Merge pull request #57 from cmrd-senya/allow-empty-signature
Allow empty strings for signatures in JSON relayables
This commit is contained in:
commit
9aeda2151e
6 changed files with 28 additions and 2 deletions
|
|
@ -17,8 +17,17 @@
|
||||||
|
|
||||||
"definitions": {
|
"definitions": {
|
||||||
"signature": {
|
"signature": {
|
||||||
"type": "string",
|
"oneOf" : [
|
||||||
"minLength": 30
|
{
|
||||||
|
"type": "string",
|
||||||
|
"minLength": 30
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "string",
|
||||||
|
"maxLength": 0,
|
||||||
|
"description": "Allow empty string when no signature is provided"
|
||||||
|
}
|
||||||
|
]
|
||||||
},
|
},
|
||||||
|
|
||||||
"guid": {
|
"guid": {
|
||||||
|
|
|
||||||
|
|
@ -55,6 +55,8 @@ JSON
|
||||||
|
|
||||||
it_behaves_like "a relayable Entity"
|
it_behaves_like "a relayable Entity"
|
||||||
|
|
||||||
|
it_behaves_like "a relayable JSON entity"
|
||||||
|
|
||||||
describe "#created_at" do
|
describe "#created_at" do
|
||||||
it "has a created_at after parse" do
|
it "has a created_at after parse" do
|
||||||
entity = described_class.from_xml(Nokogiri::XML::Document.parse(xml).root)
|
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 Entity"
|
||||||
|
|
||||||
|
it_behaves_like "a relayable JSON entity"
|
||||||
|
|
||||||
context "invalid XML" do
|
context "invalid XML" do
|
||||||
it "raises a ValidationError if the parent_type is missing" do
|
it "raises a ValidationError if the parent_type is missing" do
|
||||||
broken_xml = <<-XML
|
broken_xml = <<-XML
|
||||||
|
|
|
||||||
|
|
@ -53,6 +53,8 @@ JSON
|
||||||
|
|
||||||
it_behaves_like "a relayable Entity"
|
it_behaves_like "a relayable Entity"
|
||||||
|
|
||||||
|
it_behaves_like "a relayable JSON entity"
|
||||||
|
|
||||||
describe "#sender_valid?" do
|
describe "#sender_valid?" do
|
||||||
let(:entity) { Entities::Participation.new(data) }
|
let(:entity) { Entities::Participation.new(data) }
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -51,5 +51,7 @@ JSON
|
||||||
it_behaves_like "a JSON Entity"
|
it_behaves_like "a JSON Entity"
|
||||||
|
|
||||||
it_behaves_like "a relayable Entity"
|
it_behaves_like "a relayable Entity"
|
||||||
|
|
||||||
|
it_behaves_like "a relayable JSON entity"
|
||||||
end
|
end
|
||||||
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)
|
expect(described_class.from_json(JSON.parse(entity_json)).to_json.to_json).to eq(entity_json)
|
||||||
end
|
end
|
||||||
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