don't include signatures in xml_order on receive
This commit is contained in:
parent
ba129aafa3
commit
41de99bd5e
2 changed files with 11 additions and 6 deletions
|
|
@ -72,7 +72,7 @@ module DiasporaFederation
|
|||
# @param [Hash] additional_xml_elements additional xml elements
|
||||
# @see DiasporaFederation::Entity#initialize
|
||||
def initialize(data, xml_order=nil, additional_xml_elements={})
|
||||
@xml_order = xml_order
|
||||
@xml_order = xml_order.try(:reject) {|name| name =~ /signature/ }
|
||||
@additional_xml_elements = additional_xml_elements
|
||||
|
||||
super(data)
|
||||
|
|
@ -164,7 +164,7 @@ module DiasporaFederation
|
|||
def signature_order
|
||||
if xml_order
|
||||
prop_names = self.class.class_props.keys.map(&:to_s)
|
||||
xml_order.reject {|name| name =~ /signature/ }.map {|name| prop_names.include?(name) ? name.to_sym : name }
|
||||
xml_order.map {|name| prop_names.include?(name) ? name.to_sym : name }
|
||||
else
|
||||
self.class::LEGACY_SIGNATURE_ORDER
|
||||
end
|
||||
|
|
|
|||
|
|
@ -183,6 +183,13 @@ XML
|
|||
expect(xml.at_xpath("new_property").text).to be_empty
|
||||
end
|
||||
|
||||
it "filters signatures from order" do
|
||||
xml_order = [:author, :guid, :parent_guid, :property, "new_property", :author_signature]
|
||||
|
||||
expect(SomeRelayable.new(hash, xml_order).xml_order)
|
||||
.to eq([:author, :guid, :parent_guid, :property, "new_property"])
|
||||
end
|
||||
|
||||
it "computes correct signatures for the entity" do
|
||||
expect_callback(:fetch_private_key, author).and_return(author_pkey)
|
||||
expect_callback(:fetch_private_key, local_parent.author).and_return(parent_pkey)
|
||||
|
|
@ -273,12 +280,10 @@ XML
|
|||
)
|
||||
end
|
||||
|
||||
it "hand over the order in the xml to the instance" do
|
||||
it "hand over the order in the xml to the instance without signatures" do
|
||||
entity = SomeRelayable.from_xml(Nokogiri::XML::Document.parse(new_xml).root)
|
||||
|
||||
expect(entity.xml_order).to eq(
|
||||
[:author, :guid, :parent_guid, "new_property", :property, :author_signature, :parent_author_signature]
|
||||
)
|
||||
expect(entity.xml_order).to eq([:author, :guid, :parent_guid, "new_property", :property])
|
||||
end
|
||||
|
||||
it "creates Entity with empty 'additional_xml_elements' if the xml has only known properties" do
|
||||
|
|
|
|||
Loading…
Reference in a new issue