handle SignedRetraction and RelayableRetraction as Retraction after parse
This commit is contained in:
parent
bd9cc67f5e
commit
930c3051c7
4 changed files with 30 additions and 2 deletions
|
|
@ -61,6 +61,13 @@ module DiasporaFederation
|
||||||
|
|
||||||
private
|
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
|
# 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.
|
# if the signatures are not there yet and if the keys are available.
|
||||||
#
|
#
|
||||||
|
|
|
||||||
|
|
@ -46,6 +46,13 @@ module DiasporaFederation
|
||||||
|
|
||||||
private
|
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
|
# 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.
|
# if the signatures are not there yet and if the keys are available.
|
||||||
#
|
#
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@ XML
|
||||||
|
|
||||||
it_behaves_like "an Entity subclass"
|
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
|
describe "#to_xml" do
|
||||||
let(:author_pkey) { OpenSSL::PKey::RSA.generate(1024) }
|
let(:author_pkey) { OpenSSL::PKey::RSA.generate(1024) }
|
||||||
|
|
@ -95,5 +95,12 @@ XML
|
||||||
expect(retraction.target_type).to eq(relayable_retraction.target_type)
|
expect(retraction.target_type).to eq(relayable_retraction.target_type)
|
||||||
end
|
end
|
||||||
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
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@ XML
|
||||||
|
|
||||||
it_behaves_like "an Entity subclass"
|
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
|
describe "#to_xml" do
|
||||||
let(:author_pkey) { OpenSSL::PKey::RSA.generate(1024) }
|
let(:author_pkey) { OpenSSL::PKey::RSA.generate(1024) }
|
||||||
|
|
@ -63,5 +63,12 @@ XML
|
||||||
expect(retraction.target_type).to eq(signed_retraction.target_type)
|
expect(retraction.target_type).to eq(signed_retraction.target_type)
|
||||||
end
|
end
|
||||||
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
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue