handle SignedRetraction and RelayableRetraction as Retraction after parse

This commit is contained in:
Benjamin Neff 2016-03-18 03:12:31 +01:00
parent bd9cc67f5e
commit 930c3051c7
4 changed files with 30 additions and 2 deletions

View file

@ -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.
#

View file

@ -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.
#

View file

@ -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

View file

@ -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