@azure/web-pubsub 1.0.1-alpha.20220311.2 → 1.0.1-alpha.20220325.2
Sign up to get free protection for your applications and to get access to all the features.
- package/dist-esm/test/groups.spec.js +7 -8
- package/dist-esm/test/groups.spec.js.map +1 -1
- package/dist-esm/test/hubs.spec.js +20 -21
- package/dist-esm/test/hubs.spec.js.map +1 -1
- package/dist-esm/test/integration.spec.js +3 -3
- package/dist-esm/test/integration.spec.js.map +1 -1
- package/dist-esm/test/testEnv.js +14 -13
- package/dist-esm/test/testEnv.js.map +1 -1
- package/package.json +5 -7
@@ -1,10 +1,10 @@
|
|
1
1
|
// Copyright (c) Microsoft Corporation.
|
2
2
|
// Licensed under the MIT license.
|
3
3
|
/* eslint-disable no-invalid-this */
|
4
|
-
import {
|
4
|
+
import { Recorder, assertEnvironmentVariable } from "@azure-tools/test-recorder";
|
5
5
|
import { WebPubSubServiceClient } from "../src";
|
6
6
|
import { assert } from "chai";
|
7
|
-
import
|
7
|
+
import recorderOptions from "./testEnv";
|
8
8
|
/* eslint-disable @typescript-eslint/no-invalid-this */
|
9
9
|
describe("Group client working with a group", function () {
|
10
10
|
let recorder;
|
@@ -13,9 +13,10 @@ describe("Group client working with a group", function () {
|
|
13
13
|
function onResponse(response) {
|
14
14
|
lastResponse = response;
|
15
15
|
}
|
16
|
-
beforeEach(function () {
|
17
|
-
recorder =
|
18
|
-
|
16
|
+
beforeEach(async function () {
|
17
|
+
recorder = new Recorder(this.currentTest);
|
18
|
+
await recorder.start(recorderOptions);
|
19
|
+
const hubClient = new WebPubSubServiceClient(assertEnvironmentVariable("WPS_CONNECTION_STRING"), "simplechat", recorder.configureClientOptions({}));
|
19
20
|
client = hubClient.group("group");
|
20
21
|
});
|
21
22
|
it("can broadcast to groups", async () => {
|
@@ -55,9 +56,7 @@ describe("Group client working with a group", function () {
|
|
55
56
|
await client.removeUser("brian");
|
56
57
|
});
|
57
58
|
afterEach(async function () {
|
58
|
-
|
59
|
-
recorder.stop();
|
60
|
-
}
|
59
|
+
await recorder.stop();
|
61
60
|
});
|
62
61
|
});
|
63
62
|
//# sourceMappingURL=groups.spec.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"groups.spec.js","sourceRoot":"","sources":["../../test/groups.spec.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAClC,oCAAoC;AACpC,OAAO,EAAE,
|
1
|
+
{"version":3,"file":"groups.spec.js","sourceRoot":"","sources":["../../test/groups.spec.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAClC,oCAAoC;AACpC,OAAO,EAAE,QAAQ,EAAE,yBAAyB,EAAE,MAAM,4BAA4B,CAAC;AACjF,OAAO,EAAE,sBAAsB,EAAkB,MAAM,QAAQ,CAAC;AAChE,OAAO,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAC9B,OAAO,eAAe,MAAM,WAAW,CAAC;AAGxC,uDAAuD;AAEvD,QAAQ,CAAC,mCAAmC,EAAE;IAC5C,IAAI,QAAkB,CAAC;IACvB,IAAI,MAAsB,CAAC;IAC3B,IAAI,YAA+C,CAAC;IACpD,SAAS,UAAU,CAAC,QAA+B;QACjD,YAAY,GAAG,QAAQ,CAAC;IAC1B,CAAC;IACD,UAAU,CAAC,KAAK;QACd,QAAQ,GAAG,IAAI,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;QAC1C,MAAM,QAAQ,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC;QACtC,MAAM,SAAS,GAAG,IAAI,sBAAsB,CAC1C,yBAAyB,CAAC,uBAAuB,CAAC,EAClD,YAAY,EACZ,QAAQ,CAAC,sBAAsB,CAAC,EAAE,CAAC,CACpC,CAAC;QAEF,MAAM,GAAG,SAAS,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IACpC,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,yBAAyB,EAAE,KAAK,IAAI,EAAE;QACvC,MAAM,MAAM,CAAC,SAAS,CAAC,OAAO,EAAE,EAAE,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K,uBAAL,KAAK,CAAE,IAAI,EAAE,WAAW,CAAC,CAAC;SAC9C;IACH,CAAC,CAAC,CAAC;IAEH,wEAAwE;IACxE,EAAE,CAAC,IAAI,CAAC,kBAAkB,EAAE,KAAK,IAAI,EAAE;QACrC,0EAA0E;QAC1E,4BAA4B;QAC5B,MAAM,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;QAE9B,uCAAuC;QACvC,MAAM,MAAM,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;IACnC,CAAC,CAAC,CAAC;IAEH,SAAS,CAAC,KAAK;QACb,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;IACxB,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n/* eslint-disable no-invalid-this */\nimport { Recorder, assertEnvironmentVariable } from \"@azure-tools/test-recorder\";\nimport { WebPubSubServiceClient, WebPubSubGroup } from \"../src\";\nimport { assert } from \"chai\";\nimport recorderOptions from \"./testEnv\";\nimport { FullOperationResponse } from \"@azure/core-client\";\nimport { RestError } from \"@azure/core-rest-pipeline\";\n/* eslint-disable @typescript-eslint/no-invalid-this */\n\ndescribe(\"Group client working with a group\", function () {\n let recorder: Recorder;\n let client: WebPubSubGroup;\n let lastResponse: FullOperationResponse | undefined;\n function onResponse(response: FullOperationResponse) {\n lastResponse = response;\n }\n beforeEach(async function () {\n recorder = new Recorder(this.currentTest);\n await recorder.start(recorderOptions);\n const hubClient = new WebPubSubServiceClient(\n assertEnvironmentVariable(\"WPS_CONNECTION_STRING\"),\n \"simplechat\",\n recorder.configureClientOptions({})\n );\n\n client = hubClient.group(\"group\");\n });\n\n it(\"can broadcast to groups\", async () => {\n await client.sendToAll(\"hello\", { contentType: \"text/plain\", onResponse });\n assert.equal(lastResponse?.status, 202);\n\n await client.sendToAll({ x: 1, y: 2 }, { onResponse });\n assert.equal(lastResponse?.status, 202);\n\n const binaryMessage = new Uint8Array(10);\n await client.sendToAll(binaryMessage.buffer, { onResponse });\n assert.equal(lastResponse?.status, 202);\n });\n\n it(\"can manage connections\", async () => {\n // this endpoint returns 404 for connections not on the hub\n let error: RestError | undefined;\n try {\n await client.addConnection(\"xxxx\");\n } catch (e) {\n error = e;\n }\n\n assert.exists(error);\n assert.strictEqual(error?.name, \"RestError\");\n\n try {\n await client.removeConnection(\"xxxx\", { onResponse });\n } catch (e) {\n assert.exists(error);\n assert.strictEqual(error?.name, \"RestError\");\n }\n });\n\n // skipping until we can record better tests with an actual user active.\n it.skip(\"can manage users\", async () => {\n // service returns 404, this should likely be raised as an error but isn't\n // due to the swagger design\n await client.addUser(\"brian\");\n\n // service returns 404 and this throws.\n await client.removeUser(\"brian\");\n });\n\n afterEach(async function () {\n await recorder.stop();\n });\n});\n"]}
|
@@ -1,53 +1,52 @@
|
|
1
1
|
// Copyright (c) Microsoft Corporation.
|
2
2
|
// Licensed under the MIT license.
|
3
3
|
/* eslint-disable no-invalid-this */
|
4
|
-
import {
|
4
|
+
import { Recorder, isLiveMode, assertEnvironmentVariable } from "@azure-tools/test-recorder";
|
5
5
|
import { WebPubSubServiceClient, AzureKeyCredential } from "../src";
|
6
6
|
import { assert } from "chai";
|
7
|
-
import
|
8
|
-
import {
|
7
|
+
import recorderOptions from "./testEnv";
|
8
|
+
import { createTestCredential } from "@azure-tools/test-credential";
|
9
9
|
/* eslint-disable @typescript-eslint/no-invalid-this */
|
10
10
|
describe("HubClient", function () {
|
11
|
-
let recorder;
|
12
|
-
beforeEach(function () {
|
13
|
-
recorder = record(this, environmentSetup);
|
14
|
-
});
|
15
|
-
afterEach(async function () {
|
16
|
-
if (recorder) {
|
17
|
-
await recorder.stop();
|
18
|
-
}
|
19
|
-
});
|
20
11
|
describe("Constructing a HubClient", () => {
|
12
|
+
const credential = createTestCredential();
|
21
13
|
it("takes a connection string, hub name, and options", () => {
|
22
14
|
assert.doesNotThrow(() => {
|
23
|
-
new WebPubSubServiceClient(
|
15
|
+
new WebPubSubServiceClient(assertEnvironmentVariable("WPS_CONNECTION_STRING"), "test-hub", {
|
24
16
|
retryOptions: { maxRetries: 2 },
|
25
17
|
});
|
26
18
|
});
|
27
19
|
});
|
28
20
|
it("takes an endpoint, an API key, a hub name, and options", () => {
|
29
21
|
assert.doesNotThrow(() => {
|
30
|
-
new WebPubSubServiceClient(
|
22
|
+
new WebPubSubServiceClient(assertEnvironmentVariable("WPS_ENDPOINT"), new AzureKeyCredential(assertEnvironmentVariable("WPS_API_KEY")), "test-hub", {
|
31
23
|
retryOptions: { maxRetries: 2 },
|
32
24
|
});
|
33
25
|
});
|
34
26
|
});
|
35
27
|
it("takes an endpoint, DefaultAzureCredential, a hub name, and options", () => {
|
36
28
|
assert.doesNotThrow(() => {
|
37
|
-
new WebPubSubServiceClient(
|
29
|
+
new WebPubSubServiceClient(assertEnvironmentVariable("WPS_ENDPOINT"), credential, "test-hub", {
|
38
30
|
retryOptions: { maxRetries: 2 },
|
39
31
|
});
|
40
32
|
});
|
41
33
|
});
|
42
34
|
});
|
43
35
|
describe("Working with a hub", function () {
|
36
|
+
let recorder;
|
44
37
|
let client;
|
45
38
|
let lastResponse;
|
39
|
+
const credential = createTestCredential();
|
46
40
|
function onResponse(response) {
|
47
41
|
lastResponse = response;
|
48
42
|
}
|
49
|
-
beforeEach(function () {
|
50
|
-
|
43
|
+
beforeEach(async function () {
|
44
|
+
recorder = new Recorder(this.currentTest);
|
45
|
+
await recorder.start(recorderOptions);
|
46
|
+
client = new WebPubSubServiceClient(assertEnvironmentVariable("WPS_CONNECTION_STRING"), "simplechat", recorder.configureClientOptions({}));
|
47
|
+
});
|
48
|
+
afterEach(async function () {
|
49
|
+
await recorder.stop();
|
51
50
|
});
|
52
51
|
it("can broadcast", async () => {
|
53
52
|
await client.sendToAll("hello", { contentType: "text/plain", onResponse });
|
@@ -59,7 +58,7 @@ describe("HubClient", function () {
|
|
59
58
|
assert.equal(lastResponse === null || lastResponse === void 0 ? void 0 : lastResponse.status, 202);
|
60
59
|
});
|
61
60
|
it("can broadcast using the DAC", async () => {
|
62
|
-
const dacClient = new WebPubSubServiceClient(
|
61
|
+
const dacClient = new WebPubSubServiceClient(assertEnvironmentVariable("WPS_ENDPOINT"), credential, "simplechat", recorder.configureClientOptions({}));
|
63
62
|
await dacClient.sendToAll("hello", { contentType: "text/plain", onResponse });
|
64
63
|
assert.equal(lastResponse === null || lastResponse === void 0 ? void 0 : lastResponse.status, 202);
|
65
64
|
await dacClient.sendToAll({ x: 1, y: 2 }, { onResponse });
|
@@ -69,9 +68,9 @@ describe("HubClient", function () {
|
|
69
68
|
assert.equal(lastResponse === null || lastResponse === void 0 ? void 0 : lastResponse.status, 202);
|
70
69
|
});
|
71
70
|
it("can broadcast using APIM", async () => {
|
72
|
-
const apimClient = new WebPubSubServiceClient(
|
73
|
-
reverseProxyEndpoint:
|
74
|
-
});
|
71
|
+
const apimClient = new WebPubSubServiceClient(assertEnvironmentVariable("WPS_CONNECTION_STRING"), "simplechat", recorder.configureClientOptions({
|
72
|
+
reverseProxyEndpoint: assertEnvironmentVariable("WPS_REVERSE_PROXY_ENDPOINT"),
|
73
|
+
}));
|
75
74
|
await apimClient.sendToAll("hello", { contentType: "text/plain", onResponse });
|
76
75
|
assert.equal(lastResponse === null || lastResponse === void 0 ? void 0 : lastResponse.status, 202);
|
77
76
|
await apimClient.sendToAll({ x: 1, y: 2 }, { onResponse });
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"hubs.spec.js","sourceRoot":"","sources":["../../test/hubs.spec.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAClC,oCAAoC;AACpC,OAAO,EAAE,GAAG,EAAY,MAAM,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AAC/E,OAAO,EAAE,sBAAsB,EAAE,kBAAkB,EAAE,MAAM,QAAQ,CAAC;AACpE,OAAO,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAC9B,OAAO,gBAAgB,MAAM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env, Recorder, record, isLiveMode } from \"@azure-tools/test-recorder\";\nimport { WebPubSubServiceClient, AzureKeyCredential } from \"../src\";\nimport { assert } from \"chai\";\nimport environmentSetup from \"./testEnv\";\nimport { FullOperationResponse } from \"@azure/core-client\";\nimport { DefaultAzureCredential } from \"@azure/identity\";\n/* eslint-disable @typescript-eslint/no-invalid-this */\n\ndescribe(\"HubClient\", function () {\n let recorder: Recorder;\n beforeEach(function () {\n recorder = record(this, environmentSetup);\n });\n\n afterEach(async function () {\n if (recorder) {\n await recorder.stop();\n }\n });\n\n describe(\"Constructing a HubClient\", () => {\n it(\"takes a connection string, hub name, and options\", () => {\n assert.doesNotThrow(() => {\n new WebPubSubServiceClient(env.WPS_CONNECTION_STRING, \"test-hub\", {\n retryOptions: { maxRetries: 2 },\n });\n });\n });\n\n it(\"takes an endpoint, an API key, a hub name, and options\", () => {\n assert.doesNotThrow(() => {\n new WebPubSubServiceClient(\n env.WPS_ENDPOINT,\n new AzureKeyCredential(env.WPS_API_KEY),\n \"test-hub\",\n {\n retryOptions: { maxRetries: 2 },\n }\n );\n });\n });\n\n it(\"takes an endpoint, DefaultAzureCredential, a hub name, and options\", () => {\n assert.doesNotThrow(() => {\n new WebPubSubServiceClient(env.WPS_ENDPOINT, new DefaultAzureCredential(), \"test-hub\", {\n retryOptions: { maxRetries: 2 },\n });\n });\n });\n });\n\n describe(\"Working with a hub\", function () {\n let client: WebPubSubServiceClient;\n let lastResponse: FullOperationResponse | undefined;\n function onResponse(response: FullOperationResponse) {\n lastResponse = response;\n }\n beforeEach(function () {\n client = new WebPubSubServiceClient(env.WPS_CONNECTION_STRING, \"simplechat\");\n });\n\n it(\"can broadcast\", async () => {\n await client.sendToAll(\"hello\", { contentType: \"text/plain\", onResponse });\n assert.equal(lastResponse?.status, 202);\n\n await client.sendToAll({ x: 1, y: 2 }, { onResponse });\n assert.equal(lastResponse?.status, 202);\n\n const binaryMessage = new Uint8Array(10);\n await client.sendToAll(binaryMessage.buffer, { onResponse });\n assert.equal(lastResponse?.status, 202);\n });\n\n it(\"can broadcast using the DAC\", async () => {\n const dacClient = new WebPubSubServiceClient(\n env.WPS_ENDPOINT,\n new DefaultAzureCredential(),\n \"simplechat\"\n );\n\n await dacClient.sendToAll(\"hello\", { contentType: \"text/plain\", onResponse });\n assert.equal(lastResponse?.status, 202);\n\n await dacClient.sendToAll({ x: 1, y: 2 }, { onResponse });\n assert.equal(lastResponse?.status, 202);\n\n const binaryMessage = new Uint8Array(10);\n await dacClient.sendToAll(binaryMessage.buffer, { onResponse });\n assert.equal(lastResponse?.status, 202);\n });\n\n it(\"can broadcast using APIM\", async () => {\n const apimClient = new WebPubSubServiceClient(env.WPS_CONNECTION_STRING, \"simplechat\", {\n reverseProxyEndpoint: env.WPS_REVERSE_PROXY_ENDPOINT,\n });\n\n await apimClient.sendToAll(\"hello\", { contentType: \"text/plain\", onResponse });\n assert.equal(lastResponse?.status, 202);\n\n await apimClient.sendToAll({ x: 1, y: 2 }, { onResponse });\n assert.equal(lastResponse?.status, 202);\n\n const binaryMessage = new Uint8Array(10);\n await apimClient.sendToAll(binaryMessage.buffer, { onResponse });\n assert.equal(lastResponse?.status, 202);\n });\n\n it(\"can send messages to a user\", async () => {\n await client.sendToUser(\"brian\", \"hello\", {\n contentType: \"text/plain\",\n onResponse,\n });\n assert.equal(lastResponse?.status, 202);\n\n await client.sendToUser(\"brian\", { x: 1, y: 2 }, { onResponse });\n assert.equal(lastResponse?.status, 202);\n\n const binaryMessage = new Uint8Array(10);\n await client.sendToUser(\"brian\", binaryMessage.buffer, { onResponse });\n assert.equal(lastResponse?.status, 202);\n });\n\n it(\"can send messages to a connection\", async () => {\n await client.sendToConnection(\"xxxx\", \"hello\", { contentType: \"text/plain\", onResponse });\n assert.equal(lastResponse?.status, 202);\n\n await client.sendToConnection(\"xxxx\", { x: 1, y: 2 }, { onResponse });\n assert.equal(lastResponse?.status, 202);\n const binaryMessage = new Uint8Array(10);\n\n await client.sendToConnection(\"xxxx\", binaryMessage.buffer, { onResponse });\n assert.equal(lastResponse?.status, 202);\n });\n\n // `removeUserFromAllGroups` always times out.\n it.skip(\"can manage users\", async () => {\n this.timeout(Infinity);\n const res = await client.userExists(\"foo\");\n assert.ok(!res);\n await client.removeUserFromAllGroups(\"brian\", { onResponse });\n assert.equal(lastResponse?.status, 200);\n });\n\n it(\"can check if a connection exists\", async function () {\n // likely bug in recorder for this test - recording not generating properly\n if (!isLiveMode()) this.skip();\n const res = await client.connectionExists(\"xxx\");\n assert.ok(!res);\n });\n\n it(\"can grant permissions to connections\", async () => {\n let error;\n try {\n await client.grantPermission(\"xxx\", \"joinLeaveGroup\", { targetName: \"x\" });\n } catch (e) {\n error = e;\n }\n // grantPermission validates connection ids, so we expect an error here.\n assert.equal(error.statusCode, 404);\n });\n\n it(\"can revoke permissions from connections\", async function () {\n // likely bug in recorder for this test - recording not generating properly\n if (!isLiveMode()) this.skip();\n await client.revokePermission(\"invalid-id\", \"joinLeaveGroup\", { targetName: \"x\" });\n // Service doesn't throw error for invalid connection-ids\n });\n\n // service API doesn't work yet.\n it.skip(\"can generate client tokens\", async () => {\n await client.getClientAccessToken({\n userId: \"brian\",\n });\n });\n });\n});\n"]}
|
1
|
+
{"version":3,"file":"hubs.spec.js","sourceRoot":"","sources":["../../test/hubs.spec.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAClC,oCAAoC;AACpC,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,yBAAyB,EAAE,MAAM,4BAA4B,CAAC;AAC7F,OAAO,EAAE,sBAAsB,EAAE,kBAAkB,EAAE,MAAM,QAAQ,CAAC;AACpE,OAAO,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAC9B,OAAO,eAAe,MAAM,WAAW,CAAC;AAExC,OAAO,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AACpE,uDAAuD;AAEvD,QAAQ,CAAC,WAAW,EAAE;IACpB,QAAQ,CAAC,0BAA0B,EAAE,GA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ACL,CAAC,CAAC,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n/* eslint-disable no-invalid-this */\nimport { Recorder, isLiveMode, assertEnvironmentVariable } from \"@azure-tools/test-recorder\";\nimport { WebPubSubServiceClient, AzureKeyCredential } from \"../src\";\nimport { assert } from \"chai\";\nimport recorderOptions from \"./testEnv\";\nimport { FullOperationResponse } from \"@azure/core-client\";\nimport { createTestCredential } from \"@azure-tools/test-credential\";\n/* eslint-disable @typescript-eslint/no-invalid-this */\n\ndescribe(\"HubClient\", function () {\n describe(\"Constructing a HubClient\", () => {\n const credential = createTestCredential();\n it(\"takes a connection string, hub name, and options\", () => {\n assert.doesNotThrow(() => {\n new WebPubSubServiceClient(assertEnvironmentVariable(\"WPS_CONNECTION_STRING\"), \"test-hub\", {\n retryOptions: { maxRetries: 2 },\n });\n });\n });\n\n it(\"takes an endpoint, an API key, a hub name, and options\", () => {\n assert.doesNotThrow(() => {\n new WebPubSubServiceClient(\n assertEnvironmentVariable(\"WPS_ENDPOINT\"),\n new AzureKeyCredential(assertEnvironmentVariable(\"WPS_API_KEY\")),\n \"test-hub\",\n {\n retryOptions: { maxRetries: 2 },\n }\n );\n });\n });\n\n it(\"takes an endpoint, DefaultAzureCredential, a hub name, and options\", () => {\n assert.doesNotThrow(() => {\n new WebPubSubServiceClient(\n assertEnvironmentVariable(\"WPS_ENDPOINT\"),\n credential,\n \"test-hub\",\n {\n retryOptions: { maxRetries: 2 },\n }\n );\n });\n });\n });\n\n describe(\"Working with a hub\", function () {\n let recorder: Recorder;\n let client: WebPubSubServiceClient;\n let lastResponse: FullOperationResponse | undefined;\n const credential = createTestCredential();\n function onResponse(response: FullOperationResponse) {\n lastResponse = response;\n }\n beforeEach(async function () {\n recorder = new Recorder(this.currentTest);\n await recorder.start(recorderOptions);\n\n client = new WebPubSubServiceClient(\n assertEnvironmentVariable(\"WPS_CONNECTION_STRING\"),\n \"simplechat\",\n recorder.configureClientOptions({})\n );\n });\n\n afterEach(async function () {\n await recorder.stop();\n });\n\n it(\"can broadcast\", async () => {\n await client.sendToAll(\"hello\", { contentType: \"text/plain\", onResponse });\n assert.equal(lastResponse?.status, 202);\n\n await client.sendToAll({ x: 1, y: 2 }, { onResponse });\n assert.equal(lastResponse?.status, 202);\n\n const binaryMessage = new Uint8Array(10);\n await client.sendToAll(binaryMessage.buffer, { onResponse });\n assert.equal(lastResponse?.status, 202);\n });\n\n it(\"can broadcast using the DAC\", async () => {\n const dacClient = new WebPubSubServiceClient(\n assertEnvironmentVariable(\"WPS_ENDPOINT\"),\n credential,\n \"simplechat\",\n recorder.configureClientOptions({})\n );\n\n await dacClient.sendToAll(\"hello\", { contentType: \"text/plain\", onResponse });\n assert.equal(lastResponse?.status, 202);\n\n await dacClient.sendToAll({ x: 1, y: 2 }, { onResponse });\n assert.equal(lastResponse?.status, 202);\n\n const binaryMessage = new Uint8Array(10);\n await dacClient.sendToAll(binaryMessage.buffer, { onResponse });\n assert.equal(lastResponse?.status, 202);\n });\n\n it(\"can broadcast using APIM\", async () => {\n const apimClient = new WebPubSubServiceClient(\n assertEnvironmentVariable(\"WPS_CONNECTION_STRING\"),\n \"simplechat\",\n recorder.configureClientOptions({\n reverseProxyEndpoint: assertEnvironmentVariable(\"WPS_REVERSE_PROXY_ENDPOINT\"),\n })\n );\n\n await apimClient.sendToAll(\"hello\", { contentType: \"text/plain\", onResponse });\n assert.equal(lastResponse?.status, 202);\n\n await apimClient.sendToAll({ x: 1, y: 2 }, { onResponse });\n assert.equal(lastResponse?.status, 202);\n\n const binaryMessage = new Uint8Array(10);\n await apimClient.sendToAll(binaryMessage.buffer, { onResponse });\n assert.equal(lastResponse?.status, 202);\n });\n\n it(\"can send messages to a user\", async () => {\n await client.sendToUser(\"brian\", \"hello\", {\n contentType: \"text/plain\",\n onResponse,\n });\n assert.equal(lastResponse?.status, 202);\n\n await client.sendToUser(\"brian\", { x: 1, y: 2 }, { onResponse });\n assert.equal(lastResponse?.status, 202);\n\n const binaryMessage = new Uint8Array(10);\n await client.sendToUser(\"brian\", binaryMessage.buffer, { onResponse });\n assert.equal(lastResponse?.status, 202);\n });\n\n it(\"can send messages to a connection\", async () => {\n await client.sendToConnection(\"xxxx\", \"hello\", { contentType: \"text/plain\", onResponse });\n assert.equal(lastResponse?.status, 202);\n\n await client.sendToConnection(\"xxxx\", { x: 1, y: 2 }, { onResponse });\n assert.equal(lastResponse?.status, 202);\n const binaryMessage = new Uint8Array(10);\n\n await client.sendToConnection(\"xxxx\", binaryMessage.buffer, { onResponse });\n assert.equal(lastResponse?.status, 202);\n });\n\n // `removeUserFromAllGroups` always times out.\n it.skip(\"can manage users\", async () => {\n this.timeout(Infinity);\n const res = await client.userExists(\"foo\");\n assert.ok(!res);\n await client.removeUserFromAllGroups(\"brian\", { onResponse });\n assert.equal(lastResponse?.status, 200);\n });\n\n it(\"can check if a connection exists\", async function () {\n // likely bug in recorder for this test - recording not generating properly\n if (!isLiveMode()) this.skip();\n const res = await client.connectionExists(\"xxx\");\n assert.ok(!res);\n });\n\n it(\"can grant permissions to connections\", async () => {\n let error;\n try {\n await client.grantPermission(\"xxx\", \"joinLeaveGroup\", { targetName: \"x\" });\n } catch (e) {\n error = e;\n }\n // grantPermission validates connection ids, so we expect an error here.\n assert.equal(error.statusCode, 404);\n });\n\n it(\"can revoke permissions from connections\", async function () {\n // likely bug in recorder for this test - recording not generating properly\n if (!isLiveMode()) this.skip();\n await client.revokePermission(\"invalid-id\", \"joinLeaveGroup\", { targetName: \"x\" });\n // Service doesn't throw error for invalid connection-ids\n });\n\n // service API doesn't work yet.\n it.skip(\"can generate client tokens\", async () => {\n await client.getClientAccessToken({\n userId: \"brian\",\n });\n });\n });\n});\n"]}
|
@@ -2,7 +2,7 @@
|
|
2
2
|
// Licensed under the MIT license.
|
3
3
|
/* eslint-disable no-invalid-this */
|
4
4
|
import { WebPubSubServiceClient } from "../src/index";
|
5
|
-
import {
|
5
|
+
import { isLiveMode, assertEnvironmentVariable } from "@azure-tools/test-recorder";
|
6
6
|
import { assert } from "chai";
|
7
7
|
import ws from "ws";
|
8
8
|
function defer() {
|
@@ -77,7 +77,7 @@ describe("ServiceClient to manage the connected WebSocket connections", function
|
|
77
77
|
const hub = "SimpleClientCanReceiveMessage";
|
78
78
|
const messages = [];
|
79
79
|
// Get token
|
80
|
-
const serviceClient = new WebPubSubServiceClient(
|
80
|
+
const serviceClient = new WebPubSubServiceClient(assertEnvironmentVariable("WPS_CONNECTION_STRING"), hub);
|
81
81
|
const token = await serviceClient.getClientAccessToken();
|
82
82
|
const endSignal = defer();
|
83
83
|
// Start simple WebSocket connections
|
@@ -113,7 +113,7 @@ describe("ServiceClient to manage the connected WebSocket connections", function
|
|
113
113
|
const hub = "PubSubClientCanReceiveMessage";
|
114
114
|
const messages = [];
|
115
115
|
// Get token
|
116
|
-
const serviceClient = new WebPubSubServiceClient(
|
116
|
+
const serviceClient = new WebPubSubServiceClient(assertEnvironmentVariable("WPS_CONNECTION_STRING"), hub);
|
117
117
|
const token = await serviceClient.getClientAccessToken();
|
118
118
|
const endSignal = defer();
|
119
119
|
const connectedSignal = defer();
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"integration.spec.js","sourceRoot":"","sources":["../../test/integration.spec.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAClC,oCAAoC;AACpC,OAAO,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAC;AACtD,OAAO,EAAE,GAAG,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AAE7D,OAAO,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAC9B,OAAO,EAAE,MAAM,IAAI,CAAC;AAEpB,SAAS,KAAK;IAKZ,IAAI,aAA6B,CAAC;IAClC,IAAI,YAAkC,CAAC;IAEvC,MAAM,OAAO,GAAG,IAAI,OAAO,CAAI,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACjD,aAAa,GAAG,OAAO,CAAC;QACxB,YAAY,G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M,EAAE,CAAC,CAAC,CAAC;QACjC,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,WAAW,CAAC,CAAC;QACrD,MAAM,CAAC,KAAK,CACV,QAAQ,CAAC,CAAC,CAAC,CAAC,YAAY,EACxB,wFAAwF,CACzF,CAAC;QACF,MAAM,CAAC,KAAK,CACV,QAAQ,CAAC,CAAC,CAAC,CAAC,YAAY,EACxB,yEAAyE,CAC1E,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n/* eslint-disable no-invalid-this */\nimport { WebPubSubServiceClient } from \"../src/index\";\nimport { env, isLiveMode } from \"@azure-tools/test-recorder\";\nimport { Context } from \"mocha\";\nimport { assert } from \"chai\";\nimport ws from \"ws\";\n\nfunction defer<T>(): {\n promise: Promise<T>;\n resolve: (t: T) => void;\n reject: (err: Error) => void;\n} {\n let actualResolve: (t: T) => void;\n let actualReject: (err: Error) => void;\n\n const promise = new Promise<T>((resolve, reject) => {\n actualResolve = resolve;\n actualReject = reject;\n });\n\n return {\n promise,\n resolve: actualResolve!,\n reject: actualReject!,\n };\n}\n\nclass SimpleWebSocketFrame {\n public dataAsString: string | undefined;\n constructor(public data: Buffer | ArrayBuffer | Buffer[], public isBinary: boolean) {\n if (!isBinary) {\n this.dataAsString = data.toString();\n }\n }\n\n isEndSignal(): boolean {\n return (\n this.isBinary &&\n this.data instanceof Buffer &&\n this.data[0] === 5 &&\n this.data[1] === 1 &&\n this.data[2] === 1\n );\n }\n\n toString(): string | undefined {\n if (this.isEndSignal()) {\n return \"|EndSignal|\";\n }\n if (!this.isBinary) {\n return this.dataAsString;\n } else {\n return this.data.toString();\n }\n }\n}\n\nclass PubSubWebSocketFrame {\n public message: any;\n public dataAsString: string;\n constructor(data: Buffer | ArrayBuffer | Buffer[], isBinary: boolean) {\n assert.isFalse(isBinary);\n this.dataAsString = data.toString();\n this.message = JSON.parse(this.dataAsString);\n }\n\n isEndSignal(): boolean {\n return this.message.dataType === \"binary\" && this.message.data === \"BQEB\";\n }\n\n toString(): string | undefined {\n if (this.isEndSignal()) {\n return \"|EndSignal|\";\n }\n\n return this.dataAsString;\n }\n}\n\nfunction getEndSignal(): Uint8Array {\n // magic number 511\n const payload = new Uint8Array(3);\n payload[0] = 5;\n payload[1] = 1;\n payload[2] = 1;\n return payload;\n}\n\ndescribe(\"ServiceClient to manage the connected WebSocket connections\", function () {\n // Issue - https://github.com/Azure/azure-sdk-for-js/issues/20571 waiting for service fix\n it.skip(\"Simple clients can receive expected messages with different content types\", async function (this: Context) {\n if (!isLiveMode()) this.skip();\n const hub = \"SimpleClientCanReceiveMessage\";\n\n const messages: SimpleWebSocketFrame[] = [];\n\n // Get token\n const serviceClient = new WebPubSubServiceClient(env.WPS_CONNECTION_STRING, hub);\n const token = await serviceClient.getClientAccessToken();\n const endSignal = defer<void>();\n // Start simple WebSocket connections\n const client = new ws.WebSocket(token.url);\n client.on(\"message\", (data, isBinary) => {\n const frame = new SimpleWebSocketFrame(data, isBinary);\n console.log(frame.toString());\n if (frame.isEndSignal()) {\n endSignal.resolve();\n client.close();\n } else {\n messages.push(frame);\n }\n });\n client.on(\"open\", async () => {\n // send to all\n // Send a JSON message\n await serviceClient.sendToAll({ message: \"Hello world!\" });\n\n // Send a plain text message\n await serviceClient.sendToAll(\"Hi there!\", { contentType: \"text/plain\" });\n\n // Send the binary end signal message\n await serviceClient.sendToAll(getEndSignal());\n });\n\n await endSignal.promise;\n\n assert.equal(messages.length, 2);\n assert.equal(messages[0].dataAsString, '{\"message\":\"Hello world!\"}');\n assert.equal(messages[1].dataAsString, \"Hi there!\");\n });\n\n it(\"Subprotocol clients can receive expected messages with different content types\", async function (this: Context) {\n if (!isLiveMode()) this.skip();\n const hub = \"PubSubClientCanReceiveMessage\";\n const messages: PubSubWebSocketFrame[] = [];\n\n // Get token\n const serviceClient = new WebPubSubServiceClient(env.WPS_CONNECTION_STRING, hub);\n const token = await serviceClient.getClientAccessToken();\n const endSignal = defer<void>();\n const connectedSignal = defer<void>();\n // Start simple WebSocket connections\n const client = new ws.WebSocket(token.url, \"json.webpubsub.azure.v1\");\n client.on(\"message\", (data, isBinary) => {\n const frame = new PubSubWebSocketFrame(data, isBinary);\n console.log(frame.toString());\n if (frame.message.event === \"connected\") {\n connectedSignal.resolve();\n }\n if (frame.isEndSignal()) {\n endSignal.resolve();\n client.close();\n } else {\n messages.push(frame);\n }\n });\n client.on(\"open\", async () => {\n await connectedSignal.promise;\n\n // send to all\n // Send a JSON message\n await serviceClient.sendToAll({ message: \"Hello world!\" });\n\n // Send a plain text message\n await serviceClient.sendToAll(\"Hi there!\", { contentType: \"text/plain\" });\n\n // Send the binary end signal message\n await serviceClient.sendToAll(getEndSignal());\n });\n\n await endSignal.promise;\n\n assert.equal(messages.length, 3);\n assert.equal(messages[0].message.event, \"connected\");\n assert.equal(\n messages[1].dataAsString,\n '{\"type\":\"message\",\"from\":\"server\",\"dataType\":\"json\",\"data\":{\"message\":\"Hello world!\"}}'\n );\n assert.equal(\n messages[2].dataAsString,\n '{\"type\":\"message\",\"from\":\"server\",\"dataType\":\"text\",\"data\":\"Hi there!\"}'\n );\n });\n});\n"]}
|
1
|
+
{"version":3,"file":"integration.spec.js","sourceRoot":"","sources":["../../test/integration.spec.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAClC,oCAAoC;AACpC,OAAO,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAC;AACtD,OAAO,EAAE,UAAU,EAAE,yBAAyB,EAAE,MAAM,4BAA4B,CAAC;AAEnF,OAAO,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAC9B,OAAO,EAAE,MAAM,IAAI,CAAC;AAEpB,SAAS,KAAK;IAKZ,IAAI,aAA6B,CAAC;IAClC,IAAI,YAAkC,CAAC;IAEvC,MAAM,OAAO,GAAG,IAAI,OA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AChD,CAAC,CAAC,CAAC;QAEH,MAAM,SAAS,CAAC,OAAO,CAAC;QAExB,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;QACjC,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,WAAW,CAAC,CAAC;QACrD,MAAM,CAAC,KAAK,CACV,QAAQ,CAAC,CAAC,CAAC,CAAC,YAAY,EACxB,wFAAwF,CACzF,CAAC;QACF,MAAM,CAAC,KAAK,CACV,QAAQ,CAAC,CAAC,CAAC,CAAC,YAAY,EACxB,yEAAyE,CAC1E,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n/* eslint-disable no-invalid-this */\nimport { WebPubSubServiceClient } from \"../src/index\";\nimport { isLiveMode, assertEnvironmentVariable } from \"@azure-tools/test-recorder\";\nimport { Context } from \"mocha\";\nimport { assert } from \"chai\";\nimport ws from \"ws\";\n\nfunction defer<T>(): {\n promise: Promise<T>;\n resolve: (t: T) => void;\n reject: (err: Error) => void;\n} {\n let actualResolve: (t: T) => void;\n let actualReject: (err: Error) => void;\n\n const promise = new Promise<T>((resolve, reject) => {\n actualResolve = resolve;\n actualReject = reject;\n });\n\n return {\n promise,\n resolve: actualResolve!,\n reject: actualReject!,\n };\n}\n\nclass SimpleWebSocketFrame {\n public dataAsString: string | undefined;\n constructor(public data: Buffer | ArrayBuffer | Buffer[], public isBinary: boolean) {\n if (!isBinary) {\n this.dataAsString = data.toString();\n }\n }\n\n isEndSignal(): boolean {\n return (\n this.isBinary &&\n this.data instanceof Buffer &&\n this.data[0] === 5 &&\n this.data[1] === 1 &&\n this.data[2] === 1\n );\n }\n\n toString(): string | undefined {\n if (this.isEndSignal()) {\n return \"|EndSignal|\";\n }\n if (!this.isBinary) {\n return this.dataAsString;\n } else {\n return this.data.toString();\n }\n }\n}\n\nclass PubSubWebSocketFrame {\n public message: any;\n public dataAsString: string;\n constructor(data: Buffer | ArrayBuffer | Buffer[], isBinary: boolean) {\n assert.isFalse(isBinary);\n this.dataAsString = data.toString();\n this.message = JSON.parse(this.dataAsString);\n }\n\n isEndSignal(): boolean {\n return this.message.dataType === \"binary\" && this.message.data === \"BQEB\";\n }\n\n toString(): string | undefined {\n if (this.isEndSignal()) {\n return \"|EndSignal|\";\n }\n\n return this.dataAsString;\n }\n}\n\nfunction getEndSignal(): Uint8Array {\n // magic number 511\n const payload = new Uint8Array(3);\n payload[0] = 5;\n payload[1] = 1;\n payload[2] = 1;\n return payload;\n}\n\ndescribe(\"ServiceClient to manage the connected WebSocket connections\", function () {\n // Issue - https://github.com/Azure/azure-sdk-for-js/issues/20571 waiting for service fix\n it.skip(\"Simple clients can receive expected messages with different content types\", async function (this: Context) {\n if (!isLiveMode()) this.skip();\n const hub = \"SimpleClientCanReceiveMessage\";\n\n const messages: SimpleWebSocketFrame[] = [];\n\n // Get token\n const serviceClient = new WebPubSubServiceClient(\n assertEnvironmentVariable(\"WPS_CONNECTION_STRING\"),\n hub\n );\n const token = await serviceClient.getClientAccessToken();\n const endSignal = defer<void>();\n // Start simple WebSocket connections\n const client = new ws.WebSocket(token.url);\n client.on(\"message\", (data, isBinary) => {\n const frame = new SimpleWebSocketFrame(data, isBinary);\n console.log(frame.toString());\n if (frame.isEndSignal()) {\n endSignal.resolve();\n client.close();\n } else {\n messages.push(frame);\n }\n });\n client.on(\"open\", async () => {\n // send to all\n // Send a JSON message\n await serviceClient.sendToAll({ message: \"Hello world!\" });\n\n // Send a plain text message\n await serviceClient.sendToAll(\"Hi there!\", { contentType: \"text/plain\" });\n\n // Send the binary end signal message\n await serviceClient.sendToAll(getEndSignal());\n });\n\n await endSignal.promise;\n\n assert.equal(messages.length, 2);\n assert.equal(messages[0].dataAsString, '{\"message\":\"Hello world!\"}');\n assert.equal(messages[1].dataAsString, \"Hi there!\");\n });\n\n it(\"Subprotocol clients can receive expected messages with different content types\", async function (this: Context) {\n if (!isLiveMode()) this.skip();\n const hub = \"PubSubClientCanReceiveMessage\";\n const messages: PubSubWebSocketFrame[] = [];\n\n // Get token\n const serviceClient = new WebPubSubServiceClient(\n assertEnvironmentVariable(\"WPS_CONNECTION_STRING\"),\n hub\n );\n const token = await serviceClient.getClientAccessToken();\n const endSignal = defer<void>();\n const connectedSignal = defer<void>();\n // Start simple WebSocket connections\n const client = new ws.WebSocket(token.url, \"json.webpubsub.azure.v1\");\n client.on(\"message\", (data, isBinary) => {\n const frame = new PubSubWebSocketFrame(data, isBinary);\n console.log(frame.toString());\n if (frame.message.event === \"connected\") {\n connectedSignal.resolve();\n }\n if (frame.isEndSignal()) {\n endSignal.resolve();\n client.close();\n } else {\n messages.push(frame);\n }\n });\n client.on(\"open\", async () => {\n await connectedSignal.promise;\n\n // send to all\n // Send a JSON message\n await serviceClient.sendToAll({ message: \"Hello world!\" });\n\n // Send a plain text message\n await serviceClient.sendToAll(\"Hi there!\", { contentType: \"text/plain\" });\n\n // Send the binary end signal message\n await serviceClient.sendToAll(getEndSignal());\n });\n\n await endSignal.promise;\n\n assert.equal(messages.length, 3);\n assert.equal(messages[0].message.event, \"connected\");\n assert.equal(\n messages[1].dataAsString,\n '{\"type\":\"message\",\"from\":\"server\",\"dataType\":\"json\",\"data\":{\"message\":\"Hello world!\"}}'\n );\n assert.equal(\n messages[2].dataAsString,\n '{\"type\":\"message\",\"from\":\"server\",\"dataType\":\"text\",\"data\":\"Hi there!\"}'\n );\n });\n});\n"]}
|
package/dist-esm/test/testEnv.js
CHANGED
@@ -1,15 +1,16 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
customizationsOnRecordings: [],
|
12
|
-
queryParametersToSkip: [],
|
1
|
+
// Copyright (c) Microsoft Corporation.
|
2
|
+
// Licensed under the MIT license.
|
3
|
+
const envSetupForPlayback = {
|
4
|
+
WPS_CONNECTION_STRING: "Endpoint=endpoint;AccessKey=api_key;Version=1.0;",
|
5
|
+
WPS_API_KEY: "api_key",
|
6
|
+
WPS_ENDPOINT: "https://endpoint",
|
7
|
+
WPS_REVERSE_PROXY_ENDPOINT: "https://rp-endpoint",
|
8
|
+
AZURE_CLIENT_ID: "azure_client_id",
|
9
|
+
AZURE_CLIENT_SECRET: "azure_client_secret",
|
10
|
+
AZURE_TENANT_ID: "azuretenantid",
|
13
11
|
};
|
14
|
-
|
12
|
+
const recorderOptions = {
|
13
|
+
envSetupForPlayback,
|
14
|
+
};
|
15
|
+
export default recorderOptions;
|
15
16
|
//# sourceMappingURL=testEnv.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"testEnv.js","sourceRoot":"","sources":["../../test/testEnv.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"testEnv.js","sourceRoot":"","sources":["../../test/testEnv.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAIlC,MAAM,mBAAmB,GAA2B;IAClD,qBAAqB,EAAE,kDAAkD;IACzE,WAAW,EAAE,SAAS;IACtB,YAAY,EAAE,kBAAkB;IAChC,0BAA0B,EAAE,qBAAqB;IACjD,eAAe,EAAE,iBAAiB;IAClC,mBAAmB,EAAE,qBAAqB;IAC1C,eAAe,EAAE,eAAe;CACjC,CAAC;AAEF,MAAM,eAAe,GAAyB;IAC5C,mBAAmB;CACpB,CAAC;AAEF,eAAe,eAAe,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { RecorderStartOptions } from \"@azure-tools/test-recorder\";\n\nconst envSetupForPlayback: Record<string, string> = {\n WPS_CONNECTION_STRING: \"Endpoint=endpoint;AccessKey=api_key;Version=1.0;\",\n WPS_API_KEY: \"api_key\",\n WPS_ENDPOINT: \"https://endpoint\",\n WPS_REVERSE_PROXY_ENDPOINT: \"https://rp-endpoint\",\n AZURE_CLIENT_ID: \"azure_client_id\",\n AZURE_CLIENT_SECRET: \"azure_client_secret\",\n AZURE_TENANT_ID: \"azuretenantid\",\n};\n\nconst recorderOptions: RecorderStartOptions = {\n envSetupForPlayback,\n};\n\nexport default recorderOptions;\n"]}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@azure/web-pubsub",
|
3
|
-
"version": "1.0.1-alpha.
|
3
|
+
"version": "1.0.1-alpha.20220325.2",
|
4
4
|
"description": "Azure client library for Azure Web PubSub",
|
5
5
|
"sdk-type": "client",
|
6
6
|
"main": "dist/index.js",
|
@@ -20,7 +20,7 @@
|
|
20
20
|
"execute:samples": "dev-tool samples run samples-dev",
|
21
21
|
"extract-api": "tsc -p . && api-extractor run --local",
|
22
22
|
"integration-test:browser": "echo \"Browser is not supported.\" && exit 0",
|
23
|
-
"integration-test:node": "
|
23
|
+
"integration-test:node": "dev-tool run test:node-js-input -- --timeout 5000000 'dist-esm/test/**/*.spec.js'",
|
24
24
|
"integration-test": "npm run integration-test:node && npm run integration-test:browser",
|
25
25
|
"lint:fix": "eslint package.json api-extractor.json src test --ext .ts --fix --fix-type [problem,suggestion]",
|
26
26
|
"lint": "eslint package.json api-extractor.json src test --ext .ts",
|
@@ -29,7 +29,7 @@
|
|
29
29
|
"test:node": "npm run build:test && npm run unit-test:node && npm run integration-test:node",
|
30
30
|
"test": "npm run build:test && npm run unit-test && npm run integration-test",
|
31
31
|
"unit-test:browser": "echo \"Browser is not supported.\" && exit 0",
|
32
|
-
"unit-test:node": "
|
32
|
+
"unit-test:node": "dev-tool run test:node-ts-input -- --timeout 1200000 --exclude 'test/**/browser/*.spec.ts' 'test/**/*.spec.ts'",
|
33
33
|
"unit-test": "npm run unit-test:node && npm run unit-test:browser"
|
34
34
|
},
|
35
35
|
"files": [
|
@@ -82,8 +82,8 @@
|
|
82
82
|
"devDependencies": {
|
83
83
|
"@azure/dev-tool": ">=1.0.0-alpha <1.0.0-alphb",
|
84
84
|
"@azure/eslint-plugin-azure-sdk": ">=3.0.0-alpha <3.0.0-alphb",
|
85
|
-
"@azure/
|
86
|
-
"@azure-tools/test-recorder": "
|
85
|
+
"@azure-tools/test-credential": ">=1.0.0-alpha <1.0.0-alphb",
|
86
|
+
"@azure-tools/test-recorder": ">=2.0.0-alpha <2.0.0-alphb",
|
87
87
|
"@microsoft/api-extractor": "^7.18.11",
|
88
88
|
"@types/chai": "^4.1.6",
|
89
89
|
"@types/jsonwebtoken": "~8.5.0",
|
@@ -103,8 +103,6 @@
|
|
103
103
|
"karma-env-preprocessor": "^0.1.1",
|
104
104
|
"karma-firefox-launcher": "^1.1.0",
|
105
105
|
"karma-ie-launcher": "^1.0.0",
|
106
|
-
"karma-json-preprocessor": "^0.3.3",
|
107
|
-
"karma-json-to-file-reporter": "^1.0.1",
|
108
106
|
"karma-junit-reporter": "^2.0.1",
|
109
107
|
"karma-mocha": "^2.0.1",
|
110
108
|
"karma-mocha-reporter": "^2.2.5",
|