From 7370a32c65a42dd17fde8eed871e5b73778c7898 Mon Sep 17 00:00:00 2001 From: Benjamin Neff Date: Sat, 4 Jul 2015 19:46:27 +0200 Subject: [PATCH] use serialized_public_key because a conflict with the diaspora code --- lib/diaspora_federation.rb | 4 ++-- lib/diaspora_federation/web_finger/h_card.rb | 24 +++++++++---------- .../web_finger/web_finger.rb | 20 ++++++++-------- .../web_finger/h_card_spec.rb | 4 ++-- .../web_finger/web_finger_spec.rb | 6 ++--- test/dummy/app/models/person.rb | 1 - 6 files changed, 29 insertions(+), 30 deletions(-) diff --git a/lib/diaspora_federation.rb b/lib/diaspora_federation.rb index 85ba255..886fc9e 100644 --- a/lib/diaspora_federation.rb +++ b/lib/diaspora_federation.rb @@ -43,7 +43,7 @@ module DiasporaFederation # +guid+: the guid # "0123456789abcdef" # - # +public_key+: the public key of the person (DER-encoded PKCS#1 key) + # +serialized_public_key+: the public key of the person (DER-encoded PKCS#1 key) # "-----BEGIN PUBLIC KEY----- # ABCDEF== # -----END PUBLIC KEY-----" @@ -115,7 +115,7 @@ module DiasporaFederation configuration_error "missing server_uri" unless @server_uri.respond_to? :host validate_class(@person_class, "person_class", %i( find_local_by_diaspora_handle find_local_by_guid - diaspora_handle nickname guid public_key searchable + diaspora_handle nickname guid serialized_public_key searchable alias_url hcard_url seed_url profile_url atom_url salmon_url photo_large_url photo_medium_url photo_small_url full_name first_name last_name diff --git a/lib/diaspora_federation/web_finger/h_card.rb b/lib/diaspora_federation/web_finger/h_card.rb index 23880b9..65081ff 100644 --- a/lib/diaspora_federation/web_finger/h_card.rb +++ b/lib/diaspora_federation/web_finger/h_card.rb @@ -18,17 +18,17 @@ module DiasporaFederation # html_string = HCard.from_person(person).to_html # # The person object should have the following attributes (with examples) - # guid: "0123456789abcdef", - # nickname: "user", - # full_name: "User Name", - # seed_url: "https://server.example/", - # photo_large_url: "https://server.example/uploads/l.jpg", - # photo_medium_url: "https://server.example/uploads/m.jpg", - # photo_small_url: "https://server.example/uploads/s.jpg", - # public_key: "-----BEGIN PUBLIC KEY-----\nABCDEF==\n-----END PUBLIC KEY-----", - # searchable: true, - # first_name: "User", - # last_name: "Name" + # guid: "0123456789abcdef", + # nickname: "user", + # full_name: "User Name", + # seed_url: "https://server.example/", + # photo_large_url: "https://server.example/uploads/l.jpg", + # photo_medium_url: "https://server.example/uploads/m.jpg", + # photo_small_url: "https://server.example/uploads/s.jpg", + # serialized_public_key: "-----BEGIN PUBLIC KEY-----\nABCDEF==\n-----END PUBLIC KEY-----", + # searchable: true, + # first_name: "User", + # last_name: "Name" # # @example Create a HCard instance from an hCard document # hc = HCard.from_html(html_string) @@ -161,7 +161,7 @@ module DiasporaFederation @photo_large_url = person.photo_large_url @photo_medium_url = person.photo_medium_url @photo_small_url = person.photo_small_url - @public_key = person.public_key + @public_key = person.serialized_public_key @searchable = person.searchable # TODO: remove me! ################### diff --git a/lib/diaspora_federation/web_finger/web_finger.rb b/lib/diaspora_federation/web_finger/web_finger.rb index 0318e64..8d3afea 100644 --- a/lib/diaspora_federation/web_finger/web_finger.rb +++ b/lib/diaspora_federation/web_finger/web_finger.rb @@ -13,15 +13,15 @@ module DiasporaFederation # xml_string = WebFinger.from_person(person).to_xml # # The person object should have the following attributes (with examples) - # diaspora_handle: "user@server.example" - # alias_url: "https://server.example/people/0123456789abcdef" - # hcard_url: "https://server.example/hcard/users/0123456789abcdef" - # seed_url: "https://server.example/" - # profile_url: "https://server.example/u/user" - # atom_url: "https://server.example/public/user.atom" - # salmon_url: "https://server.example/receive/users/0123456789abcdef" - # guid: "0123456789abcdef" - # public_key: "-----BEGIN PUBLIC KEY-----\nABCDEF==\n-----END PUBLIC KEY-----" + # diaspora_handle: "user@server.example" + # alias_url: "https://server.example/people/0123456789abcdef" + # hcard_url: "https://server.example/hcard/users/0123456789abcdef" + # seed_url: "https://server.example/" + # profile_url: "https://server.example/u/user" + # atom_url: "https://server.example/public/user.atom" + # salmon_url: "https://server.example/receive/users/0123456789abcdef" + # guid: "0123456789abcdef" + # serialized_public_key: "-----BEGIN PUBLIC KEY-----\nABCDEF==\n-----END PUBLIC KEY-----" # # @example Creating a WebFinger instance from an xml document # wf = WebFinger.from_xml(xml_string) @@ -150,7 +150,7 @@ module DiasporaFederation # TODO: remove me! ######### @guid = person.guid - @public_key = person.public_key + @public_key = person.serialized_public_key ############################# } wf diff --git a/spec/lib/diaspora_federation/web_finger/h_card_spec.rb b/spec/lib/diaspora_federation/web_finger/h_card_spec.rb index bcf4ac2..368052e 100644 --- a/spec/lib/diaspora_federation/web_finger/h_card_spec.rb +++ b/spec/lib/diaspora_federation/web_finger/h_card_spec.rb @@ -43,7 +43,7 @@ module DiasporaFederation
Key
-
#{person.public_key}
+
#{person.serialized_public_key}
@@ -114,7 +114,7 @@ HTML expect(hcard.photo_large_url).to eq(person.photo_large_url) expect(hcard.photo_medium_url).to eq(person.photo_medium_url) expect(hcard.photo_small_url).to eq(person.photo_small_url) - expect(hcard.public_key).to eq(person.public_key) + expect(hcard.public_key).to eq(person.serialized_public_key) expect(hcard.searchable).to eq(person.searchable) expect(hcard.first_name).to eq(person.first_name) diff --git a/spec/lib/diaspora_federation/web_finger/web_finger_spec.rb b/spec/lib/diaspora_federation/web_finger/web_finger_spec.rb index 6b89fb9..fa02ea8 100644 --- a/spec/lib/diaspora_federation/web_finger/web_finger_spec.rb +++ b/spec/lib/diaspora_federation/web_finger/web_finger_spec.rb @@ -2,7 +2,7 @@ module DiasporaFederation describe WebFinger::WebFinger do let(:person) { FactoryGirl.create(:person) } let(:acct) { "acct:#{person.diaspora_handle}" } - let(:public_key_base64) { Base64.strict_encode64(person.public_key) } + let(:public_key_base64) { Base64.strict_encode64(person.serialized_public_key) } let(:xml) { <<-XML @@ -48,7 +48,7 @@ XML expect(wf.salmon_url).to eq(person.salmon_url) expect(wf.guid).to eq(person.guid) - expect(wf.public_key).to eq(person.public_key) + expect(wf.public_key).to eq(person.serialized_public_key) end it "reads old-style XML" do @@ -79,7 +79,7 @@ XML expect(wf.salmon_url).to eq(person.salmon_url) expect(wf.guid).to eq(person.guid) - expect(wf.public_key).to eq(person.public_key) + expect(wf.public_key).to eq(person.serialized_public_key) end it "fails if the document is empty" do diff --git a/test/dummy/app/models/person.rb b/test/dummy/app/models/person.rb index fd684ca..17d9259 100644 --- a/test/dummy/app/models/person.rb +++ b/test/dummy/app/models/person.rb @@ -8,7 +8,6 @@ class Person < ActiveRecord::Base def salmon_url; "#{url}receive/users/#{guid}" end alias_attribute :seed_url, :url - alias_attribute :public_key, :serialized_public_key def nickname; diaspora_handle.split("@")[0] end def photo_large_url; "#{url}assets/user/default.png" end