diff --git a/lib/diaspora_federation/entities/relayable_retraction.rb b/lib/diaspora_federation/entities/relayable_retraction.rb index a235f39..e6596b1 100644 --- a/lib/diaspora_federation/entities/relayable_retraction.rb +++ b/lib/diaspora_federation/entities/relayable_retraction.rb @@ -61,6 +61,13 @@ module DiasporaFederation private + # @param [Nokogiri::XML::Element] root_node xml nodes + # @return [Retraction] instance + def self.populate_entity(root_node) + super(root_node).to_retraction + end + private_class_method :populate_entity + # It updates also the signatures with the keys of the author and the parent # if the signatures are not there yet and if the keys are available. # diff --git a/lib/diaspora_federation/entities/signed_retraction.rb b/lib/diaspora_federation/entities/signed_retraction.rb index c61f08d..94946b8 100644 --- a/lib/diaspora_federation/entities/signed_retraction.rb +++ b/lib/diaspora_federation/entities/signed_retraction.rb @@ -46,6 +46,13 @@ module DiasporaFederation private + # @param [Nokogiri::XML::Element] root_node xml nodes + # @return [Retraction] instance + def self.populate_entity(root_node) + super(root_node).to_retraction + end + private_class_method :populate_entity + # It updates also the signatures with the keys of the author and the parent # if the signatures are not there yet and if the keys are available. # diff --git a/spec/lib/diaspora_federation/entities/relayable_retraction_spec.rb b/spec/lib/diaspora_federation/entities/relayable_retraction_spec.rb index eccfdb3..721577f 100644 --- a/spec/lib/diaspora_federation/entities/relayable_retraction_spec.rb +++ b/spec/lib/diaspora_federation/entities/relayable_retraction_spec.rb @@ -20,7 +20,7 @@ XML it_behaves_like "an Entity subclass" - it_behaves_like "an XML Entity" + it_behaves_like "an XML Entity", %i(parent_author_signature target_author_signature) describe "#to_xml" do let(:author_pkey) { OpenSSL::PKey::RSA.generate(1024) } @@ -95,5 +95,12 @@ XML expect(retraction.target_type).to eq(relayable_retraction.target_type) end end + + context "parse retraction" do + it "parses the xml as a retraction" do + retraction = Entities::RelayableRetraction.from_xml(Nokogiri::XML::Document.parse(xml).root) + expect(retraction).to be_a(Entities::Retraction) + end + end end end diff --git a/spec/lib/diaspora_federation/entities/signed_retraction_spec.rb b/spec/lib/diaspora_federation/entities/signed_retraction_spec.rb index 8cd969a..b8f7d4a 100644 --- a/spec/lib/diaspora_federation/entities/signed_retraction_spec.rb +++ b/spec/lib/diaspora_federation/entities/signed_retraction_spec.rb @@ -15,7 +15,7 @@ XML it_behaves_like "an Entity subclass" - it_behaves_like "an XML Entity" + it_behaves_like "an XML Entity", [:target_author_signature] describe "#to_xml" do let(:author_pkey) { OpenSSL::PKey::RSA.generate(1024) } @@ -63,5 +63,12 @@ XML expect(retraction.target_type).to eq(signed_retraction.target_type) end end + + context "parse retraction" do + it "parses the xml as a retraction" do + retraction = Entities::SignedRetraction.from_xml(Nokogiri::XML::Document.parse(xml).root) + expect(retraction).to be_a(Entities::Retraction) + end + end end end