Merge pull request #57 from cmrd-senya/allow-empty-signature

Allow empty strings for signatures in JSON relayables
This commit is contained in:
Benjamin Neff 2017-04-01 02:45:22 +02:00
commit 9aeda2151e
No known key found for this signature in database
GPG key ID: 971464C3F1A90194
6 changed files with 28 additions and 2 deletions

View file

@ -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": {

View file

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

View file

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

View file

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

View file

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

View file

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