Allow empty strings for signatures in JSON relayables
This commit is contained in:
parent
1fed7b501c
commit
7cc0112877
6 changed files with 28 additions and 2 deletions
|
|
@ -17,8 +17,17 @@
|
|||
|
||||
"definitions": {
|
||||
"signature": {
|
||||
"type": "string",
|
||||
"minLength": 30
|
||||
"oneOf" : [
|
||||
{
|
||||
"type": "string",
|
||||
"minLength": 30
|
||||
},
|
||||
{
|
||||
"type": "string",
|
||||
"maxLength": 0,
|
||||
"description": "Allow empty string when no signature is provided"
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
"guid": {
|
||||
|
|
|
|||
|
|
@ -55,6 +55,8 @@ JSON
|
|||
|
||||
it_behaves_like "a relayable Entity"
|
||||
|
||||
it_behaves_like "a relayable JSON entity"
|
||||
|
||||
describe "#created_at" do
|
||||
it "has a created_at after parse" do
|
||||
entity = described_class.from_xml(Nokogiri::XML::Document.parse(xml).root)
|
||||
|
|
|
|||
|
|
@ -56,6 +56,8 @@ JSON
|
|||
|
||||
it_behaves_like "a relayable Entity"
|
||||
|
||||
it_behaves_like "a relayable JSON entity"
|
||||
|
||||
context "invalid XML" do
|
||||
it "raises a ValidationError if the parent_type is missing" do
|
||||
broken_xml = <<-XML
|
||||
|
|
|
|||
|
|
@ -53,6 +53,8 @@ JSON
|
|||
|
||||
it_behaves_like "a relayable Entity"
|
||||
|
||||
it_behaves_like "a relayable JSON entity"
|
||||
|
||||
describe "#sender_valid?" do
|
||||
let(:entity) { Entities::Participation.new(data) }
|
||||
|
||||
|
|
|
|||
|
|
@ -51,5 +51,7 @@ JSON
|
|||
it_behaves_like "a JSON Entity"
|
||||
|
||||
it_behaves_like "a relayable Entity"
|
||||
|
||||
it_behaves_like "a relayable JSON entity"
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -188,3 +188,12 @@ shared_examples "a JSON Entity" do
|
|||
expect(described_class.from_json(JSON.parse(entity_json)).to_json.to_json).to eq(entity_json)
|
||||
end
|
||||
end
|
||||
|
||||
shared_examples "a relayable JSON entity" do
|
||||
it "matches JSON schema with empty string signatures" do
|
||||
json = described_class.new(data).to_json
|
||||
json[:entity_data][:author_signature] = ""
|
||||
json[:entity_data][:parent_author_signature] = ""
|
||||
expect(json.to_json).to match_json_schema(:entity_schema)
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Reference in a new issue