From bfabde3215b4014b4f2315d808337c7b52aa6738 Mon Sep 17 00:00:00 2001 From: Evan Anderson Date: Mon, 17 Jun 2019 15:26:14 -0700 Subject: [PATCH 01/15] Define several tricky cases for encoding based on spec. Signed-off-by: Evan Anderson --- testcases/README.md | 31 +++++++++++++++++++++++++++++ testcases/contenttype.http | 11 ++++++++++ testcases/contenttype.json | 12 +++++++++++ testcases/contenttype.mqtt | 12 +++++++++++ testcases/extensions-map.http | 11 ++++++++++ testcases/extensions-map.json | 17 ++++++++++++++++ testcases/extensions-map.mqtt | 11 ++++++++++ testcases/unicode-strings.http | 9 +++++++++ testcases/unicode-strings.http-json | 22 ++++++++++++++++++++ testcases/unicode-strings.json | 16 +++++++++++++++ testcases/unicode-strings.mqtt | 11 ++++++++++ testcases/urls.http | 9 +++++++++ testcases/urls.json | 16 +++++++++++++++ 13 files changed, 188 insertions(+) create mode 100644 testcases/README.md create mode 100644 testcases/contenttype.http create mode 100644 testcases/contenttype.json create mode 100644 testcases/contenttype.mqtt create mode 100644 testcases/extensions-map.http create mode 100644 testcases/extensions-map.json create mode 100644 testcases/extensions-map.mqtt create mode 100644 testcases/unicode-strings.http create mode 100644 testcases/unicode-strings.http-json create mode 100644 testcases/unicode-strings.json create mode 100644 testcases/unicode-strings.mqtt create mode 100644 testcases/urls.http create mode 100644 testcases/urls.json diff --git a/testcases/README.md b/testcases/README.md new file mode 100644 index 000000000..cba431a02 --- /dev/null +++ b/testcases/README.md @@ -0,0 +1,31 @@ +# Test cases for CloudEvents encoding + +These cases provide a set of "difficult" or edge-case encodings of valid CloudEvents, for use in testing various CloudEvents implementations. The cases cover transformation between a [canonical JSON object](../json-format.md) and a transport-specific output. Test cases are organized by common prefix with the following suffixes denoting different transports: + +Suffix | Encoding +--- | --- +`json` | [JSON event](../json-format.md) +`http` | [HTTP binary request](../http-transport-binding.md) +`http-json` | [HTTP structured request](../http-transport-binding.md) +`mqtt` | [MQTT binary publish](../mqtt-transport-binding.md) +`mqtt-json` | [MQTT structured publish](../mqtt-transport-binding.md) +`amqp` | [AMQP message](../amqp-transport-binding.md) + +If multiple files exist with the same input prefix, they all represent the same CloudEvent rendered across the different transports. For example, given the files: + +- `unicode-input.json` +- `unicode-input.http` +- `unicode-input.mqtt` +- `binary-date.json` +- `binary-date.amqp` + +These form two sets of tests: the `unicode-input` case is defined for JSON, HTTP, and MQTT, and the `binary-date` case is defined for QSON and AMQP. + +Test cases which describe particularly unexpected formats should include comments in the JSON document using Javascript comment format (`//` or `/* .. */`). + + \ No newline at end of file diff --git a/testcases/contenttype.http b/testcases/contenttype.http new file mode 100644 index 000000000..e4e23fc46 --- /dev/null +++ b/testcases/contenttype.http @@ -0,0 +1,11 @@ +POST / HTTP/1.1 +Host: handler.example.com +Content-Type: application/xml +Content-Length: 24 +CE-specversion: 0.3 +CE-id: 123 +CE-source: https://cloudevents.io/contenttype +CE-type: io.cloudevetns.contenttype-test +CE-datacontentencoding: Base64 + +PG11Y2ggd293PSJ4bWwiLz4= \ No newline at end of file diff --git a/testcases/contenttype.json b/testcases/contenttype.json new file mode 100644 index 000000000..4509d3b3a --- /dev/null +++ b/testcases/contenttype.json @@ -0,0 +1,12 @@ +{ + "specversion": "0.3", + "id": "123", + + "source": "https://cloudevents.io/contenttype", + "type": "io.cloudevents.contenttype-test", + + "datacontentencoding": "Base64", + "datacontenttype": "application/xml", + + "data": "PG11Y2ggd293PSJ4bWwiLz4=", // +} \ No newline at end of file diff --git a/testcases/contenttype.mqtt b/testcases/contenttype.mqtt new file mode 100644 index 000000000..76ad15cc4 --- /dev/null +++ b/testcases/contenttype.mqtt @@ -0,0 +1,12 @@ +------------------ PUBLISH --------------- +Topic Name: mytopic +Content Type: application/xml +--------------- User Properties ---------- +specversion: 0.3 +id: 123 +source: https://cloudevents.io/contenttype +type: io.cloudevents.contenttype-test +datacontentencoding: Base64 +------------------ payload --------------- +PG11Y2ggd293PSJ4bWwiLz4= +------------------------------------------ \ No newline at end of file diff --git a/testcases/extensions-map.http b/testcases/extensions-map.http new file mode 100644 index 000000000..adff9774c --- /dev/null +++ b/testcases/extensions-map.http @@ -0,0 +1,11 @@ +POST / HTTP/1.1 +Host: handler.example.com +Content-Length: 0 +CE-specversion: 0.3 +CE-id: 123 +CE-source: https://cloudevents.io/extensions-map +CE-type: io.cloudevents.extensions-map-test +CE-this0is0ok-\: ok +CE-this0is0ok-": {\"u005c": 17} +Content-Type: application/xml + diff --git a/testcases/extensions-map.json b/testcases/extensions-map.json new file mode 100644 index 000000000..089460f1d --- /dev/null +++ b/testcases/extensions-map.json @@ -0,0 +1,17 @@ +{ + "specversion": "0.3", + "id": "123", + + "source": "https://cloudevents.io/extensions-map", + "type": "io.cloudevents.extensions-map-test", + + /*** + * EXTENSIONS, with a map value + */ + "this0is0ok": { + "\\": "ok", + "\"": { + "\u005c": "17" + } + } +} \ No newline at end of file diff --git a/testcases/extensions-map.mqtt b/testcases/extensions-map.mqtt new file mode 100644 index 000000000..47e79e771 --- /dev/null +++ b/testcases/extensions-map.mqtt @@ -0,0 +1,11 @@ +------------------ PUBLISH --------------- +Topic Name: mytopic +Content Type: +--------------- User Properties ---------- +specversion: 0.3 +id: 123 +source: https://cloudevents.io/extensions-map +type: io.cloudevents.extensions-map-test +this0is0ok: {"\\":"ok","\"":{"\\": "17"}} +------------------ payload --------------- +------------------------------------------ \ No newline at end of file diff --git a/testcases/unicode-strings.http b/testcases/unicode-strings.http new file mode 100644 index 000000000..0266cd221 --- /dev/null +++ b/testcases/unicode-strings.http @@ -0,0 +1,9 @@ +POST / HTTP/1.1 +Host: handler.example.com +Content-Length: 0 +CE-specversion: 0.3 +CE-id: %22%F0%9F%98%89%03%3c.is%2BFine%E7%81%AB%22 +CE-source: https://cloudevents.io/unicode-strings +CE-type: %22%F0%9F%98%89%03%3c.is%2BFine%E7%81%AB%22 +CE-subject: %22%F0%9F%98%89%03%3c.is%2BFine%E7%81%AB%22 + diff --git a/testcases/unicode-strings.http-json b/testcases/unicode-strings.http-json new file mode 100644 index 000000000..462cb383a --- /dev/null +++ b/testcases/unicode-strings.http-json @@ -0,0 +1,22 @@ +POST / HTTP/1.1 +Host: handler.example.com +Content-Length: 517 +Content-Type: applications/cloudevents+json; charset=utf-8 + +{ + "specversion": "0.3", + "id": "\"😉\u033c.is+Fine火\u0022", // \u22\u1F609\u033c\u2e\u69\u73\u2b\u46\u69\u6e\u65\u706b\u22 + "source": "", // relative-ref -> relative-part -> path-empty + "type": "\"😉\u033c.is+Fine火\u0022", + "datacontentencoding": "Base64", + "datacontenttype": "application/xml", + "schemaurl": "%2f%2f%anonymous@example.com/a&b;?x'=%2f//#//", + "subject": "\"😉\u033c.is+Fine火\u0022", + "data": "PG11Y2ggd293PSJ4bWwiLz4=", + "this0is0ok": { + "\\": "ok", + "\"": { + "\u005c": "good,too" + } + } +} \ No newline at end of file diff --git a/testcases/unicode-strings.json b/testcases/unicode-strings.json new file mode 100644 index 000000000..fb71d6bce --- /dev/null +++ b/testcases/unicode-strings.json @@ -0,0 +1,16 @@ +{ + "specversion": "0.3", + // "Printable" might or might not include " ", but probably includes + // characters that produce at least some visible output + // Go defines this as: + // > Such characters include letters, marks, numbers, punctuation, symbols, + // > and spaces, from categories L, M, N, P, S, Zs. + // https://golang.org/pkg/unicode/#IsGraphic + "id": "\"😉\u033c.is+Fine火\u0022", // \u22\u1F609\u033c\u2e\u69\u73\u2b\u46\u69\u6e\u65\u706b\u22 + + "source": "https://cloudevents.io/unicode-strings" + "type": "\"😉\u033c.is+Fine火\u0022", + + // OPTIONAL field + "subject": "\"😉\u033c.is+Fine火\u0022", +} \ No newline at end of file diff --git a/testcases/unicode-strings.mqtt b/testcases/unicode-strings.mqtt new file mode 100644 index 000000000..20793a429 --- /dev/null +++ b/testcases/unicode-strings.mqtt @@ -0,0 +1,11 @@ +------------------ PUBLISH --------------- +Topic Name: mytopic +Content Type: +--------------- User Properties ---------- +specversion: 0.3 +id: "😉̼.is+Fine火" +source: https://cloudevents.io/unicode-strings +type: "😉̼.is+Fine火" +subject: "😉̼.is+Fine火" +------------------ payload --------------- +------------------------------------------ \ No newline at end of file diff --git a/testcases/urls.http b/testcases/urls.http new file mode 100644 index 000000000..c240ddb99 --- /dev/null +++ b/testcases/urls.http @@ -0,0 +1,9 @@ +POST / HTTP/1.1 +Host: handler.example.com +Content-Length: 0 +CE-specversion: 0.3 +CE-id: 123 +CE-source: +CE-type: io.cloudevetns.url-test +CE-schemaurl: %2f%2f%anonymous@example.com/a&b;?x'=%2f//#// + diff --git a/testcases/urls.json b/testcases/urls.json new file mode 100644 index 000000000..cd1af5fb7 --- /dev/null +++ b/testcases/urls.json @@ -0,0 +1,16 @@ +{ + "specversion": "0.3", + + "id": "123", + + // Source is a URI-reference, https://tools.ietf.org/html/rfc3986#appendix-A + "source": "", // relative-ref -> relative-part -> path-empty + "type": "io.cloudevents.url-test", + + // URI-reference: https://tools.ietf.org/html/rfc3986#appendix-A + // Verify that % decoding is done properly. This is a 'path-noscheme' + // that percent-decodes to a '"//" authority path-abempty'. + "schemaurl": "%2f%2f%anonymous@example.com/a&b;?x'=%2f//#//", + + "data": "", +} \ No newline at end of file From 151dc4b5ab3d2b32057c8b881d199691f7a9e589 Mon Sep 17 00:00:00 2001 From: Evan Anderson Date: Mon, 17 Jun 2019 15:42:18 -0700 Subject: [PATCH 02/15] Run prettier.io printWidth=80 proseWrap=always Signed-off-by: Evan Anderson --- testcases/README.md | 39 ++++++++++++++++++++++++--------------- 1 file changed, 24 insertions(+), 15 deletions(-) diff --git a/testcases/README.md b/testcases/README.md index cba431a02..83ae6fd1b 100644 --- a/testcases/README.md +++ b/testcases/README.md @@ -1,17 +1,23 @@ # Test cases for CloudEvents encoding -These cases provide a set of "difficult" or edge-case encodings of valid CloudEvents, for use in testing various CloudEvents implementations. The cases cover transformation between a [canonical JSON object](../json-format.md) and a transport-specific output. Test cases are organized by common prefix with the following suffixes denoting different transports: - -Suffix | Encoding ---- | --- -`json` | [JSON event](../json-format.md) -`http` | [HTTP binary request](../http-transport-binding.md) -`http-json` | [HTTP structured request](../http-transport-binding.md) -`mqtt` | [MQTT binary publish](../mqtt-transport-binding.md) -`mqtt-json` | [MQTT structured publish](../mqtt-transport-binding.md) -`amqp` | [AMQP message](../amqp-transport-binding.md) - -If multiple files exist with the same input prefix, they all represent the same CloudEvent rendered across the different transports. For example, given the files: +These cases provide a set of "difficult" or edge-case encodings of valid +CloudEvents, for use in testing various CloudEvents implementations. The cases +cover transformation between a [canonical JSON object](../json-format.md) and a +transport-specific output. Test cases are organized by common prefix with the +following suffixes denoting different transports: + +| Suffix | Encoding | +| ----------- | ------------------------------------------------------- | +| `json` | [JSON event](../json-format.md) | +| `http` | [HTTP binary request](../http-transport-binding.md) | +| `http-json` | [HTTP structured request](../http-transport-binding.md) | +| `mqtt` | [MQTT binary publish](../mqtt-transport-binding.md) | +| `mqtt-json` | [MQTT structured publish](../mqtt-transport-binding.md) | +| `amqp` | [AMQP message](../amqp-transport-binding.md) | + +If multiple files exist with the same input prefix, they all represent the same +CloudEvent rendered across the different transports. For example, given the +files: - `unicode-input.json` - `unicode-input.http` @@ -19,13 +25,16 @@ If multiple files exist with the same input prefix, they all represent the same - `binary-date.json` - `binary-date.amqp` -These form two sets of tests: the `unicode-input` case is defined for JSON, HTTP, and MQTT, and the `binary-date` case is defined for QSON and AMQP. +These form two sets of tests: the `unicode-input` case is defined for JSON, +HTTP, and MQTT, and the `binary-date` case is defined for QSON and AMQP. -Test cases which describe particularly unexpected formats should include comments in the JSON document using Javascript comment format (`//` or `/* .. */`). +Test cases which describe particularly unexpected formats should include +comments in the JSON document using Javascript comment format (`//` or +`/* .. */`). \ No newline at end of file +--> From 87b92a350fbbe760862dc72a0f6e9269051e74e6 Mon Sep 17 00:00:00 2001 From: Evan Anderson Date: Mon, 17 Jun 2019 15:58:59 -0700 Subject: [PATCH 03/15] Resolve duglin@ comments. Signed-off-by: Evan Anderson --- testcases/contenttype.http | 10 +++++----- testcases/extensions-map.http | 12 ++++++------ testcases/unicode-strings.http | 10 +++++----- testcases/urls.http | 10 +++++----- 4 files changed, 21 insertions(+), 21 deletions(-) diff --git a/testcases/contenttype.http b/testcases/contenttype.http index e4e23fc46..05873e013 100644 --- a/testcases/contenttype.http +++ b/testcases/contenttype.http @@ -2,10 +2,10 @@ POST / HTTP/1.1 Host: handler.example.com Content-Type: application/xml Content-Length: 24 -CE-specversion: 0.3 -CE-id: 123 -CE-source: https://cloudevents.io/contenttype -CE-type: io.cloudevetns.contenttype-test -CE-datacontentencoding: Base64 +ce-specversion: 0.3 +ce-id: 123 +ce-source: https://cloudevents.io/contenttype +ce-type: io.cloudevents.contenttype-test +ce-datacontentencoding: Base64 PG11Y2ggd293PSJ4bWwiLz4= \ No newline at end of file diff --git a/testcases/extensions-map.http b/testcases/extensions-map.http index adff9774c..f7d321efe 100644 --- a/testcases/extensions-map.http +++ b/testcases/extensions-map.http @@ -1,11 +1,11 @@ POST / HTTP/1.1 Host: handler.example.com Content-Length: 0 -CE-specversion: 0.3 -CE-id: 123 -CE-source: https://cloudevents.io/extensions-map -CE-type: io.cloudevents.extensions-map-test -CE-this0is0ok-\: ok -CE-this0is0ok-": {\"u005c": 17} +ce-specversion: 0.3 +ce-id: 123 +ce-source: https://cloudevents.io/extensions-map +ce-type: io.cloudevents.extensions-map-test +ce-this0is0ok-\: ok +ce-this0is0ok-": {\"u005c": 17} Content-Type: application/xml diff --git a/testcases/unicode-strings.http b/testcases/unicode-strings.http index 0266cd221..52edc177c 100644 --- a/testcases/unicode-strings.http +++ b/testcases/unicode-strings.http @@ -1,9 +1,9 @@ POST / HTTP/1.1 Host: handler.example.com Content-Length: 0 -CE-specversion: 0.3 -CE-id: %22%F0%9F%98%89%03%3c.is%2BFine%E7%81%AB%22 -CE-source: https://cloudevents.io/unicode-strings -CE-type: %22%F0%9F%98%89%03%3c.is%2BFine%E7%81%AB%22 -CE-subject: %22%F0%9F%98%89%03%3c.is%2BFine%E7%81%AB%22 +ce-specversion: 0.3 +ce-id: %22%F0%9F%98%89%03%3c.is%2BFine%E7%81%AB%22 +ce-source: https://cloudevents.io/unicode-strings +ce-type: %22%F0%9F%98%89%03%3c.is%2BFine%E7%81%AB%22 +ce-subject: %22%F0%9F%98%89%03%3c.is%2BFine%E7%81%AB%22 diff --git a/testcases/urls.http b/testcases/urls.http index c240ddb99..844df5eb9 100644 --- a/testcases/urls.http +++ b/testcases/urls.http @@ -1,9 +1,9 @@ POST / HTTP/1.1 Host: handler.example.com Content-Length: 0 -CE-specversion: 0.3 -CE-id: 123 -CE-source: -CE-type: io.cloudevetns.url-test -CE-schemaurl: %2f%2f%anonymous@example.com/a&b;?x'=%2f//#// +ce-specversion: 0.3 +ce-id: 123 +ce-source: +ce-type: io.cloudevetns.url-test +ce-schemaurl: %2f%2f%anonymous@example.com/a&b;?x'=%2f//#// From cb99096b46c72f54171e9611485f4c263748acd1 Mon Sep 17 00:00:00 2001 From: Evan Anderson Date: Mon, 17 Jun 2019 16:01:54 -0700 Subject: [PATCH 04/15] Make one map key "", which is allowed by RFC. Signed-off-by: Evan Anderson --- testcases/extensions-map.http | 4 ++-- testcases/extensions-map.json | 5 +++-- testcases/extensions-map.mqtt | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/testcases/extensions-map.http b/testcases/extensions-map.http index f7d321efe..a851fe610 100644 --- a/testcases/extensions-map.http +++ b/testcases/extensions-map.http @@ -5,7 +5,7 @@ ce-specversion: 0.3 ce-id: 123 ce-source: https://cloudevents.io/extensions-map ce-type: io.cloudevents.extensions-map-test -ce-this0is0ok-\: ok -ce-this0is0ok-": {\"u005c": 17} +ce-this0is0ok-": ok +ce-this0is0ok-: {\"u005c": 17} Content-Type: application/xml diff --git a/testcases/extensions-map.json b/testcases/extensions-map.json index 089460f1d..1ada7713e 100644 --- a/testcases/extensions-map.json +++ b/testcases/extensions-map.json @@ -9,8 +9,9 @@ * EXTENSIONS, with a map value */ "this0is0ok": { - "\\": "ok", - "\"": { + "\": "ok", + // Empty string **is** allowed by RFC7159. + "": { "\u005c": "17" } } diff --git a/testcases/extensions-map.mqtt b/testcases/extensions-map.mqtt index 47e79e771..ac9c86093 100644 --- a/testcases/extensions-map.mqtt +++ b/testcases/extensions-map.mqtt @@ -6,6 +6,6 @@ specversion: 0.3 id: 123 source: https://cloudevents.io/extensions-map type: io.cloudevents.extensions-map-test -this0is0ok: {"\\":"ok","\"":{"\\": "17"}} +this0is0ok: {"\"":"ok","":{"\\": "17"}} ------------------ payload --------------- ------------------------------------------ \ No newline at end of file From 71637f500ad34b4e020f951980126d0179240153 Mon Sep 17 00:00:00 2001 From: Evan Anderson Date: Mon, 17 Jun 2019 16:05:27 -0700 Subject: [PATCH 05/15] Further cleanup thanks to duglin@'s eagle eye. Signed-off-by: Evan Anderson --- testcases/extensions-map.http | 1 - testcases/unicode-strings.http-json | 14 ++------------ testcases/unicode-strings.json | 2 +- testcases/urls.json | 2 -- 4 files changed, 3 insertions(+), 16 deletions(-) diff --git a/testcases/extensions-map.http b/testcases/extensions-map.http index a851fe610..2c846d7fd 100644 --- a/testcases/extensions-map.http +++ b/testcases/extensions-map.http @@ -7,5 +7,4 @@ ce-source: https://cloudevents.io/extensions-map ce-type: io.cloudevents.extensions-map-test ce-this0is0ok-": ok ce-this0is0ok-: {\"u005c": 17} -Content-Type: application/xml diff --git a/testcases/unicode-strings.http-json b/testcases/unicode-strings.http-json index 462cb383a..b6fd7ed2d 100644 --- a/testcases/unicode-strings.http-json +++ b/testcases/unicode-strings.http-json @@ -1,22 +1,12 @@ POST / HTTP/1.1 Host: handler.example.com -Content-Length: 517 +Content-Length: 279 Content-Type: applications/cloudevents+json; charset=utf-8 { "specversion": "0.3", "id": "\"😉\u033c.is+Fine火\u0022", // \u22\u1F609\u033c\u2e\u69\u73\u2b\u46\u69\u6e\u65\u706b\u22 - "source": "", // relative-ref -> relative-part -> path-empty + "source": "https://cloudevents.io/unicode-strings", "type": "\"😉\u033c.is+Fine火\u0022", - "datacontentencoding": "Base64", - "datacontenttype": "application/xml", - "schemaurl": "%2f%2f%anonymous@example.com/a&b;?x'=%2f//#//", "subject": "\"😉\u033c.is+Fine火\u0022", - "data": "PG11Y2ggd293PSJ4bWwiLz4=", - "this0is0ok": { - "\\": "ok", - "\"": { - "\u005c": "good,too" - } - } } \ No newline at end of file diff --git a/testcases/unicode-strings.json b/testcases/unicode-strings.json index fb71d6bce..3c68785a7 100644 --- a/testcases/unicode-strings.json +++ b/testcases/unicode-strings.json @@ -12,5 +12,5 @@ "type": "\"😉\u033c.is+Fine火\u0022", // OPTIONAL field - "subject": "\"😉\u033c.is+Fine火\u0022", + "subject": "\"😉\u033c.is+Fine火\u0022" } \ No newline at end of file diff --git a/testcases/urls.json b/testcases/urls.json index cd1af5fb7..3bf426790 100644 --- a/testcases/urls.json +++ b/testcases/urls.json @@ -11,6 +11,4 @@ // Verify that % decoding is done properly. This is a 'path-noscheme' // that percent-decodes to a '"//" authority path-abempty'. "schemaurl": "%2f%2f%anonymous@example.com/a&b;?x'=%2f//#//", - - "data": "", } \ No newline at end of file From d1184194abe1ba57d86f49545ae09e009acf2d67 Mon Sep 17 00:00:00 2001 From: Evan Anderson Date: Mon, 17 Jun 2019 15:26:14 -0700 Subject: [PATCH 06/15] Define several tricky cases for encoding based on spec. Signed-off-by: Evan Anderson --- testcases/README.md | 31 +++++++++++++++++++++++++++++ testcases/contenttype.http | 11 ++++++++++ testcases/contenttype.json | 12 +++++++++++ testcases/contenttype.mqtt | 12 +++++++++++ testcases/extensions-map.http | 11 ++++++++++ testcases/extensions-map.json | 17 ++++++++++++++++ testcases/extensions-map.mqtt | 11 ++++++++++ testcases/unicode-strings.http | 9 +++++++++ testcases/unicode-strings.http-json | 22 ++++++++++++++++++++ testcases/unicode-strings.json | 16 +++++++++++++++ testcases/unicode-strings.mqtt | 11 ++++++++++ testcases/urls.http | 9 +++++++++ testcases/urls.json | 16 +++++++++++++++ 13 files changed, 188 insertions(+) create mode 100644 testcases/README.md create mode 100644 testcases/contenttype.http create mode 100644 testcases/contenttype.json create mode 100644 testcases/contenttype.mqtt create mode 100644 testcases/extensions-map.http create mode 100644 testcases/extensions-map.json create mode 100644 testcases/extensions-map.mqtt create mode 100644 testcases/unicode-strings.http create mode 100644 testcases/unicode-strings.http-json create mode 100644 testcases/unicode-strings.json create mode 100644 testcases/unicode-strings.mqtt create mode 100644 testcases/urls.http create mode 100644 testcases/urls.json diff --git a/testcases/README.md b/testcases/README.md new file mode 100644 index 000000000..cba431a02 --- /dev/null +++ b/testcases/README.md @@ -0,0 +1,31 @@ +# Test cases for CloudEvents encoding + +These cases provide a set of "difficult" or edge-case encodings of valid CloudEvents, for use in testing various CloudEvents implementations. The cases cover transformation between a [canonical JSON object](../json-format.md) and a transport-specific output. Test cases are organized by common prefix with the following suffixes denoting different transports: + +Suffix | Encoding +--- | --- +`json` | [JSON event](../json-format.md) +`http` | [HTTP binary request](../http-transport-binding.md) +`http-json` | [HTTP structured request](../http-transport-binding.md) +`mqtt` | [MQTT binary publish](../mqtt-transport-binding.md) +`mqtt-json` | [MQTT structured publish](../mqtt-transport-binding.md) +`amqp` | [AMQP message](../amqp-transport-binding.md) + +If multiple files exist with the same input prefix, they all represent the same CloudEvent rendered across the different transports. For example, given the files: + +- `unicode-input.json` +- `unicode-input.http` +- `unicode-input.mqtt` +- `binary-date.json` +- `binary-date.amqp` + +These form two sets of tests: the `unicode-input` case is defined for JSON, HTTP, and MQTT, and the `binary-date` case is defined for QSON and AMQP. + +Test cases which describe particularly unexpected formats should include comments in the JSON document using Javascript comment format (`//` or `/* .. */`). + + \ No newline at end of file diff --git a/testcases/contenttype.http b/testcases/contenttype.http new file mode 100644 index 000000000..e4e23fc46 --- /dev/null +++ b/testcases/contenttype.http @@ -0,0 +1,11 @@ +POST / HTTP/1.1 +Host: handler.example.com +Content-Type: application/xml +Content-Length: 24 +CE-specversion: 0.3 +CE-id: 123 +CE-source: https://cloudevents.io/contenttype +CE-type: io.cloudevetns.contenttype-test +CE-datacontentencoding: Base64 + +PG11Y2ggd293PSJ4bWwiLz4= \ No newline at end of file diff --git a/testcases/contenttype.json b/testcases/contenttype.json new file mode 100644 index 000000000..4509d3b3a --- /dev/null +++ b/testcases/contenttype.json @@ -0,0 +1,12 @@ +{ + "specversion": "0.3", + "id": "123", + + "source": "https://cloudevents.io/contenttype", + "type": "io.cloudevents.contenttype-test", + + "datacontentencoding": "Base64", + "datacontenttype": "application/xml", + + "data": "PG11Y2ggd293PSJ4bWwiLz4=", // +} \ No newline at end of file diff --git a/testcases/contenttype.mqtt b/testcases/contenttype.mqtt new file mode 100644 index 000000000..76ad15cc4 --- /dev/null +++ b/testcases/contenttype.mqtt @@ -0,0 +1,12 @@ +------------------ PUBLISH --------------- +Topic Name: mytopic +Content Type: application/xml +--------------- User Properties ---------- +specversion: 0.3 +id: 123 +source: https://cloudevents.io/contenttype +type: io.cloudevents.contenttype-test +datacontentencoding: Base64 +------------------ payload --------------- +PG11Y2ggd293PSJ4bWwiLz4= +------------------------------------------ \ No newline at end of file diff --git a/testcases/extensions-map.http b/testcases/extensions-map.http new file mode 100644 index 000000000..adff9774c --- /dev/null +++ b/testcases/extensions-map.http @@ -0,0 +1,11 @@ +POST / HTTP/1.1 +Host: handler.example.com +Content-Length: 0 +CE-specversion: 0.3 +CE-id: 123 +CE-source: https://cloudevents.io/extensions-map +CE-type: io.cloudevents.extensions-map-test +CE-this0is0ok-\: ok +CE-this0is0ok-": {\"u005c": 17} +Content-Type: application/xml + diff --git a/testcases/extensions-map.json b/testcases/extensions-map.json new file mode 100644 index 000000000..089460f1d --- /dev/null +++ b/testcases/extensions-map.json @@ -0,0 +1,17 @@ +{ + "specversion": "0.3", + "id": "123", + + "source": "https://cloudevents.io/extensions-map", + "type": "io.cloudevents.extensions-map-test", + + /*** + * EXTENSIONS, with a map value + */ + "this0is0ok": { + "\\": "ok", + "\"": { + "\u005c": "17" + } + } +} \ No newline at end of file diff --git a/testcases/extensions-map.mqtt b/testcases/extensions-map.mqtt new file mode 100644 index 000000000..47e79e771 --- /dev/null +++ b/testcases/extensions-map.mqtt @@ -0,0 +1,11 @@ +------------------ PUBLISH --------------- +Topic Name: mytopic +Content Type: +--------------- User Properties ---------- +specversion: 0.3 +id: 123 +source: https://cloudevents.io/extensions-map +type: io.cloudevents.extensions-map-test +this0is0ok: {"\\":"ok","\"":{"\\": "17"}} +------------------ payload --------------- +------------------------------------------ \ No newline at end of file diff --git a/testcases/unicode-strings.http b/testcases/unicode-strings.http new file mode 100644 index 000000000..0266cd221 --- /dev/null +++ b/testcases/unicode-strings.http @@ -0,0 +1,9 @@ +POST / HTTP/1.1 +Host: handler.example.com +Content-Length: 0 +CE-specversion: 0.3 +CE-id: %22%F0%9F%98%89%03%3c.is%2BFine%E7%81%AB%22 +CE-source: https://cloudevents.io/unicode-strings +CE-type: %22%F0%9F%98%89%03%3c.is%2BFine%E7%81%AB%22 +CE-subject: %22%F0%9F%98%89%03%3c.is%2BFine%E7%81%AB%22 + diff --git a/testcases/unicode-strings.http-json b/testcases/unicode-strings.http-json new file mode 100644 index 000000000..462cb383a --- /dev/null +++ b/testcases/unicode-strings.http-json @@ -0,0 +1,22 @@ +POST / HTTP/1.1 +Host: handler.example.com +Content-Length: 517 +Content-Type: applications/cloudevents+json; charset=utf-8 + +{ + "specversion": "0.3", + "id": "\"😉\u033c.is+Fine火\u0022", // \u22\u1F609\u033c\u2e\u69\u73\u2b\u46\u69\u6e\u65\u706b\u22 + "source": "", // relative-ref -> relative-part -> path-empty + "type": "\"😉\u033c.is+Fine火\u0022", + "datacontentencoding": "Base64", + "datacontenttype": "application/xml", + "schemaurl": "%2f%2f%anonymous@example.com/a&b;?x'=%2f//#//", + "subject": "\"😉\u033c.is+Fine火\u0022", + "data": "PG11Y2ggd293PSJ4bWwiLz4=", + "this0is0ok": { + "\\": "ok", + "\"": { + "\u005c": "good,too" + } + } +} \ No newline at end of file diff --git a/testcases/unicode-strings.json b/testcases/unicode-strings.json new file mode 100644 index 000000000..fb71d6bce --- /dev/null +++ b/testcases/unicode-strings.json @@ -0,0 +1,16 @@ +{ + "specversion": "0.3", + // "Printable" might or might not include " ", but probably includes + // characters that produce at least some visible output + // Go defines this as: + // > Such characters include letters, marks, numbers, punctuation, symbols, + // > and spaces, from categories L, M, N, P, S, Zs. + // https://golang.org/pkg/unicode/#IsGraphic + "id": "\"😉\u033c.is+Fine火\u0022", // \u22\u1F609\u033c\u2e\u69\u73\u2b\u46\u69\u6e\u65\u706b\u22 + + "source": "https://cloudevents.io/unicode-strings" + "type": "\"😉\u033c.is+Fine火\u0022", + + // OPTIONAL field + "subject": "\"😉\u033c.is+Fine火\u0022", +} \ No newline at end of file diff --git a/testcases/unicode-strings.mqtt b/testcases/unicode-strings.mqtt new file mode 100644 index 000000000..20793a429 --- /dev/null +++ b/testcases/unicode-strings.mqtt @@ -0,0 +1,11 @@ +------------------ PUBLISH --------------- +Topic Name: mytopic +Content Type: +--------------- User Properties ---------- +specversion: 0.3 +id: "😉̼.is+Fine火" +source: https://cloudevents.io/unicode-strings +type: "😉̼.is+Fine火" +subject: "😉̼.is+Fine火" +------------------ payload --------------- +------------------------------------------ \ No newline at end of file diff --git a/testcases/urls.http b/testcases/urls.http new file mode 100644 index 000000000..c240ddb99 --- /dev/null +++ b/testcases/urls.http @@ -0,0 +1,9 @@ +POST / HTTP/1.1 +Host: handler.example.com +Content-Length: 0 +CE-specversion: 0.3 +CE-id: 123 +CE-source: +CE-type: io.cloudevetns.url-test +CE-schemaurl: %2f%2f%anonymous@example.com/a&b;?x'=%2f//#// + diff --git a/testcases/urls.json b/testcases/urls.json new file mode 100644 index 000000000..cd1af5fb7 --- /dev/null +++ b/testcases/urls.json @@ -0,0 +1,16 @@ +{ + "specversion": "0.3", + + "id": "123", + + // Source is a URI-reference, https://tools.ietf.org/html/rfc3986#appendix-A + "source": "", // relative-ref -> relative-part -> path-empty + "type": "io.cloudevents.url-test", + + // URI-reference: https://tools.ietf.org/html/rfc3986#appendix-A + // Verify that % decoding is done properly. This is a 'path-noscheme' + // that percent-decodes to a '"//" authority path-abempty'. + "schemaurl": "%2f%2f%anonymous@example.com/a&b;?x'=%2f//#//", + + "data": "", +} \ No newline at end of file From bd0bf974e7ceebbb44889aedc4b356558317ddf5 Mon Sep 17 00:00:00 2001 From: Evan Anderson Date: Mon, 17 Jun 2019 15:42:18 -0700 Subject: [PATCH 07/15] Run prettier.io printWidth=80 proseWrap=always Signed-off-by: Evan Anderson --- testcases/README.md | 39 ++++++++++++++++++++++++--------------- 1 file changed, 24 insertions(+), 15 deletions(-) diff --git a/testcases/README.md b/testcases/README.md index cba431a02..83ae6fd1b 100644 --- a/testcases/README.md +++ b/testcases/README.md @@ -1,17 +1,23 @@ # Test cases for CloudEvents encoding -These cases provide a set of "difficult" or edge-case encodings of valid CloudEvents, for use in testing various CloudEvents implementations. The cases cover transformation between a [canonical JSON object](../json-format.md) and a transport-specific output. Test cases are organized by common prefix with the following suffixes denoting different transports: - -Suffix | Encoding ---- | --- -`json` | [JSON event](../json-format.md) -`http` | [HTTP binary request](../http-transport-binding.md) -`http-json` | [HTTP structured request](../http-transport-binding.md) -`mqtt` | [MQTT binary publish](../mqtt-transport-binding.md) -`mqtt-json` | [MQTT structured publish](../mqtt-transport-binding.md) -`amqp` | [AMQP message](../amqp-transport-binding.md) - -If multiple files exist with the same input prefix, they all represent the same CloudEvent rendered across the different transports. For example, given the files: +These cases provide a set of "difficult" or edge-case encodings of valid +CloudEvents, for use in testing various CloudEvents implementations. The cases +cover transformation between a [canonical JSON object](../json-format.md) and a +transport-specific output. Test cases are organized by common prefix with the +following suffixes denoting different transports: + +| Suffix | Encoding | +| ----------- | ------------------------------------------------------- | +| `json` | [JSON event](../json-format.md) | +| `http` | [HTTP binary request](../http-transport-binding.md) | +| `http-json` | [HTTP structured request](../http-transport-binding.md) | +| `mqtt` | [MQTT binary publish](../mqtt-transport-binding.md) | +| `mqtt-json` | [MQTT structured publish](../mqtt-transport-binding.md) | +| `amqp` | [AMQP message](../amqp-transport-binding.md) | + +If multiple files exist with the same input prefix, they all represent the same +CloudEvent rendered across the different transports. For example, given the +files: - `unicode-input.json` - `unicode-input.http` @@ -19,13 +25,16 @@ If multiple files exist with the same input prefix, they all represent the same - `binary-date.json` - `binary-date.amqp` -These form two sets of tests: the `unicode-input` case is defined for JSON, HTTP, and MQTT, and the `binary-date` case is defined for QSON and AMQP. +These form two sets of tests: the `unicode-input` case is defined for JSON, +HTTP, and MQTT, and the `binary-date` case is defined for QSON and AMQP. -Test cases which describe particularly unexpected formats should include comments in the JSON document using Javascript comment format (`//` or `/* .. */`). +Test cases which describe particularly unexpected formats should include +comments in the JSON document using Javascript comment format (`//` or +`/* .. */`). \ No newline at end of file +--> From 900a2a5b3d921e56eae967b59cfa726fe3e4d796 Mon Sep 17 00:00:00 2001 From: Evan Anderson Date: Mon, 17 Jun 2019 15:58:59 -0700 Subject: [PATCH 08/15] Resolve duglin@ comments. Signed-off-by: Evan Anderson --- testcases/contenttype.http | 10 +++++----- testcases/extensions-map.http | 12 ++++++------ testcases/unicode-strings.http | 10 +++++----- testcases/urls.http | 10 +++++----- 4 files changed, 21 insertions(+), 21 deletions(-) diff --git a/testcases/contenttype.http b/testcases/contenttype.http index e4e23fc46..05873e013 100644 --- a/testcases/contenttype.http +++ b/testcases/contenttype.http @@ -2,10 +2,10 @@ POST / HTTP/1.1 Host: handler.example.com Content-Type: application/xml Content-Length: 24 -CE-specversion: 0.3 -CE-id: 123 -CE-source: https://cloudevents.io/contenttype -CE-type: io.cloudevetns.contenttype-test -CE-datacontentencoding: Base64 +ce-specversion: 0.3 +ce-id: 123 +ce-source: https://cloudevents.io/contenttype +ce-type: io.cloudevents.contenttype-test +ce-datacontentencoding: Base64 PG11Y2ggd293PSJ4bWwiLz4= \ No newline at end of file diff --git a/testcases/extensions-map.http b/testcases/extensions-map.http index adff9774c..f7d321efe 100644 --- a/testcases/extensions-map.http +++ b/testcases/extensions-map.http @@ -1,11 +1,11 @@ POST / HTTP/1.1 Host: handler.example.com Content-Length: 0 -CE-specversion: 0.3 -CE-id: 123 -CE-source: https://cloudevents.io/extensions-map -CE-type: io.cloudevents.extensions-map-test -CE-this0is0ok-\: ok -CE-this0is0ok-": {\"u005c": 17} +ce-specversion: 0.3 +ce-id: 123 +ce-source: https://cloudevents.io/extensions-map +ce-type: io.cloudevents.extensions-map-test +ce-this0is0ok-\: ok +ce-this0is0ok-": {\"u005c": 17} Content-Type: application/xml diff --git a/testcases/unicode-strings.http b/testcases/unicode-strings.http index 0266cd221..52edc177c 100644 --- a/testcases/unicode-strings.http +++ b/testcases/unicode-strings.http @@ -1,9 +1,9 @@ POST / HTTP/1.1 Host: handler.example.com Content-Length: 0 -CE-specversion: 0.3 -CE-id: %22%F0%9F%98%89%03%3c.is%2BFine%E7%81%AB%22 -CE-source: https://cloudevents.io/unicode-strings -CE-type: %22%F0%9F%98%89%03%3c.is%2BFine%E7%81%AB%22 -CE-subject: %22%F0%9F%98%89%03%3c.is%2BFine%E7%81%AB%22 +ce-specversion: 0.3 +ce-id: %22%F0%9F%98%89%03%3c.is%2BFine%E7%81%AB%22 +ce-source: https://cloudevents.io/unicode-strings +ce-type: %22%F0%9F%98%89%03%3c.is%2BFine%E7%81%AB%22 +ce-subject: %22%F0%9F%98%89%03%3c.is%2BFine%E7%81%AB%22 diff --git a/testcases/urls.http b/testcases/urls.http index c240ddb99..844df5eb9 100644 --- a/testcases/urls.http +++ b/testcases/urls.http @@ -1,9 +1,9 @@ POST / HTTP/1.1 Host: handler.example.com Content-Length: 0 -CE-specversion: 0.3 -CE-id: 123 -CE-source: -CE-type: io.cloudevetns.url-test -CE-schemaurl: %2f%2f%anonymous@example.com/a&b;?x'=%2f//#// +ce-specversion: 0.3 +ce-id: 123 +ce-source: +ce-type: io.cloudevetns.url-test +ce-schemaurl: %2f%2f%anonymous@example.com/a&b;?x'=%2f//#// From b13ca64a36a2fbc1ad70e3fc0d47224a1c8ec5b8 Mon Sep 17 00:00:00 2001 From: Evan Anderson Date: Mon, 17 Jun 2019 16:01:54 -0700 Subject: [PATCH 09/15] Make one map key "", which is allowed by RFC. Signed-off-by: Evan Anderson --- testcases/extensions-map.http | 4 ++-- testcases/extensions-map.json | 5 +++-- testcases/extensions-map.mqtt | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/testcases/extensions-map.http b/testcases/extensions-map.http index f7d321efe..a851fe610 100644 --- a/testcases/extensions-map.http +++ b/testcases/extensions-map.http @@ -5,7 +5,7 @@ ce-specversion: 0.3 ce-id: 123 ce-source: https://cloudevents.io/extensions-map ce-type: io.cloudevents.extensions-map-test -ce-this0is0ok-\: ok -ce-this0is0ok-": {\"u005c": 17} +ce-this0is0ok-": ok +ce-this0is0ok-: {\"u005c": 17} Content-Type: application/xml diff --git a/testcases/extensions-map.json b/testcases/extensions-map.json index 089460f1d..1ada7713e 100644 --- a/testcases/extensions-map.json +++ b/testcases/extensions-map.json @@ -9,8 +9,9 @@ * EXTENSIONS, with a map value */ "this0is0ok": { - "\\": "ok", - "\"": { + "\": "ok", + // Empty string **is** allowed by RFC7159. + "": { "\u005c": "17" } } diff --git a/testcases/extensions-map.mqtt b/testcases/extensions-map.mqtt index 47e79e771..ac9c86093 100644 --- a/testcases/extensions-map.mqtt +++ b/testcases/extensions-map.mqtt @@ -6,6 +6,6 @@ specversion: 0.3 id: 123 source: https://cloudevents.io/extensions-map type: io.cloudevents.extensions-map-test -this0is0ok: {"\\":"ok","\"":{"\\": "17"}} +this0is0ok: {"\"":"ok","":{"\\": "17"}} ------------------ payload --------------- ------------------------------------------ \ No newline at end of file From cc5a3684db6322b2cb29495305e01bcc4577ec42 Mon Sep 17 00:00:00 2001 From: Evan Anderson Date: Mon, 17 Jun 2019 16:05:27 -0700 Subject: [PATCH 10/15] Further cleanup thanks to duglin@'s eagle eye. Signed-off-by: Evan Anderson --- testcases/extensions-map.http | 1 - testcases/unicode-strings.http-json | 14 ++------------ testcases/unicode-strings.json | 2 +- testcases/urls.json | 2 -- 4 files changed, 3 insertions(+), 16 deletions(-) diff --git a/testcases/extensions-map.http b/testcases/extensions-map.http index a851fe610..2c846d7fd 100644 --- a/testcases/extensions-map.http +++ b/testcases/extensions-map.http @@ -7,5 +7,4 @@ ce-source: https://cloudevents.io/extensions-map ce-type: io.cloudevents.extensions-map-test ce-this0is0ok-": ok ce-this0is0ok-: {\"u005c": 17} -Content-Type: application/xml diff --git a/testcases/unicode-strings.http-json b/testcases/unicode-strings.http-json index 462cb383a..b6fd7ed2d 100644 --- a/testcases/unicode-strings.http-json +++ b/testcases/unicode-strings.http-json @@ -1,22 +1,12 @@ POST / HTTP/1.1 Host: handler.example.com -Content-Length: 517 +Content-Length: 279 Content-Type: applications/cloudevents+json; charset=utf-8 { "specversion": "0.3", "id": "\"😉\u033c.is+Fine火\u0022", // \u22\u1F609\u033c\u2e\u69\u73\u2b\u46\u69\u6e\u65\u706b\u22 - "source": "", // relative-ref -> relative-part -> path-empty + "source": "https://cloudevents.io/unicode-strings", "type": "\"😉\u033c.is+Fine火\u0022", - "datacontentencoding": "Base64", - "datacontenttype": "application/xml", - "schemaurl": "%2f%2f%anonymous@example.com/a&b;?x'=%2f//#//", "subject": "\"😉\u033c.is+Fine火\u0022", - "data": "PG11Y2ggd293PSJ4bWwiLz4=", - "this0is0ok": { - "\\": "ok", - "\"": { - "\u005c": "good,too" - } - } } \ No newline at end of file diff --git a/testcases/unicode-strings.json b/testcases/unicode-strings.json index fb71d6bce..3c68785a7 100644 --- a/testcases/unicode-strings.json +++ b/testcases/unicode-strings.json @@ -12,5 +12,5 @@ "type": "\"😉\u033c.is+Fine火\u0022", // OPTIONAL field - "subject": "\"😉\u033c.is+Fine火\u0022", + "subject": "\"😉\u033c.is+Fine火\u0022" } \ No newline at end of file diff --git a/testcases/urls.json b/testcases/urls.json index cd1af5fb7..3bf426790 100644 --- a/testcases/urls.json +++ b/testcases/urls.json @@ -11,6 +11,4 @@ // Verify that % decoding is done properly. This is a 'path-noscheme' // that percent-decodes to a '"//" authority path-abempty'. "schemaurl": "%2f%2f%anonymous@example.com/a&b;?x'=%2f//#//", - - "data": "", } \ No newline at end of file From 234510c3e9f4e9bd3249e20975cf8e906b7ba401 Mon Sep 17 00:00:00 2001 From: Evan Anderson Date: Tue, 2 Jul 2019 16:26:32 -0700 Subject: [PATCH 11/15] Update to 0.4-wip `specversion` Signed-off-by: Evan Anderson --- testcases/contenttype.http | 2 +- testcases/contenttype.json | 2 +- testcases/contenttype.mqtt | 2 +- testcases/extensions-map.http | 2 +- testcases/extensions-map.json | 2 +- testcases/extensions-map.mqtt | 2 +- testcases/unicode-strings.http | 2 +- testcases/unicode-strings.http-json | 2 +- testcases/unicode-strings.json | 4 ++-- testcases/unicode-strings.mqtt | 2 +- testcases/urls.http | 2 +- testcases/urls.json | 2 +- 12 files changed, 13 insertions(+), 13 deletions(-) diff --git a/testcases/contenttype.http b/testcases/contenttype.http index 05873e013..0bfc71fb5 100644 --- a/testcases/contenttype.http +++ b/testcases/contenttype.http @@ -2,7 +2,7 @@ POST / HTTP/1.1 Host: handler.example.com Content-Type: application/xml Content-Length: 24 -ce-specversion: 0.3 +ce-specversion: 0.4-wip ce-id: 123 ce-source: https://cloudevents.io/contenttype ce-type: io.cloudevents.contenttype-test diff --git a/testcases/contenttype.json b/testcases/contenttype.json index 4509d3b3a..b4111507e 100644 --- a/testcases/contenttype.json +++ b/testcases/contenttype.json @@ -1,5 +1,5 @@ { - "specversion": "0.3", + "specversion": "0.4-wip", "id": "123", "source": "https://cloudevents.io/contenttype", diff --git a/testcases/contenttype.mqtt b/testcases/contenttype.mqtt index 76ad15cc4..57431a5f7 100644 --- a/testcases/contenttype.mqtt +++ b/testcases/contenttype.mqtt @@ -2,7 +2,7 @@ Topic Name: mytopic Content Type: application/xml --------------- User Properties ---------- -specversion: 0.3 +specversion: 0.4-wip id: 123 source: https://cloudevents.io/contenttype type: io.cloudevents.contenttype-test diff --git a/testcases/extensions-map.http b/testcases/extensions-map.http index 2c846d7fd..5804d1a50 100644 --- a/testcases/extensions-map.http +++ b/testcases/extensions-map.http @@ -1,7 +1,7 @@ POST / HTTP/1.1 Host: handler.example.com Content-Length: 0 -ce-specversion: 0.3 +ce-specversion: 0.4-wip ce-id: 123 ce-source: https://cloudevents.io/extensions-map ce-type: io.cloudevents.extensions-map-test diff --git a/testcases/extensions-map.json b/testcases/extensions-map.json index 1ada7713e..45714615b 100644 --- a/testcases/extensions-map.json +++ b/testcases/extensions-map.json @@ -1,5 +1,5 @@ { - "specversion": "0.3", + "specversion": "0.4-wip", "id": "123", "source": "https://cloudevents.io/extensions-map", diff --git a/testcases/extensions-map.mqtt b/testcases/extensions-map.mqtt index ac9c86093..a98a96692 100644 --- a/testcases/extensions-map.mqtt +++ b/testcases/extensions-map.mqtt @@ -2,7 +2,7 @@ Topic Name: mytopic Content Type: --------------- User Properties ---------- -specversion: 0.3 +specversion: 0.4-wip id: 123 source: https://cloudevents.io/extensions-map type: io.cloudevents.extensions-map-test diff --git a/testcases/unicode-strings.http b/testcases/unicode-strings.http index 52edc177c..28bc345f8 100644 --- a/testcases/unicode-strings.http +++ b/testcases/unicode-strings.http @@ -1,7 +1,7 @@ POST / HTTP/1.1 Host: handler.example.com Content-Length: 0 -ce-specversion: 0.3 +ce-specversion: 0.4-wip ce-id: %22%F0%9F%98%89%03%3c.is%2BFine%E7%81%AB%22 ce-source: https://cloudevents.io/unicode-strings ce-type: %22%F0%9F%98%89%03%3c.is%2BFine%E7%81%AB%22 diff --git a/testcases/unicode-strings.http-json b/testcases/unicode-strings.http-json index b6fd7ed2d..576e6756c 100644 --- a/testcases/unicode-strings.http-json +++ b/testcases/unicode-strings.http-json @@ -4,7 +4,7 @@ Content-Length: 279 Content-Type: applications/cloudevents+json; charset=utf-8 { - "specversion": "0.3", + "specversion": "0.4-wip", "id": "\"😉\u033c.is+Fine火\u0022", // \u22\u1F609\u033c\u2e\u69\u73\u2b\u46\u69\u6e\u65\u706b\u22 "source": "https://cloudevents.io/unicode-strings", "type": "\"😉\u033c.is+Fine火\u0022", diff --git a/testcases/unicode-strings.json b/testcases/unicode-strings.json index 3c68785a7..5d06fda7c 100644 --- a/testcases/unicode-strings.json +++ b/testcases/unicode-strings.json @@ -1,5 +1,5 @@ { - "specversion": "0.3", + "specversion": "0.4-wip", // "Printable" might or might not include " ", but probably includes // characters that produce at least some visible output // Go defines this as: @@ -12,5 +12,5 @@ "type": "\"😉\u033c.is+Fine火\u0022", // OPTIONAL field - "subject": "\"😉\u033c.is+Fine火\u0022" + "subject": "\"😉\u0.4-wipc.is+Fine火\u0022" } \ No newline at end of file diff --git a/testcases/unicode-strings.mqtt b/testcases/unicode-strings.mqtt index 20793a429..195efae8d 100644 --- a/testcases/unicode-strings.mqtt +++ b/testcases/unicode-strings.mqtt @@ -2,7 +2,7 @@ Topic Name: mytopic Content Type: --------------- User Properties ---------- -specversion: 0.3 +specversion: 0.4-wip id: "😉̼.is+Fine火" source: https://cloudevents.io/unicode-strings type: "😉̼.is+Fine火" diff --git a/testcases/urls.http b/testcases/urls.http index 844df5eb9..fd6f429cc 100644 --- a/testcases/urls.http +++ b/testcases/urls.http @@ -1,7 +1,7 @@ POST / HTTP/1.1 Host: handler.example.com Content-Length: 0 -ce-specversion: 0.3 +ce-specversion: 0.4-wip ce-id: 123 ce-source: ce-type: io.cloudevetns.url-test diff --git a/testcases/urls.json b/testcases/urls.json index 3bf426790..dd2d896ee 100644 --- a/testcases/urls.json +++ b/testcases/urls.json @@ -1,5 +1,5 @@ { - "specversion": "0.3", + "specversion": "0.4-wip", "id": "123", From ef0712a8c0e1522d2df42957602bd2cec0a6de5c Mon Sep 17 00:00:00 2001 From: Evan Anderson Date: Tue, 13 Aug 2019 11:14:54 -0700 Subject: [PATCH 12/15] Remove map after #467. Clean up JSON a little per @duglin review. Signed-off-by: Evan Anderson --- testcases/contenttype.json | 2 +- testcases/extensions-map.http | 10 ---------- testcases/extensions-map.json | 18 ------------------ testcases/extensions-map.mqtt | 11 ----------- testcases/unicode-strings.http-json | 2 +- testcases/urls.json | 6 +++--- 6 files changed, 5 insertions(+), 44 deletions(-) delete mode 100644 testcases/extensions-map.http delete mode 100644 testcases/extensions-map.json delete mode 100644 testcases/extensions-map.mqtt diff --git a/testcases/contenttype.json b/testcases/contenttype.json index b4111507e..44f4b2aa8 100644 --- a/testcases/contenttype.json +++ b/testcases/contenttype.json @@ -8,5 +8,5 @@ "datacontentencoding": "Base64", "datacontenttype": "application/xml", - "data": "PG11Y2ggd293PSJ4bWwiLz4=", // + "data": "PG11Y2ggd293PSJ4bWwiLz4=" // } \ No newline at end of file diff --git a/testcases/extensions-map.http b/testcases/extensions-map.http deleted file mode 100644 index 5804d1a50..000000000 --- a/testcases/extensions-map.http +++ /dev/null @@ -1,10 +0,0 @@ -POST / HTTP/1.1 -Host: handler.example.com -Content-Length: 0 -ce-specversion: 0.4-wip -ce-id: 123 -ce-source: https://cloudevents.io/extensions-map -ce-type: io.cloudevents.extensions-map-test -ce-this0is0ok-": ok -ce-this0is0ok-: {\"u005c": 17} - diff --git a/testcases/extensions-map.json b/testcases/extensions-map.json deleted file mode 100644 index 45714615b..000000000 --- a/testcases/extensions-map.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "specversion": "0.4-wip", - "id": "123", - - "source": "https://cloudevents.io/extensions-map", - "type": "io.cloudevents.extensions-map-test", - - /*** - * EXTENSIONS, with a map value - */ - "this0is0ok": { - "\": "ok", - // Empty string **is** allowed by RFC7159. - "": { - "\u005c": "17" - } - } -} \ No newline at end of file diff --git a/testcases/extensions-map.mqtt b/testcases/extensions-map.mqtt deleted file mode 100644 index a98a96692..000000000 --- a/testcases/extensions-map.mqtt +++ /dev/null @@ -1,11 +0,0 @@ ------------------- PUBLISH --------------- -Topic Name: mytopic -Content Type: ---------------- User Properties ---------- -specversion: 0.4-wip -id: 123 -source: https://cloudevents.io/extensions-map -type: io.cloudevents.extensions-map-test -this0is0ok: {"\"":"ok","":{"\\": "17"}} ------------------- payload --------------- ------------------------------------------- \ No newline at end of file diff --git a/testcases/unicode-strings.http-json b/testcases/unicode-strings.http-json index 576e6756c..07173124b 100644 --- a/testcases/unicode-strings.http-json +++ b/testcases/unicode-strings.http-json @@ -8,5 +8,5 @@ Content-Type: applications/cloudevents+json; charset=utf-8 "id": "\"😉\u033c.is+Fine火\u0022", // \u22\u1F609\u033c\u2e\u69\u73\u2b\u46\u69\u6e\u65\u706b\u22 "source": "https://cloudevents.io/unicode-strings", "type": "\"😉\u033c.is+Fine火\u0022", - "subject": "\"😉\u033c.is+Fine火\u0022", + "subject": "\"😉\u033c.is+Fine火\u0022" } \ No newline at end of file diff --git a/testcases/urls.json b/testcases/urls.json index dd2d896ee..f9e4a29c8 100644 --- a/testcases/urls.json +++ b/testcases/urls.json @@ -8,7 +8,7 @@ "type": "io.cloudevents.url-test", // URI-reference: https://tools.ietf.org/html/rfc3986#appendix-A - // Verify that % decoding is done properly. This is a 'path-noscheme' - // that percent-decodes to a '"//" authority path-abempty'. - "schemaurl": "%2f%2f%anonymous@example.com/a&b;?x'=%2f//#//", + // Verify that % decoding not performed. This is a 'path-noscheme' + // which percent-decodes to a hier-part -> '"//" authority path-abempty'. + "schemaurl": "%2f%2f%anonymous@example.com/a&b;?x'=%2f//#//" } \ No newline at end of file From 85fbd92640792623cd1d4b9ad2ea00f604fea2d4 Mon Sep 17 00:00:00 2001 From: Evan Anderson Date: Tue, 13 Aug 2019 14:53:23 -0700 Subject: [PATCH 13/15] Update README.md to link to test cases. Signed-off-by: Evan Anderson --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index e37a1efc0..04d02f126 100644 --- a/README.md +++ b/README.md @@ -43,6 +43,7 @@ The following documents are available: | **Additional Documentation:** | | Primer | [v0.3](https://github.com/cloudevents/spec/blob/v0.3/primer.md) | [master](https://github.com/cloudevents/spec/blob/master/primer.md) | | Documented Extensions | - | [master](https://github.com/cloudevents/spec/blob/master/documented-extensions.md) | +| Edge cases for SDK testing | - | [master](https://github.com/cloudevents/spec/blob/master/testcases/README.md) | | Proprietary Specifications | - | [master](https://github.com/cloudevents/spec/blob/master/proprietary-specs.md) | If you are new to CloudEvents, it is recommended that you start by reading the From 9cd4c3a742832fbb5fed8561fc7c97bc31846e0a Mon Sep 17 00:00:00 2001 From: Evan Anderson Date: Wed, 21 Aug 2019 12:08:37 -0700 Subject: [PATCH 14/15] Update URLs for disallowed empty URLs, fix over unicode strings. Assume #488 escaping in URLs as well. Signed-off-by: Evan Anderson --- testcases/README.md | 2 +- testcases/unicode-strings.json | 2 +- testcases/urls.http | 4 ++-- testcases/urls.json | 10 ++++++---- 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/testcases/README.md b/testcases/README.md index 83ae6fd1b..7ed8fa1bb 100644 --- a/testcases/README.md +++ b/testcases/README.md @@ -26,7 +26,7 @@ files: - `binary-date.amqp` These form two sets of tests: the `unicode-input` case is defined for JSON, -HTTP, and MQTT, and the `binary-date` case is defined for QSON and AMQP. +HTTP, and MQTT, and the `binary-date` case is defined for JSON and AMQP. Test cases which describe particularly unexpected formats should include comments in the JSON document using Javascript comment format (`//` or diff --git a/testcases/unicode-strings.json b/testcases/unicode-strings.json index 5d06fda7c..3a8085bad 100644 --- a/testcases/unicode-strings.json +++ b/testcases/unicode-strings.json @@ -12,5 +12,5 @@ "type": "\"😉\u033c.is+Fine火\u0022", // OPTIONAL field - "subject": "\"😉\u0.4-wipc.is+Fine火\u0022" + "subject": "\"😉\u033c.is+Fine火\u0022" } \ No newline at end of file diff --git a/testcases/urls.http b/testcases/urls.http index fd6f429cc..ad6d4fd37 100644 --- a/testcases/urls.http +++ b/testcases/urls.http @@ -3,7 +3,7 @@ Host: handler.example.com Content-Length: 0 ce-specversion: 0.4-wip ce-id: 123 -ce-source: +ce-source: %2f ce-type: io.cloudevetns.url-test -ce-schemaurl: %2f%2f%anonymous@example.com/a&b;?x'=%2f//#// +ce-schemaurl: %252f%252fanonymous%40example.com%2fa&b%3b%3fx'%3d%252f%2f%2f#%2f%2f diff --git a/testcases/urls.json b/testcases/urls.json index f9e4a29c8..0b6cf0965 100644 --- a/testcases/urls.json +++ b/testcases/urls.json @@ -4,11 +4,13 @@ "id": "123", // Source is a URI-reference, https://tools.ietf.org/html/rfc3986#appendix-A - "source": "", // relative-ref -> relative-part -> path-empty + "source": "/", // relative-ref -> relative-part -> path-absolute "type": "io.cloudevents.url-test", // URI-reference: https://tools.ietf.org/html/rfc3986#appendix-A - // Verify that % decoding not performed. This is a 'path-noscheme' - // which percent-decodes to a hier-part -> '"//" authority path-abempty'. - "schemaurl": "%2f%2f%anonymous@example.com/a&b;?x'=%2f//#//" + // Verify that % decoding is performed correctly (no % decoding in + // JSON, HTTP headers should be decoded). This is a 'path-noscheme' + // which percent-decodes to a different valid URI: + // relative-ref -> relative-part -> '"//" authority path-abempty'. + "schemaurl": "%2f%2fanonymous@example.com/a&b;?x'=%2f//#//" } \ No newline at end of file From e85ccc28aed08d4623f650ddda73b86aa3fb6b65 Mon Sep 17 00:00:00 2001 From: Evan Anderson Date: Thu, 19 Sep 2019 04:28:35 -0700 Subject: [PATCH 15/15] Update cases based on most recent spec changes Signed-off-by: Evan Anderson --- testcases/contenttype.http | 3 +-- testcases/contenttype.json | 5 ++--- testcases/contenttype.mqtt | 3 +-- testcases/unicode-strings.http | 4 ++-- testcases/unicode-strings.http-json | 4 ++-- testcases/unicode-strings.json | 6 +++--- testcases/unicode-strings.mqtt | 10 +++++----- testcases/urls.http | 6 +++--- 8 files changed, 19 insertions(+), 22 deletions(-) diff --git a/testcases/contenttype.http b/testcases/contenttype.http index 0bfc71fb5..1e5df9558 100644 --- a/testcases/contenttype.http +++ b/testcases/contenttype.http @@ -6,6 +6,5 @@ ce-specversion: 0.4-wip ce-id: 123 ce-source: https://cloudevents.io/contenttype ce-type: io.cloudevents.contenttype-test -ce-datacontentencoding: Base64 -PG11Y2ggd293PSJ4bWwiLz4= \ No newline at end of file + \ No newline at end of file diff --git a/testcases/contenttype.json b/testcases/contenttype.json index 44f4b2aa8..af86c63e9 100644 --- a/testcases/contenttype.json +++ b/testcases/contenttype.json @@ -5,8 +5,7 @@ "source": "https://cloudevents.io/contenttype", "type": "io.cloudevents.contenttype-test", - "datacontentencoding": "Base64", "datacontenttype": "application/xml", - "data": "PG11Y2ggd293PSJ4bWwiLz4=" // -} \ No newline at end of file + "data_base64": "PG11Y2ggd293PSJ4bWwiLz4=" // +} diff --git a/testcases/contenttype.mqtt b/testcases/contenttype.mqtt index 57431a5f7..458329893 100644 --- a/testcases/contenttype.mqtt +++ b/testcases/contenttype.mqtt @@ -6,7 +6,6 @@ specversion: 0.4-wip id: 123 source: https://cloudevents.io/contenttype type: io.cloudevents.contenttype-test -datacontentencoding: Base64 ------------------ payload --------------- -PG11Y2ggd293PSJ4bWwiLz4= + ------------------------------------------ \ No newline at end of file diff --git a/testcases/unicode-strings.http b/testcases/unicode-strings.http index 28bc345f8..7f879a483 100644 --- a/testcases/unicode-strings.http +++ b/testcases/unicode-strings.http @@ -4,6 +4,6 @@ Content-Length: 0 ce-specversion: 0.4-wip ce-id: %22%F0%9F%98%89%03%3c.is%2BFine%E7%81%AB%22 ce-source: https://cloudevents.io/unicode-strings -ce-type: %22%F0%9F%98%89%03%3c.is%2BFine%E7%81%AB%22 -ce-subject: %22%F0%9F%98%89%03%3c.is%2BFine%E7%81%AB%22 +ce-type: " -.-. . " +ce-subject: " " diff --git a/testcases/unicode-strings.http-json b/testcases/unicode-strings.http-json index 07173124b..0710250d5 100644 --- a/testcases/unicode-strings.http-json +++ b/testcases/unicode-strings.http-json @@ -7,6 +7,6 @@ Content-Type: applications/cloudevents+json; charset=utf-8 "specversion": "0.4-wip", "id": "\"😉\u033c.is+Fine火\u0022", // \u22\u1F609\u033c\u2e\u69\u73\u2b\u46\u69\u6e\u65\u706b\u22 "source": "https://cloudevents.io/unicode-strings", - "type": "\"😉\u033c.is+Fine火\u0022", - "subject": "\"😉\u033c.is+Fine火\u0022" + "type": " -.-. . " + "subject": " " } \ No newline at end of file diff --git a/testcases/unicode-strings.json b/testcases/unicode-strings.json index 3a8085bad..e65414182 100644 --- a/testcases/unicode-strings.json +++ b/testcases/unicode-strings.json @@ -9,8 +9,8 @@ "id": "\"😉\u033c.is+Fine火\u0022", // \u22\u1F609\u033c\u2e\u69\u73\u2b\u46\u69\u6e\u65\u706b\u22 "source": "https://cloudevents.io/unicode-strings" - "type": "\"😉\u033c.is+Fine火\u0022", + "type": " -.-. . " // OPTIONAL field - "subject": "\"😉\u033c.is+Fine火\u0022" -} \ No newline at end of file + "subject": " " +} diff --git a/testcases/unicode-strings.mqtt b/testcases/unicode-strings.mqtt index 195efae8d..c3ee673b6 100644 --- a/testcases/unicode-strings.mqtt +++ b/testcases/unicode-strings.mqtt @@ -2,10 +2,10 @@ Topic Name: mytopic Content Type: --------------- User Properties ---------- -specversion: 0.4-wip -id: "😉̼.is+Fine火" -source: https://cloudevents.io/unicode-strings -type: "😉̼.is+Fine火" -subject: "😉̼.is+Fine火" +specversion:0.4-wip +id:"😉̼.is+Fine火" +source:https://cloudevents.io/unicode-strings +type: -.-. . +subject: ------------------ payload --------------- ------------------------------------------ \ No newline at end of file diff --git a/testcases/urls.http b/testcases/urls.http index ad6d4fd37..6b1cf961b 100644 --- a/testcases/urls.http +++ b/testcases/urls.http @@ -1,9 +1,9 @@ -POST / HTTP/1.1 +oPOST / HTTP/1.1 Host: handler.example.com Content-Length: 0 ce-specversion: 0.4-wip ce-id: 123 -ce-source: %2f +ce-source: / ce-type: io.cloudevetns.url-test -ce-schemaurl: %252f%252fanonymous%40example.com%2fa&b%3b%3fx'%3d%252f%2f%2f#%2f%2f +ce-schemaurl: %252f%252fanonymous%40example.com/a&b;?x'=%252f//#%//