test: use header constants in receiver tests (#131)
Signed-off-by: Daniel Bevenius <daniel.bevenius@gmail.com>
This commit is contained in:
parent
63ae1ad527
commit
60bf05c8f2
|
|
@ -2,6 +2,11 @@ const expect = require("chai").expect;
|
||||||
|
|
||||||
const HTTPBinaryReceiver =
|
const HTTPBinaryReceiver =
|
||||||
require("../../../lib/bindings/http/receiver_binary_0_3.js");
|
require("../../../lib/bindings/http/receiver_binary_0_3.js");
|
||||||
|
const {
|
||||||
|
BINARY_HEADERS_03,
|
||||||
|
SPEC_V03,
|
||||||
|
HEADER_CONTENT_TYPE
|
||||||
|
} = require("../../../lib/bindings/http/constants.js");
|
||||||
|
|
||||||
const receiver = new HTTPBinaryReceiver();
|
const receiver = new HTTPBinaryReceiver();
|
||||||
|
|
||||||
|
|
@ -41,10 +46,10 @@ describe("HTTP Transport Binding Binary Receiver for CloudEvents v0.3", () => {
|
||||||
// setup
|
// setup
|
||||||
const payload = {};
|
const payload = {};
|
||||||
const attributes = {
|
const attributes = {
|
||||||
"ce-specversion": "specversion",
|
[BINARY_HEADERS_03.SPEC_VERSION]: "specversion",
|
||||||
"ce-source": "source",
|
[BINARY_HEADERS_03.SOURCE]: "source",
|
||||||
"ce-id": "id",
|
[BINARY_HEADERS_03.ID]: "id",
|
||||||
"Content-Type": "application/json"
|
[HEADER_CONTENT_TYPE]: "application/json"
|
||||||
};
|
};
|
||||||
|
|
||||||
// act and assert
|
// act and assert
|
||||||
|
|
@ -56,10 +61,10 @@ describe("HTTP Transport Binding Binary Receiver for CloudEvents v0.3", () => {
|
||||||
// setup
|
// setup
|
||||||
const payload = {};
|
const payload = {};
|
||||||
const attributes = {
|
const attributes = {
|
||||||
"ce-type": "type",
|
[BINARY_HEADERS_03.TYPE]: "type",
|
||||||
"ce-source": "source",
|
[BINARY_HEADERS_03.SOURCE]: "source",
|
||||||
"ce-id": "id",
|
[BINARY_HEADERS_03.ID]: "id",
|
||||||
"Content-Type": "application/json"
|
[HEADER_CONTENT_TYPE]: "application/json"
|
||||||
};
|
};
|
||||||
|
|
||||||
// act and assert
|
// act and assert
|
||||||
|
|
@ -71,10 +76,10 @@ describe("HTTP Transport Binding Binary Receiver for CloudEvents v0.3", () => {
|
||||||
// setup
|
// setup
|
||||||
const payload = {};
|
const payload = {};
|
||||||
const attributes = {
|
const attributes = {
|
||||||
"ce-type": "type",
|
[BINARY_HEADERS_03.TYPE]: "type",
|
||||||
"ce-specversion": "specversion",
|
[BINARY_HEADERS_03.SPEC_VERSION]: "specversion",
|
||||||
"ce-id": "id",
|
[BINARY_HEADERS_03.ID]: "id",
|
||||||
"Content-Type": "application/json"
|
[HEADER_CONTENT_TYPE]: "application/json"
|
||||||
};
|
};
|
||||||
|
|
||||||
// act and assert
|
// act and assert
|
||||||
|
|
@ -86,10 +91,10 @@ describe("HTTP Transport Binding Binary Receiver for CloudEvents v0.3", () => {
|
||||||
// setup
|
// setup
|
||||||
const payload = {};
|
const payload = {};
|
||||||
const attributes = {
|
const attributes = {
|
||||||
"ce-type": "type",
|
[BINARY_HEADERS_03.TYPE]: "type",
|
||||||
"ce-specversion": "specversion",
|
[BINARY_HEADERS_03.SPEC_VERSION]: "specversion",
|
||||||
"ce-source": "source",
|
[BINARY_HEADERS_03.SOURCE]: "source",
|
||||||
"Content-Type": "application/json"
|
[HEADER_CONTENT_TYPE]: "application/json"
|
||||||
};
|
};
|
||||||
|
|
||||||
// act and assert
|
// act and assert
|
||||||
|
|
@ -101,11 +106,11 @@ describe("HTTP Transport Binding Binary Receiver for CloudEvents v0.3", () => {
|
||||||
// setup
|
// setup
|
||||||
const payload = {};
|
const payload = {};
|
||||||
const attributes = {
|
const attributes = {
|
||||||
"ce-type": "type",
|
[BINARY_HEADERS_03.TYPE]: "type",
|
||||||
"ce-specversion": "0.2",
|
[BINARY_HEADERS_03.SPEC_VERSION]: "0.2",
|
||||||
"ce-source": "source",
|
[BINARY_HEADERS_03.SOURCE]: "source",
|
||||||
"ce-id": "id",
|
[BINARY_HEADERS_03.ID]: "id",
|
||||||
"Content-Type": "application/json"
|
[HEADER_CONTENT_TYPE]: "application/json"
|
||||||
};
|
};
|
||||||
|
|
||||||
// act and assert
|
// act and assert
|
||||||
|
|
@ -117,11 +122,11 @@ describe("HTTP Transport Binding Binary Receiver for CloudEvents v0.3", () => {
|
||||||
// setup
|
// setup
|
||||||
const payload = {};
|
const payload = {};
|
||||||
const attributes = {
|
const attributes = {
|
||||||
"ce-type": "type",
|
[BINARY_HEADERS_03.TYPE]: "type",
|
||||||
"ce-specversion": "specversion",
|
[BINARY_HEADERS_03.SPEC_VERSION]: "specversion",
|
||||||
"ce-source": "source",
|
[BINARY_HEADERS_03.SOURCE]: "source",
|
||||||
"ce-id": "id",
|
[BINARY_HEADERS_03.ID]: "id",
|
||||||
"Content-Type": "text/html"
|
[HEADER_CONTENT_TYPE]: "text/html"
|
||||||
};
|
};
|
||||||
|
|
||||||
// act and assert
|
// act and assert
|
||||||
|
|
@ -133,11 +138,11 @@ describe("HTTP Transport Binding Binary Receiver for CloudEvents v0.3", () => {
|
||||||
// setup
|
// setup
|
||||||
const payload = {};
|
const payload = {};
|
||||||
const attributes = {
|
const attributes = {
|
||||||
"ce-type": "type",
|
[BINARY_HEADERS_03.TYPE]: "type",
|
||||||
"ce-specversion": "0.3",
|
[BINARY_HEADERS_03.SPEC_VERSION]: SPEC_V03,
|
||||||
"ce-source": "source",
|
[BINARY_HEADERS_03.SOURCE]: "source",
|
||||||
"ce-id": "id",
|
[BINARY_HEADERS_03.ID]: "id",
|
||||||
"Content-Type": "application/json"
|
[HEADER_CONTENT_TYPE]: "application/json"
|
||||||
};
|
};
|
||||||
|
|
||||||
// act and assert
|
// act and assert
|
||||||
|
|
@ -148,10 +153,10 @@ describe("HTTP Transport Binding Binary Receiver for CloudEvents v0.3", () => {
|
||||||
it("No error when content-type is unspecified", () => {
|
it("No error when content-type is unspecified", () => {
|
||||||
const payload = {};
|
const payload = {};
|
||||||
const attributes = {
|
const attributes = {
|
||||||
"ce-type": "type",
|
[BINARY_HEADERS_03.TYPE]: "type",
|
||||||
"ce-specversion": "0.3",
|
[BINARY_HEADERS_03.SPEC_VERSION]: SPEC_V03,
|
||||||
"ce-source": "source",
|
[BINARY_HEADERS_03.SOURCE]: "source",
|
||||||
"ce-id": "id"
|
[BINARY_HEADERS_03.ID]: "id"
|
||||||
};
|
};
|
||||||
|
|
||||||
// act and assert
|
// act and assert
|
||||||
|
|
@ -167,13 +172,13 @@ describe("HTTP Transport Binding Binary Receiver for CloudEvents v0.3", () => {
|
||||||
data: "dataString"
|
data: "dataString"
|
||||||
};
|
};
|
||||||
const attributes = {
|
const attributes = {
|
||||||
"ce-type": "type",
|
[BINARY_HEADERS_03.TYPE]: "type",
|
||||||
"ce-specversion": "0.3",
|
[BINARY_HEADERS_03.SPEC_VERSION]: SPEC_V03,
|
||||||
"ce-source": "source",
|
[BINARY_HEADERS_03.SOURCE]: "source",
|
||||||
"ce-id": "id",
|
[BINARY_HEADERS_03.ID]: "id",
|
||||||
"ce-time": "2019-06-16T11:42:00Z",
|
[BINARY_HEADERS_03.TIME]: "2019-06-16T11:42:00Z",
|
||||||
"ce-schemaurl": "http://schema.registry/v1",
|
[BINARY_HEADERS_03.SCHEMA_URL]: "http://schema.registry/v1",
|
||||||
"Content-Type": "application/json"
|
[HEADER_CONTENT_TYPE]: "application/json"
|
||||||
};
|
};
|
||||||
|
|
||||||
// act
|
// act
|
||||||
|
|
@ -190,13 +195,13 @@ describe("HTTP Transport Binding Binary Receiver for CloudEvents v0.3", () => {
|
||||||
data: "dataString"
|
data: "dataString"
|
||||||
};
|
};
|
||||||
const attributes = {
|
const attributes = {
|
||||||
"ce-type": "type",
|
[BINARY_HEADERS_03.TYPE]: "type",
|
||||||
"ce-specversion": "0.3",
|
[BINARY_HEADERS_03.SPEC_VERSION]: SPEC_V03,
|
||||||
"ce-source": "source",
|
[BINARY_HEADERS_03.SOURCE]: "source",
|
||||||
"ce-id": "id",
|
[BINARY_HEADERS_03.ID]: "id",
|
||||||
"ce-time": "2019-06-16T11:42:00Z",
|
[BINARY_HEADERS_03.TIME]: "2019-06-16T11:42:00Z",
|
||||||
"ce-schemaurl": "http://schema.registry/v1",
|
[BINARY_HEADERS_03.SCHEMA_URL]: "http://schema.registry/v1",
|
||||||
"Content-Type": "application/json"
|
[HEADER_CONTENT_TYPE]: "application/json"
|
||||||
};
|
};
|
||||||
|
|
||||||
// act
|
// act
|
||||||
|
|
@ -204,7 +209,7 @@ describe("HTTP Transport Binding Binary Receiver for CloudEvents v0.3", () => {
|
||||||
|
|
||||||
// assert
|
// assert
|
||||||
expect(actual.getSpecversion())
|
expect(actual.getSpecversion())
|
||||||
.to.equal("0.3");
|
.to.equal(SPEC_V03);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("CloudEvent contains 'source'", () => {
|
it("CloudEvent contains 'source'", () => {
|
||||||
|
|
@ -213,13 +218,13 @@ describe("HTTP Transport Binding Binary Receiver for CloudEvents v0.3", () => {
|
||||||
data: "dataString"
|
data: "dataString"
|
||||||
};
|
};
|
||||||
const attributes = {
|
const attributes = {
|
||||||
"ce-type": "type",
|
[BINARY_HEADERS_03.TYPE]: "type",
|
||||||
"ce-specversion": "0.3",
|
[BINARY_HEADERS_03.SPEC_VERSION]: SPEC_V03,
|
||||||
"ce-source": "/source",
|
[BINARY_HEADERS_03.SOURCE]: "/source",
|
||||||
"ce-id": "id",
|
[BINARY_HEADERS_03.ID]: "id",
|
||||||
"ce-time": "2019-06-16T11:42:00Z",
|
[BINARY_HEADERS_03.TIME]: "2019-06-16T11:42:00Z",
|
||||||
"ce-schemaurl": "http://schema.registry/v1",
|
[BINARY_HEADERS_03.SCHEMA_URL]: "http://schema.registry/v1",
|
||||||
"Content-Type": "application/json"
|
[HEADER_CONTENT_TYPE]: "application/json"
|
||||||
};
|
};
|
||||||
|
|
||||||
// act
|
// act
|
||||||
|
|
@ -236,13 +241,13 @@ describe("HTTP Transport Binding Binary Receiver for CloudEvents v0.3", () => {
|
||||||
data: "dataString"
|
data: "dataString"
|
||||||
};
|
};
|
||||||
const attributes = {
|
const attributes = {
|
||||||
"ce-type": "type",
|
[BINARY_HEADERS_03.TYPE]: "type",
|
||||||
"ce-specversion": "0.3",
|
[BINARY_HEADERS_03.SPEC_VERSION]: SPEC_V03,
|
||||||
"ce-source": "/source",
|
[BINARY_HEADERS_03.SOURCE]: "/source",
|
||||||
"ce-id": "id",
|
[BINARY_HEADERS_03.ID]: "id",
|
||||||
"ce-time": "2019-06-16T11:42:00Z",
|
[BINARY_HEADERS_03.TIME]: "2019-06-16T11:42:00Z",
|
||||||
"ce-schemaurl": "http://schema.registry/v1",
|
[BINARY_HEADERS_03.SCHEMA_URL]: "http://schema.registry/v1",
|
||||||
"Content-Type": "application/json"
|
[HEADER_CONTENT_TYPE]: "application/json"
|
||||||
};
|
};
|
||||||
|
|
||||||
// act
|
// act
|
||||||
|
|
@ -259,13 +264,13 @@ describe("HTTP Transport Binding Binary Receiver for CloudEvents v0.3", () => {
|
||||||
data: "dataString"
|
data: "dataString"
|
||||||
};
|
};
|
||||||
const attributes = {
|
const attributes = {
|
||||||
"ce-type": "type",
|
[BINARY_HEADERS_03.TYPE]: "type",
|
||||||
"ce-specversion": "0.3",
|
[BINARY_HEADERS_03.SPEC_VERSION]: SPEC_V03,
|
||||||
"ce-source": "/source",
|
[BINARY_HEADERS_03.SOURCE]: "/source",
|
||||||
"ce-id": "id",
|
[BINARY_HEADERS_03.ID]: "id",
|
||||||
"ce-time": "2019-06-16T11:42:00.000Z",
|
[BINARY_HEADERS_03.TIME]: "2019-06-16T11:42:00Z",
|
||||||
"ce-schemaurl": "http://schema.registry/v1",
|
[BINARY_HEADERS_03.SCHEMA_URL]: "http://schema.registry/v1",
|
||||||
"Content-Type": "application/json"
|
[HEADER_CONTENT_TYPE]: "application/json"
|
||||||
};
|
};
|
||||||
|
|
||||||
// act
|
// act
|
||||||
|
|
@ -282,13 +287,13 @@ describe("HTTP Transport Binding Binary Receiver for CloudEvents v0.3", () => {
|
||||||
data: "dataString"
|
data: "dataString"
|
||||||
};
|
};
|
||||||
const attributes = {
|
const attributes = {
|
||||||
"ce-type": "type",
|
[BINARY_HEADERS_03.TYPE]: "type",
|
||||||
"ce-specversion": "0.3",
|
[BINARY_HEADERS_03.SPEC_VERSION]: SPEC_V03,
|
||||||
"ce-source": "/source",
|
[BINARY_HEADERS_03.SOURCE]: "/source",
|
||||||
"ce-id": "id",
|
[BINARY_HEADERS_03.ID]: "id",
|
||||||
"ce-time": "2019-06-16T11:42:00Z",
|
[BINARY_HEADERS_03.TIME]: "2019-06-16T11:42:00Z",
|
||||||
"ce-schemaurl": "http://schema.registry/v1",
|
[BINARY_HEADERS_03.SCHEMA_URL]: "http://schema.registry/v1",
|
||||||
"Content-Type": "application/json"
|
[HEADER_CONTENT_TYPE]: "application/json"
|
||||||
};
|
};
|
||||||
|
|
||||||
// act
|
// act
|
||||||
|
|
@ -305,13 +310,13 @@ describe("HTTP Transport Binding Binary Receiver for CloudEvents v0.3", () => {
|
||||||
data: "dataString"
|
data: "dataString"
|
||||||
};
|
};
|
||||||
const attributes = {
|
const attributes = {
|
||||||
"ce-type": "type",
|
[BINARY_HEADERS_03.TYPE]: "type",
|
||||||
"ce-specversion": "0.3",
|
[BINARY_HEADERS_03.SPEC_VERSION]: SPEC_V03,
|
||||||
"ce-source": "/source",
|
[BINARY_HEADERS_03.SOURCE]: "/source",
|
||||||
"ce-id": "id",
|
[BINARY_HEADERS_03.ID]: "id",
|
||||||
"ce-time": "2019-06-16T11:42:00Z",
|
[BINARY_HEADERS_03.TIME]: "2019-06-16T11:42:00Z",
|
||||||
"ce-schemaurl": "http://schema.registry/v1",
|
[BINARY_HEADERS_03.SCHEMA_URL]: "http://schema.registry/v1",
|
||||||
"Content-Type": "application/json"
|
[HEADER_CONTENT_TYPE]: "application/json"
|
||||||
};
|
};
|
||||||
|
|
||||||
// act
|
// act
|
||||||
|
|
@ -327,13 +332,13 @@ describe("HTTP Transport Binding Binary Receiver for CloudEvents v0.3", () => {
|
||||||
// setup
|
// setup
|
||||||
const payload = "The payload is binary data";
|
const payload = "The payload is binary data";
|
||||||
const attributes = {
|
const attributes = {
|
||||||
"ce-type": "type",
|
[BINARY_HEADERS_03.TYPE]: "type",
|
||||||
"ce-specversion": "0.3",
|
[BINARY_HEADERS_03.SPEC_VERSION]: SPEC_V03,
|
||||||
"ce-source": "/source",
|
[BINARY_HEADERS_03.SOURCE]: "/source",
|
||||||
"ce-id": "id",
|
[BINARY_HEADERS_03.ID]: "id",
|
||||||
"ce-time": "2019-06-16T11:42:00Z",
|
[BINARY_HEADERS_03.TIME]: "2019-06-16T11:42:00Z",
|
||||||
"ce-schemaurl": "http://schema.registry/v1",
|
[BINARY_HEADERS_03.SCHEMA_URL]: "http://schema.registry/v1",
|
||||||
"Content-Type": "application/octet-stream"
|
[HEADER_CONTENT_TYPE]: "application/octet-stream"
|
||||||
};
|
};
|
||||||
|
|
||||||
// act
|
// act
|
||||||
|
|
@ -350,13 +355,13 @@ describe("HTTP Transport Binding Binary Receiver for CloudEvents v0.3", () => {
|
||||||
data: "dataString"
|
data: "dataString"
|
||||||
};
|
};
|
||||||
const attributes = {
|
const attributes = {
|
||||||
"ce-type": "type",
|
[BINARY_HEADERS_03.TYPE]: "type",
|
||||||
"ce-specversion": "0.3",
|
[BINARY_HEADERS_03.SPEC_VERSION]: SPEC_V03,
|
||||||
"ce-source": "/source",
|
[BINARY_HEADERS_03.SOURCE]: "/source",
|
||||||
"ce-id": "id",
|
[BINARY_HEADERS_03.ID]: "id",
|
||||||
"ce-time": "2019-06-16T11:42:00Z",
|
[BINARY_HEADERS_03.TIME]: "2019-06-16T11:42:00Z",
|
||||||
"ce-schemaurl": "http://schema.registry/v1",
|
[BINARY_HEADERS_03.SCHEMA_URL]: "http://schema.registry/v1",
|
||||||
"Content-Type": "application/json"
|
[HEADER_CONTENT_TYPE]: "application/json"
|
||||||
};
|
};
|
||||||
|
|
||||||
// act
|
// act
|
||||||
|
|
@ -371,13 +376,13 @@ describe("HTTP Transport Binding Binary Receiver for CloudEvents v0.3", () => {
|
||||||
// setup
|
// setup
|
||||||
const payload = "The payload is binary data";
|
const payload = "The payload is binary data";
|
||||||
const attributes = {
|
const attributes = {
|
||||||
"ce-type": "type",
|
[BINARY_HEADERS_03.TYPE]: "type",
|
||||||
"ce-specversion": "0.3",
|
[BINARY_HEADERS_03.SPEC_VERSION]: SPEC_V03,
|
||||||
"ce-source": "/source",
|
[BINARY_HEADERS_03.SOURCE]: "/source",
|
||||||
"ce-id": "id",
|
[BINARY_HEADERS_03.ID]: "id",
|
||||||
"ce-time": "2019-06-16T11:42:00Z",
|
[BINARY_HEADERS_03.TIME]: "2019-06-16T11:42:00Z",
|
||||||
"ce-schemaurl": "http://schema.registry/v1",
|
[BINARY_HEADERS_03.SCHEMA_URL]: "http://schema.registry/v1",
|
||||||
"Content-Type": "application/octet-stream"
|
[HEADER_CONTENT_TYPE]: "application/octet-stream"
|
||||||
};
|
};
|
||||||
|
|
||||||
// act
|
// act
|
||||||
|
|
@ -394,13 +399,13 @@ describe("HTTP Transport Binding Binary Receiver for CloudEvents v0.3", () => {
|
||||||
data: "dataString"
|
data: "dataString"
|
||||||
};
|
};
|
||||||
const attributes = {
|
const attributes = {
|
||||||
"ce-type": "type",
|
[BINARY_HEADERS_03.TYPE]: "type",
|
||||||
"ce-specversion": "0.3",
|
[BINARY_HEADERS_03.SPEC_VERSION]: SPEC_V03,
|
||||||
"ce-source": "source",
|
[BINARY_HEADERS_03.SOURCE]: "source",
|
||||||
"ce-id": "id",
|
[BINARY_HEADERS_03.ID]: "id",
|
||||||
"ce-time": "2019-06-16T11:42:00Z",
|
[BINARY_HEADERS_03.TIME]: "2019-06-16T11:42:00Z",
|
||||||
"ce-schemaurl": "http://schema.registry/v1",
|
[BINARY_HEADERS_03.SCHEMA_URL]: "http://schema.registry/v1",
|
||||||
"Content-Type": "application/json"
|
[HEADER_CONTENT_TYPE]: "application/json"
|
||||||
};
|
};
|
||||||
|
|
||||||
// act
|
// act
|
||||||
|
|
@ -421,14 +426,14 @@ describe("HTTP Transport Binding Binary Receiver for CloudEvents v0.3", () => {
|
||||||
data: "dataString"
|
data: "dataString"
|
||||||
};
|
};
|
||||||
const attributes = {
|
const attributes = {
|
||||||
"ce-type": "type",
|
[BINARY_HEADERS_03.TYPE]: "type",
|
||||||
"ce-specversion": "0.3",
|
[BINARY_HEADERS_03.SPEC_VERSION]: SPEC_V03,
|
||||||
"ce-source": "source",
|
[BINARY_HEADERS_03.SOURCE]: "source",
|
||||||
"ce-id": "id",
|
[BINARY_HEADERS_03.ID]: "id",
|
||||||
"ce-time": "2019-06-16T11:42:00Z",
|
[BINARY_HEADERS_03.TIME]: "2019-06-16T11:42:00Z",
|
||||||
"ce-schemaurl": "http://schema.registry/v1",
|
[BINARY_HEADERS_03.SCHEMA_URL]: "http://schema.registry/v1",
|
||||||
"Content-Type": "application/json",
|
[HEADER_CONTENT_TYPE]: "application/json",
|
||||||
"ce-extension1": extension1
|
[`${[BINARY_HEADERS_03.EXTENSIONS_PREFIX]}extension1`]: extension1
|
||||||
};
|
};
|
||||||
|
|
||||||
// act
|
// act
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,10 @@
|
||||||
const expect = require("chai").expect;
|
const expect = require("chai").expect;
|
||||||
const { asBase64 } = require("../../../lib/utils/fun.js");
|
const { asBase64 } = require("../../../lib/utils/fun.js");
|
||||||
|
const {
|
||||||
|
BINARY_HEADERS_1,
|
||||||
|
SPEC_V1,
|
||||||
|
HEADER_CONTENT_TYPE
|
||||||
|
} = require("../../../lib/bindings/http/constants.js");
|
||||||
|
|
||||||
const HTTPBinaryReceiver =
|
const HTTPBinaryReceiver =
|
||||||
require("../../../lib/bindings/http/receiver_binary_1.js");
|
require("../../../lib/bindings/http/receiver_binary_1.js");
|
||||||
|
|
@ -42,10 +47,10 @@ describe("HTTP Transport Binding Binary Receiver for CloudEvents v1.0", () => {
|
||||||
// setup
|
// setup
|
||||||
const payload = {};
|
const payload = {};
|
||||||
const attributes = {
|
const attributes = {
|
||||||
"ce-specversion": "specversion",
|
[BINARY_HEADERS_1.SPEC_VERSION]: "specversion",
|
||||||
"ce-source": "source",
|
[BINARY_HEADERS_1.SOURCE]: "source",
|
||||||
"ce-id": "id",
|
[BINARY_HEADERS_1.ID]: "id",
|
||||||
"Content-Type": "application/json"
|
[HEADER_CONTENT_TYPE]: "application/json"
|
||||||
};
|
};
|
||||||
|
|
||||||
// act and assert
|
// act and assert
|
||||||
|
|
@ -57,10 +62,10 @@ describe("HTTP Transport Binding Binary Receiver for CloudEvents v1.0", () => {
|
||||||
// setup
|
// setup
|
||||||
const payload = {};
|
const payload = {};
|
||||||
const attributes = {
|
const attributes = {
|
||||||
"ce-type": "type",
|
[BINARY_HEADERS_1.TYPE]: "type",
|
||||||
"ce-source": "source",
|
[BINARY_HEADERS_1.SOURCE]: "source",
|
||||||
"ce-id": "id",
|
[BINARY_HEADERS_1.ID]: "id",
|
||||||
"Content-Type": "application/json"
|
[HEADER_CONTENT_TYPE]: "application/json"
|
||||||
};
|
};
|
||||||
|
|
||||||
// act and assert
|
// act and assert
|
||||||
|
|
@ -72,10 +77,10 @@ describe("HTTP Transport Binding Binary Receiver for CloudEvents v1.0", () => {
|
||||||
// setup
|
// setup
|
||||||
const payload = {};
|
const payload = {};
|
||||||
const attributes = {
|
const attributes = {
|
||||||
"ce-type": "type",
|
[BINARY_HEADERS_1.TYPE]: "type",
|
||||||
"ce-specversion": "specversion",
|
[BINARY_HEADERS_1.SPEC_VERSION]: "specversion",
|
||||||
"ce-id": "id",
|
[BINARY_HEADERS_1.ID]: "id",
|
||||||
"Content-Type": "application/json"
|
[HEADER_CONTENT_TYPE]: "application/json"
|
||||||
};
|
};
|
||||||
|
|
||||||
// act and assert
|
// act and assert
|
||||||
|
|
@ -87,10 +92,10 @@ describe("HTTP Transport Binding Binary Receiver for CloudEvents v1.0", () => {
|
||||||
// setup
|
// setup
|
||||||
const payload = {};
|
const payload = {};
|
||||||
const attributes = {
|
const attributes = {
|
||||||
"ce-type": "type",
|
[BINARY_HEADERS_1.TYPE]: "type",
|
||||||
"ce-specversion": "specversion",
|
[BINARY_HEADERS_1.SPEC_VERSION]: "specversion",
|
||||||
"ce-source": "source",
|
[BINARY_HEADERS_1.SOURCE]: "source",
|
||||||
"Content-Type": "application/json"
|
[HEADER_CONTENT_TYPE]: "application/json"
|
||||||
};
|
};
|
||||||
|
|
||||||
// act and assert
|
// act and assert
|
||||||
|
|
@ -102,11 +107,11 @@ describe("HTTP Transport Binding Binary Receiver for CloudEvents v1.0", () => {
|
||||||
// setup
|
// setup
|
||||||
const payload = {};
|
const payload = {};
|
||||||
const attributes = {
|
const attributes = {
|
||||||
"ce-type": "type",
|
[BINARY_HEADERS_1.TYPE]: "type",
|
||||||
"ce-specversion": "0.2",
|
[BINARY_HEADERS_1.SPEC_VERSION]: "0.2",
|
||||||
"ce-source": "source",
|
[BINARY_HEADERS_1.SOURCE]: "source",
|
||||||
"ce-id": "id",
|
[BINARY_HEADERS_1.ID]: "id",
|
||||||
"Content-Type": "application/json"
|
[HEADER_CONTENT_TYPE]: "application/json"
|
||||||
};
|
};
|
||||||
|
|
||||||
// act and assert
|
// act and assert
|
||||||
|
|
@ -118,11 +123,11 @@ describe("HTTP Transport Binding Binary Receiver for CloudEvents v1.0", () => {
|
||||||
// setup
|
// setup
|
||||||
const payload = {};
|
const payload = {};
|
||||||
const attributes = {
|
const attributes = {
|
||||||
"ce-type": "type",
|
[BINARY_HEADERS_1.TYPE]: "type",
|
||||||
"ce-specversion": "specversion",
|
[BINARY_HEADERS_1.SPEC_VERSION]: "specversion",
|
||||||
"ce-source": "source",
|
[BINARY_HEADERS_1.SOURCE]: "source",
|
||||||
"ce-id": "id",
|
[BINARY_HEADERS_1.ID]: "id",
|
||||||
"Content-Type": "text/html"
|
[HEADER_CONTENT_TYPE]: "text/html"
|
||||||
};
|
};
|
||||||
|
|
||||||
// act and assert
|
// act and assert
|
||||||
|
|
@ -133,10 +138,10 @@ describe("HTTP Transport Binding Binary Receiver for CloudEvents v1.0", () => {
|
||||||
it("No error when content-type is unspecified", () => {
|
it("No error when content-type is unspecified", () => {
|
||||||
const payload = {};
|
const payload = {};
|
||||||
const attributes = {
|
const attributes = {
|
||||||
"ce-type": "type",
|
[BINARY_HEADERS_1.TYPE]: "type",
|
||||||
"ce-specversion": "1.0",
|
[BINARY_HEADERS_1.SPEC_VERSION]: SPEC_V1,
|
||||||
"ce-source": "source",
|
[BINARY_HEADERS_1.SOURCE]: "source",
|
||||||
"ce-id": "id"
|
[BINARY_HEADERS_1.ID]: "id"
|
||||||
};
|
};
|
||||||
|
|
||||||
// act and assert
|
// act and assert
|
||||||
|
|
@ -148,11 +153,11 @@ describe("HTTP Transport Binding Binary Receiver for CloudEvents v1.0", () => {
|
||||||
// setup
|
// setup
|
||||||
const payload = {};
|
const payload = {};
|
||||||
const attributes = {
|
const attributes = {
|
||||||
"ce-type": "type",
|
[BINARY_HEADERS_1.TYPE]: "type",
|
||||||
"ce-specversion": "1.0",
|
[BINARY_HEADERS_1.SPEC_VERSION]: SPEC_V1,
|
||||||
"ce-source": "source",
|
[BINARY_HEADERS_1.SOURCE]: "source",
|
||||||
"ce-id": "id",
|
[BINARY_HEADERS_1.ID]: "id",
|
||||||
"Content-Type": "application/json"
|
[HEADER_CONTENT_TYPE]: "application/json"
|
||||||
};
|
};
|
||||||
|
|
||||||
// act and assert
|
// act and assert
|
||||||
|
|
@ -168,13 +173,13 @@ describe("HTTP Transport Binding Binary Receiver for CloudEvents v1.0", () => {
|
||||||
data: "dataString"
|
data: "dataString"
|
||||||
};
|
};
|
||||||
const attributes = {
|
const attributes = {
|
||||||
"ce-type": "type",
|
[BINARY_HEADERS_1.TYPE]: "type",
|
||||||
"ce-specversion": "1.0",
|
[BINARY_HEADERS_1.SPEC_VERSION]: SPEC_V1,
|
||||||
"ce-source": "source",
|
[BINARY_HEADERS_1.SOURCE]: "source",
|
||||||
"ce-id": "id",
|
[BINARY_HEADERS_1.ID]: "id",
|
||||||
"ce-time": "2019-06-16T11:42:00Z",
|
[BINARY_HEADERS_1.TIME]: "2019-06-16T11:42:00Z",
|
||||||
"ce-dataschema": "http://schema.registry/v1",
|
[BINARY_HEADERS_1.DATA_SCHEMA]: "http://schema.registry/v1",
|
||||||
"Content-Type": "application/json"
|
[HEADER_CONTENT_TYPE]: "application/json"
|
||||||
};
|
};
|
||||||
|
|
||||||
// act
|
// act
|
||||||
|
|
@ -191,13 +196,13 @@ describe("HTTP Transport Binding Binary Receiver for CloudEvents v1.0", () => {
|
||||||
data: "dataString"
|
data: "dataString"
|
||||||
};
|
};
|
||||||
const attributes = {
|
const attributes = {
|
||||||
"ce-type": "type",
|
[BINARY_HEADERS_1.TYPE]: "type",
|
||||||
"ce-specversion": "1.0",
|
[BINARY_HEADERS_1.SPEC_VERSION]: SPEC_V1,
|
||||||
"ce-source": "source",
|
[BINARY_HEADERS_1.SOURCE]: "source",
|
||||||
"ce-id": "id",
|
[BINARY_HEADERS_1.ID]: "id",
|
||||||
"ce-time": "2019-06-16T11:42:00Z",
|
[BINARY_HEADERS_1.TIME]: "2019-06-16T11:42:00Z",
|
||||||
"ce-dataschema": "http://schema.registry/v1",
|
[BINARY_HEADERS_1.DATA_SCHEMA]: "http://schema.registry/v1",
|
||||||
"Content-Type": "application/json"
|
[HEADER_CONTENT_TYPE]: "application/json"
|
||||||
};
|
};
|
||||||
|
|
||||||
// act
|
// act
|
||||||
|
|
@ -205,7 +210,7 @@ describe("HTTP Transport Binding Binary Receiver for CloudEvents v1.0", () => {
|
||||||
|
|
||||||
// assert
|
// assert
|
||||||
expect(actual.getSpecversion())
|
expect(actual.getSpecversion())
|
||||||
.to.equal("1.0");
|
.to.equal(SPEC_V1);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("CloudEvent contains 'source'", () => {
|
it("CloudEvent contains 'source'", () => {
|
||||||
|
|
@ -214,13 +219,13 @@ describe("HTTP Transport Binding Binary Receiver for CloudEvents v1.0", () => {
|
||||||
data: "dataString"
|
data: "dataString"
|
||||||
};
|
};
|
||||||
const attributes = {
|
const attributes = {
|
||||||
"ce-type": "type",
|
[BINARY_HEADERS_1.TYPE]: "type",
|
||||||
"ce-specversion": "1.0",
|
[BINARY_HEADERS_1.SPEC_VERSION]: SPEC_V1,
|
||||||
"ce-source": "/source",
|
[BINARY_HEADERS_1.SOURCE]: "/source",
|
||||||
"ce-id": "id",
|
[BINARY_HEADERS_1.ID]: "id",
|
||||||
"ce-time": "2019-06-16T11:42:00Z",
|
[BINARY_HEADERS_1.TIME]: "2019-06-16T11:42:00Z",
|
||||||
"ce-dataschema": "http://schema.registry/v1",
|
[BINARY_HEADERS_1.DATA_SCHEMA]: "http://schema.registry/v1",
|
||||||
"Content-Type": "application/json"
|
[HEADER_CONTENT_TYPE]: "application/json"
|
||||||
};
|
};
|
||||||
|
|
||||||
// act
|
// act
|
||||||
|
|
@ -237,13 +242,13 @@ describe("HTTP Transport Binding Binary Receiver for CloudEvents v1.0", () => {
|
||||||
data: "dataString"
|
data: "dataString"
|
||||||
};
|
};
|
||||||
const attributes = {
|
const attributes = {
|
||||||
"ce-type": "type",
|
[BINARY_HEADERS_1.TYPE]: "type",
|
||||||
"ce-specversion": "1.0",
|
[BINARY_HEADERS_1.SPEC_VERSION]: SPEC_V1,
|
||||||
"ce-source": "/source",
|
[BINARY_HEADERS_1.SOURCE]: "/source",
|
||||||
"ce-id": "id",
|
[BINARY_HEADERS_1.ID]: "id",
|
||||||
"ce-time": "2019-06-16T11:42:00Z",
|
[BINARY_HEADERS_1.TIME]: "2019-06-16T11:42:00Z",
|
||||||
"ce-dataschema": "http://schema.registry/v1",
|
[BINARY_HEADERS_1.DATA_SCHEMA]: "http://schema.registry/v1",
|
||||||
"Content-Type": "application/json"
|
[HEADER_CONTENT_TYPE]: "application/json"
|
||||||
};
|
};
|
||||||
|
|
||||||
// act
|
// act
|
||||||
|
|
@ -260,13 +265,13 @@ describe("HTTP Transport Binding Binary Receiver for CloudEvents v1.0", () => {
|
||||||
data: "dataString"
|
data: "dataString"
|
||||||
};
|
};
|
||||||
const attributes = {
|
const attributes = {
|
||||||
"ce-type": "type",
|
[BINARY_HEADERS_1.TYPE]: "type",
|
||||||
"ce-specversion": "1.0",
|
[BINARY_HEADERS_1.SPEC_VERSION]: SPEC_V1,
|
||||||
"ce-source": "/source",
|
[BINARY_HEADERS_1.SOURCE]: "/source",
|
||||||
"ce-id": "id",
|
[BINARY_HEADERS_1.ID]: "id",
|
||||||
"ce-time": "2019-06-16T11:42:00.000Z",
|
[BINARY_HEADERS_1.TIME]: "2019-06-16T11:42:00Z",
|
||||||
"ce-dataschema": "http://schema.registry/v1",
|
[BINARY_HEADERS_1.DATA_SCHEMA]: "http://schema.registry/v1",
|
||||||
"Content-Type": "application/json"
|
[HEADER_CONTENT_TYPE]: "application/json"
|
||||||
};
|
};
|
||||||
|
|
||||||
// act
|
// act
|
||||||
|
|
@ -283,13 +288,13 @@ describe("HTTP Transport Binding Binary Receiver for CloudEvents v1.0", () => {
|
||||||
data: "dataString"
|
data: "dataString"
|
||||||
};
|
};
|
||||||
const attributes = {
|
const attributes = {
|
||||||
"ce-type": "type",
|
[BINARY_HEADERS_1.TYPE]: "type",
|
||||||
"ce-specversion": "1.0",
|
[BINARY_HEADERS_1.SPEC_VERSION]: SPEC_V1,
|
||||||
"ce-source": "/source",
|
[BINARY_HEADERS_1.SOURCE]: "/source",
|
||||||
"ce-id": "id",
|
[BINARY_HEADERS_1.ID]: "id",
|
||||||
"ce-time": "2019-06-16T11:42:00Z",
|
[BINARY_HEADERS_1.TIME]: "2019-06-16T11:42:00Z",
|
||||||
"ce-dataschema": "http://schema.registry/v1",
|
[BINARY_HEADERS_1.DATA_SCHEMA]: "http://schema.registry/v1",
|
||||||
"Content-Type": "application/json"
|
[HEADER_CONTENT_TYPE]: "application/json"
|
||||||
};
|
};
|
||||||
|
|
||||||
// act
|
// act
|
||||||
|
|
@ -306,13 +311,13 @@ describe("HTTP Transport Binding Binary Receiver for CloudEvents v1.0", () => {
|
||||||
data: "dataString"
|
data: "dataString"
|
||||||
};
|
};
|
||||||
const attributes = {
|
const attributes = {
|
||||||
"ce-type": "type",
|
[BINARY_HEADERS_1.TYPE]: "type",
|
||||||
"ce-specversion": "1.0",
|
[BINARY_HEADERS_1.SPEC_VERSION]: SPEC_V1,
|
||||||
"ce-source": "/source",
|
[BINARY_HEADERS_1.SOURCE]: "/source",
|
||||||
"ce-id": "id",
|
[BINARY_HEADERS_1.ID]: "id",
|
||||||
"ce-time": "2019-06-16T11:42:00Z",
|
[BINARY_HEADERS_1.TIME]: "2019-06-16T11:42:00Z",
|
||||||
"ce-dataschema": "http://schema.registry/v1",
|
[BINARY_HEADERS_1.DATA_SCHEMA]: "http://schema.registry/v1",
|
||||||
"Content-Type": "application/json"
|
[HEADER_CONTENT_TYPE]: "application/json"
|
||||||
};
|
};
|
||||||
|
|
||||||
// act
|
// act
|
||||||
|
|
@ -327,13 +332,13 @@ describe("HTTP Transport Binding Binary Receiver for CloudEvents v1.0", () => {
|
||||||
// setup
|
// setup
|
||||||
const payload = "The payload is binary data";
|
const payload = "The payload is binary data";
|
||||||
const attributes = {
|
const attributes = {
|
||||||
"ce-type": "type",
|
[BINARY_HEADERS_1.TYPE]: "type",
|
||||||
"ce-specversion": "1.0",
|
[BINARY_HEADERS_1.SPEC_VERSION]: SPEC_V1,
|
||||||
"ce-source": "/source",
|
[BINARY_HEADERS_1.SOURCE]: "/source",
|
||||||
"ce-id": "id",
|
[BINARY_HEADERS_1.ID]: "id",
|
||||||
"ce-time": "2019-06-16T11:42:00Z",
|
[BINARY_HEADERS_1.TIME]: "2019-06-16T11:42:00Z",
|
||||||
"ce-dataschema": "http://schema.registry/v1",
|
[BINARY_HEADERS_1.DATA_SCHEMA]: "http://schema.registry/v1",
|
||||||
"Content-Type": "application/octet-stream"
|
[HEADER_CONTENT_TYPE]: "application/octet-stream"
|
||||||
};
|
};
|
||||||
|
|
||||||
// act
|
// act
|
||||||
|
|
@ -350,13 +355,13 @@ describe("HTTP Transport Binding Binary Receiver for CloudEvents v1.0", () => {
|
||||||
data: "dataString"
|
data: "dataString"
|
||||||
};
|
};
|
||||||
const attributes = {
|
const attributes = {
|
||||||
"ce-type": "type",
|
[BINARY_HEADERS_1.TYPE]: "type",
|
||||||
"ce-specversion": "1.0",
|
[BINARY_HEADERS_1.SPEC_VERSION]: SPEC_V1,
|
||||||
"ce-source": "/source",
|
[BINARY_HEADERS_1.SOURCE]: "/source",
|
||||||
"ce-id": "id",
|
[BINARY_HEADERS_1.ID]: "id",
|
||||||
"ce-time": "2019-06-16T11:42:00Z",
|
[BINARY_HEADERS_1.TIME]: "2019-06-16T11:42:00Z",
|
||||||
"ce-dataschema": "http://schema.registry/v1",
|
[BINARY_HEADERS_1.DATA_SCHEMA]: "http://schema.registry/v1",
|
||||||
"Content-Type": "application/json"
|
[HEADER_CONTENT_TYPE]: "application/json"
|
||||||
};
|
};
|
||||||
|
|
||||||
// act
|
// act
|
||||||
|
|
@ -371,13 +376,13 @@ describe("HTTP Transport Binding Binary Receiver for CloudEvents v1.0", () => {
|
||||||
// setup
|
// setup
|
||||||
const payload = "The payload is binary data";
|
const payload = "The payload is binary data";
|
||||||
const attributes = {
|
const attributes = {
|
||||||
"ce-type": "type",
|
[BINARY_HEADERS_1.TYPE]: "type",
|
||||||
"ce-specversion": "1.0",
|
[BINARY_HEADERS_1.SPEC_VERSION]: SPEC_V1,
|
||||||
"ce-source": "/source",
|
[BINARY_HEADERS_1.SOURCE]: "/source",
|
||||||
"ce-id": "id",
|
[BINARY_HEADERS_1.ID]: "id",
|
||||||
"ce-time": "2019-06-16T11:42:00Z",
|
[BINARY_HEADERS_1.TIME]: "2019-06-16T11:42:00Z",
|
||||||
"ce-dataschema": "http://schema.registry/v1",
|
[BINARY_HEADERS_1.DATA_SCHEMA]: "http://schema.registry/v1",
|
||||||
"Content-Type": "application/octet-stream"
|
[HEADER_CONTENT_TYPE]: "application/octet-stream"
|
||||||
};
|
};
|
||||||
|
|
||||||
// act
|
// act
|
||||||
|
|
@ -399,13 +404,13 @@ describe("HTTP Transport Binding Binary Receiver for CloudEvents v1.0", () => {
|
||||||
const payload = asBase64(bindata);
|
const payload = asBase64(bindata);
|
||||||
|
|
||||||
const attributes = {
|
const attributes = {
|
||||||
"ce-type": "type",
|
[BINARY_HEADERS_1.TYPE]: "type",
|
||||||
"ce-specversion": "1.0",
|
[BINARY_HEADERS_1.SPEC_VERSION]: SPEC_V1,
|
||||||
"ce-source": "/source",
|
[BINARY_HEADERS_1.SOURCE]: "/source",
|
||||||
"ce-id": "id",
|
[BINARY_HEADERS_1.ID]: "id",
|
||||||
"ce-time": "2019-06-16T11:42:00Z",
|
[BINARY_HEADERS_1.TIME]: "2019-06-16T11:42:00Z",
|
||||||
"ce-dataschema": "http://schema.registry/v1",
|
[BINARY_HEADERS_1.DATA_SCHEMA]: "http://schema.registry/v1",
|
||||||
"Content-Type": "application/json"
|
[HEADER_CONTENT_TYPE]: "application/json"
|
||||||
};
|
};
|
||||||
|
|
||||||
// act
|
// act
|
||||||
|
|
@ -422,13 +427,13 @@ describe("HTTP Transport Binding Binary Receiver for CloudEvents v1.0", () => {
|
||||||
data: "dataString"
|
data: "dataString"
|
||||||
};
|
};
|
||||||
const attributes = {
|
const attributes = {
|
||||||
"ce-type": "type",
|
[BINARY_HEADERS_1.TYPE]: "type",
|
||||||
"ce-specversion": "1.0",
|
[BINARY_HEADERS_1.SPEC_VERSION]: SPEC_V1,
|
||||||
"ce-source": "source",
|
[BINARY_HEADERS_1.SOURCE]: "source",
|
||||||
"ce-id": "id",
|
[BINARY_HEADERS_1.ID]: "id",
|
||||||
"ce-time": "2019-06-16T11:42:00Z",
|
[BINARY_HEADERS_1.TIME]: "2019-06-16T11:42:00Z",
|
||||||
"ce-dataschema": "http://schema.registry/v1",
|
[BINARY_HEADERS_1.DATA_SCHEMA]: "http://schema.registry/v1",
|
||||||
"Content-Type": "application/json"
|
[HEADER_CONTENT_TYPE]: "application/json"
|
||||||
};
|
};
|
||||||
|
|
||||||
// act
|
// act
|
||||||
|
|
@ -449,14 +454,14 @@ describe("HTTP Transport Binding Binary Receiver for CloudEvents v1.0", () => {
|
||||||
data: "dataString"
|
data: "dataString"
|
||||||
};
|
};
|
||||||
const attributes = {
|
const attributes = {
|
||||||
"ce-type": "type",
|
[BINARY_HEADERS_1.TYPE]: "type",
|
||||||
"ce-specversion": "1.0",
|
[BINARY_HEADERS_1.SPEC_VERSION]: SPEC_V1,
|
||||||
"ce-source": "source",
|
[BINARY_HEADERS_1.SOURCE]: "source",
|
||||||
"ce-id": "id",
|
[BINARY_HEADERS_1.ID]: "id",
|
||||||
"ce-time": "2019-06-16T11:42:00Z",
|
[BINARY_HEADERS_1.TIME]: "2019-06-16T11:42:00Z",
|
||||||
"ce-dataschema": "http://schema.registry/v1",
|
[BINARY_HEADERS_1.DATA_SCHEMA]: "http://schema.registry/v1",
|
||||||
"Content-Type": "application/json",
|
[HEADER_CONTENT_TYPE]: "application/json",
|
||||||
"ce-extension1": extension1
|
[`${[BINARY_HEADERS_1.EXTENSIONS_PREFIX]}extension1`]: extension1
|
||||||
};
|
};
|
||||||
|
|
||||||
// act
|
// act
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue