From b0e19f8efffcd79da238b86b6775e264224d4b07 Mon Sep 17 00:00:00 2001 From: Timon Back Date: Wed, 2 Oct 2024 08:23:50 +0200 Subject: [PATCH] test: add amqp 0.4.0 binding test Co-authored-by: Pavel Bodiachevskii --- bindings/amqp/0.4.0/channel.json | 4 +- test/ajv-schemes.js | 3 + .../amqp/amqp channel binding.test.mjs | 90 ++++++++++++++++++- .../amqp/amqp message binding.test.mjs | 30 ++++++- .../amqp/amqp operation binding.test.mjs | 41 ++++++++- 5 files changed, 162 insertions(+), 6 deletions(-) diff --git a/bindings/amqp/0.4.0/channel.json b/bindings/amqp/0.4.0/channel.json index de1d99c6..d2a7a854 100644 --- a/bindings/amqp/0.4.0/channel.json +++ b/bindings/amqp/0.4.0/channel.json @@ -23,9 +23,7 @@ }, "channel": { "type": "object", - "properties": { - "$ref": "http://asyncapi.com/definitions/3.0.0/Reference.json" - } + "$ref": "http://asyncapi.com/definitions/3.0.0/Reference.json" }, "exchange": { "type": "object", diff --git a/test/ajv-schemes.js b/test/ajv-schemes.js index 8b2d79ad..557390ec 100644 --- a/test/ajv-schemes.js +++ b/test/ajv-schemes.js @@ -7,6 +7,9 @@ function bindingSchemes(ajv) { ajv.addSchema(require('@bindings/amqp/0.3.0/channel.json')); ajv.addSchema(require('@bindings/amqp/0.3.0/message.json')); ajv.addSchema(require('@bindings/amqp/0.3.0/operation.json')); + ajv.addSchema(require('@bindings/amqp/0.4.0/channel.json')); + ajv.addSchema(require('@bindings/amqp/0.4.0/message.json')); + ajv.addSchema(require('@bindings/amqp/0.4.0/operation.json')); ajv.addSchema(require('@bindings/anypointmq/0.0.1/channel.json')); ajv.addSchema(require('@bindings/anypointmq/0.0.1/message.json')); diff --git a/test/bindings/amqp/amqp channel binding.test.mjs b/test/bindings/amqp/amqp channel binding.test.mjs index 74173ef9..de8795ea 100644 --- a/test/bindings/amqp/amqp channel binding.test.mjs +++ b/test/bindings/amqp/amqp channel binding.test.mjs @@ -160,12 +160,100 @@ let data = { }, "ext-number": 1 } + ), + "0.4.0": new JsonSchemaTestSuiteData( + require(`@bindings/amqp/0.4.0/channel.json`), + [ + { + "is": "queue", + "queue": { + "name": "my-queue-name", + "durable": true, + "exclusive": true, + "autoDelete": false, + "vhost": "/" + }, + "bindingVersion": "0.4.0" + }, + { + "is": "routingKey", + "exchange": { + "name": "myExchange", + "type": "topic", + "durable": true, + "autoDelete": false, + "vhost": "/" + }, + "bindingVersion": "0.4.0" + }, + { + "is": "routingKey", + "name": "routingKeyName", + "channel": { + "$ref": "#/components/channels/queue-update" + }, + "exchange": { + "name": "myExchange", + "type": "topic", + "durable": true, + "autoDelete": false, + "vhost": "/" + }, + "bindingVersion": "0.4.0" + } + ], + { + "is": "queue", + "queue": { + "name": "my-queue-name", + "durable": true, + "exclusive": true, + "autoDelete": false, + "vhost": "/" + }, + "bindingVersion": "0.4.0" + }, + { + "bindingVersion": "0.4.0" + }, + { + "is": "queue", + "queue": { + "name": "my-queue-name", + "durable": true, + "exclusive": true, + "autoDelete": false, + "vhost": "/" + }, + "x-number": 0, + "x-string": "", + "x-object": { + "property": {} + } + }, + { + "is": "queue", + "queue": { + "name": "my-queue-name", + "durable": true, + "exclusive": true, + "autoDelete": false, + "vhost": "/" + }, + "x-number": 0, + "x-string": "", + "x-object": { + "property": {} + }, + "ext-number": 1 + } ) } describe.each([ '0.2.0', - '0.3.0' + '0.3.0', + '0.4.0', ])('AMQP channel binding v%s', (bindingVersion) => { new JsonSchemaTestSuite(data[bindingVersion], config).testSuite() }) diff --git a/test/bindings/amqp/amqp message binding.test.mjs b/test/bindings/amqp/amqp message binding.test.mjs index ffbcc3a5..3f8d11cc 100644 --- a/test/bindings/amqp/amqp message binding.test.mjs +++ b/test/bindings/amqp/amqp message binding.test.mjs @@ -66,12 +66,40 @@ let data = { }, "ext-number": 1 } + ), + "0.4.0": new JsonSchemaTestSuiteData( + require(`@bindings/amqp/0.4.0/message.json`), + [ + { + "contentEncoding": "gzip", + "messageType": "user.signup", + "bindingVersion": "0.4.0" + } + ], + {}, + {}, + { + "x-number": 0, + "x-string": "", + "x-object": { + "property": {} + } + }, + { + "x-number": 0, + "x-string": "", + "x-object": { + "property": {} + }, + "ext-number": 1 + } ) } describe.each([ '0.2.0', - '0.3.0' + '0.3.0', + '0.4.0' ])('AMQP message binding v%s', (bindingVersion) => { new JsonSchemaTestSuite(data[bindingVersion], config).testSuite() }) diff --git a/test/bindings/amqp/amqp operation binding.test.mjs b/test/bindings/amqp/amqp operation binding.test.mjs index b5882714..368890bb 100644 --- a/test/bindings/amqp/amqp operation binding.test.mjs +++ b/test/bindings/amqp/amqp operation binding.test.mjs @@ -88,12 +88,51 @@ let data = { }, "ext-number": 1 } + ), + "0.4.0": new JsonSchemaTestSuiteData( + require(`@bindings/amqp/0.4.0/operation.json`), + [ + { + "expiration": 100000, + "userId": "guest", + "cc": [ + "user.logs" + ], + "priority": 10, + "deliveryMode": 2, + "mandatory": false, + "bcc": [ + "external.audit" + ], + "timestamp": true, + "ack": false, + "bindingVersion": "0.4.0" + } + ], + {}, + {}, + { + "x-number": 0, + "x-string": "", + "x-object": { + "property": {} + } + }, + { + "x-number": 0, + "x-string": "", + "x-object": { + "property": {} + }, + "ext-number": 1 + } ) } describe.each([ '0.2.0', - '0.3.0' + '0.3.0', + '0.4.0' ])('AMQP operation binding v%s', (bindingVersion) => { new JsonSchemaTestSuite(data[bindingVersion], config).testSuite() })