Skip to content

Commit

Permalink
Merge pull request hotsh#601 from wilkie/bugfix/salmon-links-in-xrds
Browse files Browse the repository at this point in the history
Bugfix/salmon links in xrds
  • Loading branch information
steveklabnik committed Aug 20, 2012
2 parents 48c1e3c + 50e97dd commit 34118f5
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 3 deletions.
5 changes: 3 additions & 2 deletions app/views/xml/webfinger/xrd.haml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@
%Alias= "#{@base_url}feeds/#{@user.feed.id}"
%Alias= "#{@base_url}users/#{@user.username}"
%Link{:rel => "http://webfinger.net/rel/profile-page", :type => "text/html", :href => "#{@base_url}users/#{@user.username}"}
-#%Link{:rel => "http://microformats.org/profile/hcard", :type => "text/html", :href => "#{@base_url}users/#{@user.username}/hcard"}
-#%Link{:rel => "http://gmpg.org/xfn/11", :type => "text/html", :href => "#{@base_url}users/#{@user.username}"}
%Link{:rel => "http://schemas.google.com/g/2010#updates-from", :href => "#{@base_url}feeds/#{@user.feed.id}.atom"}
%Link{:rel => "http://ostatus.org/schema/1.0/subscribe", :href => "#{@base_url}subscriptions?url={uri}&_method=post"}
%Link{:rel => "salmon", :href => "#{@base_url}feeds/#{@user.feed.id}/salmon"}
%Link{:rel => "http://salmon-protocol.org/ns/salmon-replies", :href => "#{@base_url}feeds/#{@user.feed.id}/salmon"}
%Link{:rel => "http://salmon-protocol.org/ns/salmon-mention", :href => "#{@base_url}feeds/#{@user.feed.id}/salmon"}
%Link{:rel => "magic-public-key", :href => "data:application/magic-public-key,#{@user.author.public_key}"}
36 changes: 35 additions & 1 deletion test/acceptance/webfinger_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,40 @@
describe "Webfinger" do
include AcceptanceHelper

describe "user xrd" do
before do
@user = Fabricate(:user)
@subject = "acct:#{@user.username}@#{@user.author.domain}"
get "/users/#{@subject}/xrd.xml"
if last_response.status == 301
follow_redirect!
end

@xml = Nokogiri.XML(last_response.body)
end

it "contains the salmon url" do
regex = /^http(?:s)?:\/\/.*\/feeds\/#{@user.feed.id}\/salmon$/
profile_rel = "salmon"
profile_uri = @xml.xpath("//xmlns:Link[@rel='#{profile_rel}']")
profile_uri.first.attr("href").must_match regex
end

it "contains the salmon-replies url" do
regex = /^http(?:s)?:\/\/.*\/feeds\/#{@user.feed.id}\/salmon$/
profile_rel = "http://salmon-protocol.org/ns/salmon-replies"
profile_uri = @xml.xpath("//xmlns:Link[@rel='#{profile_rel}']")
profile_uri.first.attr("href").must_match regex
end

it "contains the salmon-mention url" do
regex = /^http(?:s)?:\/\/.*\/feeds\/#{@user.feed.id}\/salmon$/
profile_rel = "http://salmon-protocol.org/ns/salmon-mention"
profile_uri = @xml.xpath("//xmlns:Link[@rel='#{profile_rel}']")
profile_uri.first.attr("href").must_match regex
end
end

it "404s if that user doesnt exist" do
get "/users/acct:[email protected]/xrd.xml"
if last_response.status == 301
Expand All @@ -25,4 +59,4 @@

subject.must_equal(param)
end
end
end

0 comments on commit 34118f5

Please sign in to comment.