From 89fd79e8a465b12695d2da93bc8f5443a8da6368 Mon Sep 17 00:00:00 2001 From: wilkie Date: Sun, 19 Aug 2012 14:25:52 -0400 Subject: [PATCH 1/3] Adds salmon links to xrd. These endpoints are completed in the routes, but without them in the xrd, no ostatus client would know how to reach an rstat.us node user. That would make me sad. All three links are required, but normally they all point to the same route. This is true for us and status.net, so don't be alarmed by it. I'm not sure why anybody would want to distinguish them by route since the envelope exposes this, and this distinction does not make it a separate resource at all. :( --- app/views/xml/webfinger/xrd.haml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/views/xml/webfinger/xrd.haml b/app/views/xml/webfinger/xrd.haml index 489be009..52a1f622 100644 --- a/app/views/xml/webfinger/xrd.haml +++ b/app/views/xml/webfinger/xrd.haml @@ -8,4 +8,7 @@ -#%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}"} From 6057a3df761b645991061e108616aedfde940b6f Mon Sep 17 00:00:00 2001 From: wilkie Date: Sun, 19 Aug 2012 19:29:41 -0400 Subject: [PATCH 2/3] Removing commented out lines in xrd.haml. Let's use source control! --- app/views/xml/webfinger/xrd.haml | 2 -- 1 file changed, 2 deletions(-) diff --git a/app/views/xml/webfinger/xrd.haml b/app/views/xml/webfinger/xrd.haml index 52a1f622..9201ea4d 100644 --- a/app/views/xml/webfinger/xrd.haml +++ b/app/views/xml/webfinger/xrd.haml @@ -4,8 +4,6 @@ %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"} From 50e97dda4f6922c21469c70a3f97bb5ae72c254d Mon Sep 17 00:00:00 2001 From: wilkie Date: Sun, 19 Aug 2012 19:52:48 -0400 Subject: [PATCH 3/3] Adds tests to ensure that the salmon urls exist in the user xrd. I added a section to the webfinger tests which test that the xrd served by a webfinger request contain the three salmon urls necessary to get salmon notifications. Again, the three are not necessary, but it is nice to provide all three even if they are the same url. I will add more tests for the remaining things in the xrd to this set of acceptance tests. --- test/acceptance/webfinger_test.rb | 36 ++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/test/acceptance/webfinger_test.rb b/test/acceptance/webfinger_test.rb index bfdaa110..cd5a7359 100644 --- a/test/acceptance/webfinger_test.rb +++ b/test/acceptance/webfinger_test.rb @@ -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:nonexistent@somedomain.com/xrd.xml" if last_response.status == 301 @@ -25,4 +59,4 @@ subject.must_equal(param) end -end \ No newline at end of file +end