wrangler 0.0.0-e178d6fb → 0.0.0-e1c2f5b9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +16 -2
- package/bin/wrangler.js +31 -11
- package/miniflare-dist/index.mjs +1340 -330
- package/package.json +40 -13
- package/src/__tests__/access.test.ts +25 -0
- package/src/__tests__/api-dev.test.ts +238 -0
- package/src/__tests__/api-devregistry.test.js +64 -0
- package/src/__tests__/api.test.ts +80 -0
- package/src/__tests__/configuration.test.ts +683 -470
- package/src/__tests__/d1.test.ts +123 -0
- package/src/__tests__/delete.test.ts +263 -0
- package/src/__tests__/deployments.test.ts +105 -0
- package/src/__tests__/dev.test.tsx +453 -70
- package/src/__tests__/dialogs.test.tsx +40 -0
- package/src/__tests__/generate.test.ts +235 -0
- package/src/__tests__/get-host-from-url.test.ts +16 -0
- package/src/__tests__/helpers/mock-auth-domain.ts +20 -0
- package/src/__tests__/helpers/mock-cfetch.ts +92 -26
- package/src/__tests__/helpers/mock-console.ts +11 -2
- package/src/__tests__/helpers/mock-dialogs.ts +1 -1
- package/src/__tests__/helpers/mock-get-zone-from-host.ts +8 -0
- package/src/__tests__/helpers/mock-known-routes.ts +7 -0
- package/src/__tests__/helpers/mock-kv.ts +1 -1
- package/src/__tests__/helpers/mock-oauth-flow.ts +74 -53
- package/src/__tests__/helpers/mock-process.ts +8 -13
- package/src/__tests__/helpers/msw/handlers/access.ts +13 -0
- package/src/__tests__/helpers/msw/handlers/deployments.ts +59 -0
- package/src/__tests__/helpers/msw/handlers/namespaces.ts +104 -0
- package/src/__tests__/helpers/msw/handlers/oauth.ts +31 -0
- package/src/__tests__/helpers/msw/handlers/r2.ts +80 -0
- package/src/__tests__/helpers/msw/handlers/script.ts +75 -0
- package/src/__tests__/helpers/msw/handlers/user.ts +63 -0
- package/src/__tests__/helpers/msw/handlers/zones.ts +22 -0
- package/src/__tests__/helpers/msw/index.ts +21 -0
- package/src/__tests__/helpers/worker-scripts/child-wrangler.toml +1 -0
- package/src/__tests__/helpers/worker-scripts/hello-world-worker.js +5 -0
- package/src/__tests__/helpers/worker-scripts/hello-world-wrangler.toml +1 -0
- package/src/__tests__/helpers/worker-scripts/parent-worker.js +8 -0
- package/src/__tests__/helpers/worker-scripts/parent-wrangler.toml +5 -0
- package/src/__tests__/index.test.ts +103 -97
- package/src/__tests__/init.test.ts +1484 -382
- package/src/__tests__/jest.setup.ts +88 -5
- package/src/__tests__/kv.test.ts +655 -540
- package/src/__tests__/logout.test.ts +47 -0
- package/src/__tests__/metrics.test.ts +95 -45
- package/src/__tests__/middleware.scheduled.test.ts +145 -0
- package/src/__tests__/middleware.test.ts +750 -0
- package/src/__tests__/pages-deployment-tail.test.ts +884 -0
- package/src/__tests__/pages.test.ts +1301 -119
- package/src/__tests__/paths.test.ts +39 -0
- package/src/__tests__/publish.test.ts +2266 -1180
- package/src/__tests__/pubsub.test.ts +211 -88
- package/src/__tests__/queues.test.ts +522 -0
- package/src/__tests__/r2.test.ts +363 -203
- package/src/__tests__/secret.test.ts +261 -59
- package/src/__tests__/tail.test.ts +352 -151
- package/src/__tests__/test-old-node-version.js +3 -3
- package/src/__tests__/tsconfig-sanity.ts +12 -0
- package/src/__tests__/tsconfig.json +8 -0
- package/src/__tests__/tsconfig.tsbuildinfo +1 -0
- package/src/__tests__/type-generation.test.ts +233 -0
- package/src/__tests__/user.test.ts +59 -73
- package/src/__tests__/utils-collectKeyValues.test.ts +47 -0
- package/src/__tests__/validate-dev-props.test.ts +56 -0
- package/src/__tests__/whoami.test.tsx +114 -66
- package/src/__tests__/worker-namespace.test.ts +154 -155
- package/src/api/dev.ts +170 -38
- package/src/api/index.ts +1 -0
- package/src/bundle-reporter.tsx +41 -2
- package/src/bundle.ts +668 -81
- package/src/cfetch/index.ts +40 -3
- package/src/cfetch/internal.ts +144 -32
- package/src/cli.ts +4 -3
- package/src/config/config.ts +27 -3
- package/src/config/environment.ts +131 -7
- package/src/config/index.ts +128 -8
- package/src/config/validation-helpers.ts +19 -6
- package/src/config/validation.ts +411 -14
- package/src/config-cache.ts +3 -2
- package/src/create-worker-preview.ts +31 -6
- package/src/create-worker-upload-form.ts +84 -22
- package/src/d1/backups.tsx +223 -0
- package/src/d1/constants.ts +2 -0
- package/src/d1/create.tsx +63 -0
- package/src/d1/delete.tsx +56 -0
- package/src/d1/execute.tsx +352 -0
- package/src/d1/formatTimeAgo.ts +14 -0
- package/src/d1/index.ts +101 -0
- package/src/d1/list.tsx +48 -0
- package/src/d1/migrations/apply.tsx +196 -0
- package/src/d1/migrations/create.tsx +77 -0
- package/src/d1/migrations/helpers.ts +147 -0
- package/src/d1/migrations/index.tsx +3 -0
- package/src/d1/migrations/list.tsx +79 -0
- package/src/d1/migrations/options.ts +18 -0
- package/src/d1/options.ts +22 -0
- package/src/d1/types.tsx +24 -0
- package/src/d1/utils.ts +48 -0
- package/src/delete.ts +108 -0
- package/src/deployments.ts +83 -0
- package/src/deprecated/index.ts +145 -0
- package/src/dev/dev-vars.ts +11 -8
- package/src/dev/dev.tsx +220 -58
- package/src/dev/get-local-persistence-path.tsx +31 -0
- package/src/dev/local.tsx +740 -181
- package/src/dev/remote.tsx +340 -123
- package/src/dev/start-server.ts +543 -0
- package/src/dev/use-esbuild.ts +61 -7
- package/src/dev/validate-dev-props.ts +31 -0
- package/src/dev-registry.tsx +201 -0
- package/src/dev.tsx +614 -258
- package/src/dialogs.tsx +41 -8
- package/src/{worker-namespace.ts → dispatch-namespace.ts} +23 -22
- package/src/docs/index.ts +97 -0
- package/src/entry.ts +3 -2
- package/src/environment-variables/factory.ts +88 -0
- package/src/environment-variables/misc-variables.ts +30 -0
- package/src/generate/index.ts +300 -0
- package/src/git-client.ts +100 -7
- package/src/index.tsx +249 -1560
- package/src/init.ts +626 -150
- package/src/inspect.ts +137 -32
- package/src/{metrics/is-ci.ts → is-ci.ts} +0 -0
- package/src/is-interactive.ts +4 -0
- package/src/jest.d.ts +4 -0
- package/src/{kv.ts → kv/helpers.ts} +3 -3
- package/src/kv/index.ts +596 -0
- package/src/logger.ts +27 -8
- package/src/metrics/index.ts +1 -0
- package/src/metrics/metrics-config.ts +4 -4
- package/src/metrics/metrics-dispatcher.ts +1 -0
- package/src/metrics/metrics-usage-headers.ts +24 -0
- package/src/metrics/send-event.ts +13 -8
- package/src/miniflare-cli/assets.ts +172 -465
- package/src/miniflare-cli/index.ts +149 -24
- package/src/miniflare-cli/tsconfig.json +9 -0
- package/src/miniflare-cli/tsconfig.tsbuildinfo +1 -0
- package/src/miniflare-cli/types.ts +11 -0
- package/src/module-collection.ts +12 -3
- package/src/pages/build.tsx +108 -42
- package/src/pages/constants.ts +11 -0
- package/src/pages/deployment-tails.tsx +284 -0
- package/src/pages/deployments.tsx +9 -31
- package/src/pages/dev.tsx +417 -108
- package/src/pages/errors.ts +66 -0
- package/src/pages/functions/buildPlugin.ts +86 -84
- package/src/pages/functions/buildWorker.ts +121 -106
- package/src/pages/functions/routes-consolidation.test.ts +250 -0
- package/src/pages/functions/routes-consolidation.ts +73 -0
- package/src/pages/functions/routes-transformation.test.ts +282 -0
- package/src/pages/functions/routes-transformation.ts +115 -0
- package/src/pages/functions/routes-validation.test.ts +403 -0
- package/src/pages/functions/routes-validation.ts +202 -0
- package/src/pages/functions/tsconfig.json +8 -0
- package/src/pages/functions/tsconfig.tsbuildinfo +1 -0
- package/src/pages/functions.tsx +82 -0
- package/src/pages/hash.tsx +13 -0
- package/src/pages/index.tsx +73 -55
- package/src/pages/projects.tsx +9 -3
- package/src/pages/prompt-select-project.tsx +31 -0
- package/src/pages/publish.tsx +183 -60
- package/src/pages/types.ts +1 -0
- package/src/pages/upload.tsx +107 -56
- package/src/pages/utils.ts +13 -2
- package/src/paths.ts +49 -4
- package/src/proxy.ts +375 -157
- package/src/publish/index.ts +270 -0
- package/src/{publish.ts → publish/publish.ts} +431 -188
- package/src/pubsub/pubsub-commands.tsx +4 -3
- package/src/queues/cli/commands/consumer/add.ts +71 -0
- package/src/queues/cli/commands/consumer/index.ts +22 -0
- package/src/queues/cli/commands/consumer/remove.ts +38 -0
- package/src/queues/cli/commands/create.ts +25 -0
- package/src/queues/cli/commands/delete.ts +26 -0
- package/src/queues/cli/commands/index.ts +36 -0
- package/src/queues/cli/commands/list.ts +25 -0
- package/src/queues/client.ts +135 -0
- package/src/queues/utils.ts +18 -0
- package/src/r2/constants.ts +4 -0
- package/src/r2/helpers.ts +131 -0
- package/src/r2/index.ts +289 -0
- package/src/routes.ts +140 -0
- package/src/secret/index.ts +379 -0
- package/src/sites.tsx +3 -3
- package/src/tail/createTail.ts +379 -0
- package/src/tail/filters.ts +4 -6
- package/src/tail/index.ts +199 -284
- package/src/tail/printing.ts +43 -3
- package/src/tsconfig-sanity.ts +16 -0
- package/src/type-generation.ts +181 -0
- package/src/user/access.ts +68 -0
- package/src/user/auth-variables.ts +113 -0
- package/src/user/choose-account.tsx +1 -1
- package/src/user/index.ts +0 -1
- package/src/user/user.tsx +116 -49
- package/src/utils/collectKeyValues.ts +14 -0
- package/src/whoami.tsx +80 -2
- package/src/worker.ts +69 -9
- package/src/yargs-types.ts +24 -0
- package/src/zones.ts +124 -9
- package/templates/__tests__/pages-dev-util.test.ts +128 -0
- package/templates/__tests__/tsconfig-sanity.ts +12 -0
- package/templates/__tests__/tsconfig.json +8 -0
- package/templates/__tests__/tsconfig.tsbuildinfo +1 -0
- package/templates/d1-beta-facade.js +205 -0
- package/templates/facade.d.ts +14 -0
- package/templates/first-party-worker-module-facade.ts +19 -0
- package/templates/format-dev-errors.ts +33 -0
- package/templates/init-tests/test-jest-new-worker.js +23 -0
- package/templates/init-tests/test-vitest-new-worker.js +24 -0
- package/templates/init-tests/test-vitest-new-worker.ts +25 -0
- package/templates/middleware/common.ts +62 -0
- package/templates/middleware/loader-modules.ts +82 -0
- package/templates/middleware/loader-sw.ts +233 -0
- package/templates/middleware/middleware-miniflare3-json-error.ts +20 -0
- package/templates/middleware/middleware-pretty-error.ts +40 -0
- package/templates/middleware/middleware-scheduled.ts +15 -0
- package/templates/new-worker.js +1 -1
- package/templates/pages-dev-pipeline.ts +31 -0
- package/templates/pages-dev-util.ts +52 -0
- package/templates/pages-shim.ts +4 -1
- package/templates/pages-template-plugin.ts +21 -5
- package/templates/pages-template-worker.ts +37 -9
- package/templates/{static-asset-facade.js → serve-static-assets.ts} +23 -7
- package/templates/service-bindings-module-facade.js +54 -0
- package/templates/service-bindings-sw-facade.js +42 -0
- package/templates/tsconfig-sanity.ts +11 -0
- package/templates/tsconfig.init.json +106 -0
- package/templates/tsconfig.json +5 -102
- package/templates/tsconfig.tsbuildinfo +1 -0
- package/wrangler-dist/cli.d.ts +621 -42
- package/wrangler-dist/cli.js +144441 -102606
- package/src/environment-variables.ts +0 -35
- package/src/faye-websocket.d.ts +0 -6
- package/src/generate.ts +0 -33
- package/src/miniflare-cli/enum-keys.ts +0 -17
- package/src/preview.ts +0 -31
- package/src/r2.ts +0 -50
- package/src/user/env-vars.ts +0 -46
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import { rest } from "msw";
|
|
1
2
|
import { mockAccountId, mockApiToken } from "./helpers/mock-account-id";
|
|
2
|
-
import { setMockResponse, unsetAllMocks } from "./helpers/mock-cfetch";
|
|
3
3
|
import { mockConsoleMethods } from "./helpers/mock-console";
|
|
4
|
+
import { msw } from "./helpers/msw";
|
|
4
5
|
import { runInTempDir } from "./helpers/run-in-tmp";
|
|
5
6
|
import { runWrangler } from "./helpers/run-wrangler";
|
|
6
7
|
import type {
|
|
@@ -16,10 +17,6 @@ describe("wrangler", () => {
|
|
|
16
17
|
runInTempDir();
|
|
17
18
|
const std = mockConsoleMethods();
|
|
18
19
|
|
|
19
|
-
afterEach(() => {
|
|
20
|
-
unsetAllMocks();
|
|
21
|
-
});
|
|
22
|
-
|
|
23
20
|
describe("pubsub", () => {
|
|
24
21
|
describe("help menu", () => {
|
|
25
22
|
it("shows usage details", async () => {
|
|
@@ -38,6 +35,7 @@ describe("wrangler", () => {
|
|
|
38
35
|
|
|
39
36
|
Flags:
|
|
40
37
|
-c, --config Path to .toml configuration file [string]
|
|
38
|
+
-e, --env Environment to use for operations and .env files [string]
|
|
41
39
|
-h, --help Show help [boolean]
|
|
42
40
|
-v, --version Show version number [boolean]
|
|
43
41
|
|
|
@@ -68,6 +66,7 @@ describe("wrangler", () => {
|
|
|
68
66
|
|
|
69
67
|
Flags:
|
|
70
68
|
-c, --config Path to .toml configuration file [string]
|
|
69
|
+
-e, --env Environment to use for operations and .env files [string]
|
|
71
70
|
-h, --help Show help [boolean]
|
|
72
71
|
-v, --version Show version number [boolean]
|
|
73
72
|
|
|
@@ -81,15 +80,30 @@ describe("wrangler", () => {
|
|
|
81
80
|
describe("create", () => {
|
|
82
81
|
function mockCreateRequest(expectedNamespaceName: string) {
|
|
83
82
|
const requests = { count: 0 };
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
83
|
+
msw.use(
|
|
84
|
+
rest.post(
|
|
85
|
+
"*/accounts/:accountId/pubsub/namespaces",
|
|
86
|
+
async (req, res, ctx) => {
|
|
87
|
+
expect(req.params.accountId).toEqual("some-account-id");
|
|
88
|
+
const namespace = await req.json();
|
|
89
|
+
expect(namespace.name).toEqual(expectedNamespaceName);
|
|
90
|
+
requests.count++;
|
|
91
|
+
return res.once(
|
|
92
|
+
ctx.status(200),
|
|
93
|
+
ctx.json({
|
|
94
|
+
success: true,
|
|
95
|
+
errors: [],
|
|
96
|
+
messages: [],
|
|
97
|
+
result: {
|
|
98
|
+
id: "some-namespace-id",
|
|
99
|
+
name: namespace.name,
|
|
100
|
+
created_at: "3005-01-01T00:00:00.000000Z",
|
|
101
|
+
updated_at: "3005-01-01T00:00:00.000000Z",
|
|
102
|
+
},
|
|
103
|
+
})
|
|
104
|
+
);
|
|
105
|
+
}
|
|
106
|
+
)
|
|
93
107
|
);
|
|
94
108
|
return requests;
|
|
95
109
|
}
|
|
@@ -105,14 +119,24 @@ describe("wrangler", () => {
|
|
|
105
119
|
describe("list", () => {
|
|
106
120
|
function mockListRequest(namespaces: PubSubNamespace[]) {
|
|
107
121
|
const requests = { count: 0 };
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
122
|
+
msw.use(
|
|
123
|
+
rest.get(
|
|
124
|
+
"*/accounts/:accountId/pubsub/namespaces",
|
|
125
|
+
async (req, res, ctx) => {
|
|
126
|
+
requests.count++;
|
|
127
|
+
expect(req.params.accountId).toEqual("some-account-id");
|
|
128
|
+
|
|
129
|
+
return res.once(
|
|
130
|
+
ctx.status(200),
|
|
131
|
+
ctx.json({
|
|
132
|
+
success: true,
|
|
133
|
+
errors: [],
|
|
134
|
+
messages: [],
|
|
135
|
+
result: namespaces,
|
|
136
|
+
})
|
|
137
|
+
);
|
|
138
|
+
}
|
|
139
|
+
)
|
|
116
140
|
);
|
|
117
141
|
return requests;
|
|
118
142
|
}
|
|
@@ -126,7 +150,12 @@ describe("wrangler", () => {
|
|
|
126
150
|
await runWrangler("pubsub namespace list");
|
|
127
151
|
|
|
128
152
|
expect(std.err).toMatchInlineSnapshot(`""`);
|
|
129
|
-
|
|
153
|
+
expect(std.out).toMatchInlineSnapshot(`
|
|
154
|
+
"[
|
|
155
|
+
{ name: 'namespace-1', created_on: '01-01-2001' },
|
|
156
|
+
{ name: 'namespace-2', created_on: '01-01-2001' }
|
|
157
|
+
]"
|
|
158
|
+
`);
|
|
130
159
|
expect(requests.count).toEqual(1);
|
|
131
160
|
});
|
|
132
161
|
});
|
|
@@ -158,6 +187,7 @@ describe("wrangler", () => {
|
|
|
158
187
|
|
|
159
188
|
Flags:
|
|
160
189
|
-c, --config Path to .toml configuration file [string]
|
|
190
|
+
-e, --env Environment to use for operations and .env files [string]
|
|
161
191
|
-h, --help Show help [boolean]
|
|
162
192
|
-v, --version Show version number [boolean]
|
|
163
193
|
|
|
@@ -171,16 +201,29 @@ describe("wrangler", () => {
|
|
|
171
201
|
describe("create", () => {
|
|
172
202
|
function mockCreateRequest(expectedBrokerName: string) {
|
|
173
203
|
const requests = { count: 0 };
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
204
|
+
msw.use(
|
|
205
|
+
rest.post(
|
|
206
|
+
"*/accounts/:accountId/pubsub/namespaces/:namespaceName/brokers",
|
|
207
|
+
async (req, res, ctx) => {
|
|
208
|
+
expect(req.params.accountId).toEqual("some-account-id");
|
|
209
|
+
expect(req.params.namespaceName).toEqual("some-namespace");
|
|
210
|
+
const broker = await req.json();
|
|
211
|
+
expect(broker.name).toEqual(expectedBrokerName);
|
|
212
|
+
requests.count++;
|
|
213
|
+
return res.once(
|
|
214
|
+
ctx.status(200),
|
|
215
|
+
ctx.json({
|
|
216
|
+
success: true,
|
|
217
|
+
errors: [],
|
|
218
|
+
messages: [],
|
|
219
|
+
result: {
|
|
220
|
+
name: expectedBrokerName,
|
|
221
|
+
created_on: "01-01-2001",
|
|
222
|
+
},
|
|
223
|
+
})
|
|
224
|
+
);
|
|
225
|
+
}
|
|
226
|
+
)
|
|
184
227
|
);
|
|
185
228
|
return requests;
|
|
186
229
|
}
|
|
@@ -191,7 +234,10 @@ describe("wrangler", () => {
|
|
|
191
234
|
"pubsub broker create my-broker --namespace=some-namespace"
|
|
192
235
|
);
|
|
193
236
|
|
|
194
|
-
|
|
237
|
+
expect(std.err).toMatchInlineSnapshot(`""`);
|
|
238
|
+
expect(std.out).toMatchInlineSnapshot(
|
|
239
|
+
`"{ name: 'my-broker', created_on: '01-01-2001' }"`
|
|
240
|
+
);
|
|
195
241
|
expect(requests.count).toEqual(1);
|
|
196
242
|
});
|
|
197
243
|
|
|
@@ -212,21 +258,34 @@ describe("wrangler", () => {
|
|
|
212
258
|
expectedOnPublishConfig: PubSubBrokerOnPublish
|
|
213
259
|
) {
|
|
214
260
|
const requests = { count: 0 };
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
261
|
+
msw.use(
|
|
262
|
+
rest.patch(
|
|
263
|
+
"*/accounts/:accountId/pubsub/namespaces/:namespaceName/brokers/:brokerName",
|
|
264
|
+
async (req, res, cxt) => {
|
|
265
|
+
requests.count += 1;
|
|
266
|
+
expect(req.params.accountId).toEqual("some-account-id");
|
|
267
|
+
expect(req.params.namespaceName).toEqual("some-namespace");
|
|
268
|
+
expect(req.params.brokerName).toEqual(expectedBrokerName);
|
|
269
|
+
|
|
270
|
+
const patchBody: PubSubBrokerUpdate = await req.json();
|
|
271
|
+
|
|
272
|
+
expect(patchBody.expiration).toEqual(expectedExpiration);
|
|
273
|
+
expect(patchBody.description).toEqual(expectedDescription);
|
|
274
|
+
expect(patchBody.on_publish).toEqual(expectedOnPublishConfig);
|
|
275
|
+
return res.once(
|
|
276
|
+
cxt.status(200),
|
|
277
|
+
cxt.json({
|
|
278
|
+
success: true,
|
|
279
|
+
errors: [],
|
|
280
|
+
messages: [],
|
|
281
|
+
result: {
|
|
282
|
+
name: expectedBrokerName,
|
|
283
|
+
created_on: "01-01-2001",
|
|
284
|
+
},
|
|
285
|
+
})
|
|
286
|
+
);
|
|
287
|
+
}
|
|
288
|
+
)
|
|
230
289
|
);
|
|
231
290
|
return requests;
|
|
232
291
|
}
|
|
@@ -246,7 +305,10 @@ describe("wrangler", () => {
|
|
|
246
305
|
);
|
|
247
306
|
|
|
248
307
|
expect(std.err).toMatchInlineSnapshot(`""`);
|
|
249
|
-
|
|
308
|
+
expect(std.out).toMatchInlineSnapshot(`
|
|
309
|
+
"{ name: 'my-broker', created_on: '01-01-2001' }
|
|
310
|
+
Successfully updated Pub/Sub Broker my-broker"
|
|
311
|
+
`);
|
|
250
312
|
expect(requests.count).toEqual(1);
|
|
251
313
|
});
|
|
252
314
|
});
|
|
@@ -254,15 +316,24 @@ describe("wrangler", () => {
|
|
|
254
316
|
describe("list", () => {
|
|
255
317
|
function mockListRequest(brokers: PubSubBroker[]) {
|
|
256
318
|
const requests = { count: 0 };
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
319
|
+
msw.use(
|
|
320
|
+
rest.get(
|
|
321
|
+
"*/accounts/:accountId/pubsub/namespaces/:namespaceName/brokers",
|
|
322
|
+
async (req, res, cxt) => {
|
|
323
|
+
requests.count++;
|
|
324
|
+
expect(req.params.accountId).toEqual("some-account-id");
|
|
325
|
+
expect(req.params.namespaceName).toEqual("some-namespace");
|
|
326
|
+
return res.once(
|
|
327
|
+
cxt.status(200),
|
|
328
|
+
cxt.json({
|
|
329
|
+
success: true,
|
|
330
|
+
errors: [],
|
|
331
|
+
messages: [],
|
|
332
|
+
result: brokers,
|
|
333
|
+
})
|
|
334
|
+
);
|
|
335
|
+
}
|
|
336
|
+
)
|
|
266
337
|
);
|
|
267
338
|
return requests;
|
|
268
339
|
}
|
|
@@ -276,7 +347,12 @@ describe("wrangler", () => {
|
|
|
276
347
|
await runWrangler("pubsub broker list --namespace=some-namespace");
|
|
277
348
|
|
|
278
349
|
expect(std.err).toMatchInlineSnapshot(`""`);
|
|
279
|
-
|
|
350
|
+
expect(std.out).toMatchInlineSnapshot(`
|
|
351
|
+
"[
|
|
352
|
+
{ name: 'broker-1', created_on: '01-01-2001' },
|
|
353
|
+
{ name: 'broker-2', created_on: '01-01-2001' }
|
|
354
|
+
]"
|
|
355
|
+
`);
|
|
280
356
|
expect(requests.count).toEqual(1);
|
|
281
357
|
});
|
|
282
358
|
});
|
|
@@ -284,15 +360,25 @@ describe("wrangler", () => {
|
|
|
284
360
|
describe("describe", () => {
|
|
285
361
|
function mockGetRequest(broker: PubSubBroker) {
|
|
286
362
|
const requests = { count: 0 };
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
363
|
+
msw.use(
|
|
364
|
+
rest.get(
|
|
365
|
+
"*/accounts/:accountId/pubsub/namespaces/:namespaceName/brokers/:brokerName",
|
|
366
|
+
(req, res, cxt) => {
|
|
367
|
+
requests.count++;
|
|
368
|
+
expect(req.params.accountId).toEqual("some-account-id");
|
|
369
|
+
expect(req.params.namespaceName).toEqual("some-namespace");
|
|
370
|
+
expect(req.params.brokerName).toEqual(broker.name);
|
|
371
|
+
return res.once(
|
|
372
|
+
cxt.status(200),
|
|
373
|
+
cxt.json({
|
|
374
|
+
success: true,
|
|
375
|
+
errors: [],
|
|
376
|
+
messages: [],
|
|
377
|
+
result: broker,
|
|
378
|
+
})
|
|
379
|
+
);
|
|
380
|
+
}
|
|
381
|
+
)
|
|
296
382
|
);
|
|
297
383
|
return requests;
|
|
298
384
|
}
|
|
@@ -304,7 +390,9 @@ describe("wrangler", () => {
|
|
|
304
390
|
);
|
|
305
391
|
|
|
306
392
|
expect(std.err).toMatchInlineSnapshot(`""`);
|
|
307
|
-
|
|
393
|
+
expect(std.out).toMatchInlineSnapshot(
|
|
394
|
+
`"{ id: '1234', name: 'my-broker' }"`
|
|
395
|
+
);
|
|
308
396
|
expect(requests.count).toEqual(1);
|
|
309
397
|
});
|
|
310
398
|
});
|
|
@@ -312,14 +400,28 @@ describe("wrangler", () => {
|
|
|
312
400
|
describe("issue", () => {
|
|
313
401
|
function mockIssueRequest(expectedBrokerName: string) {
|
|
314
402
|
const requests = { count: 0 };
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
403
|
+
msw.use(
|
|
404
|
+
rest.get(
|
|
405
|
+
"*/accounts/:accountId/pubsub/namespaces/:namespaceName/brokers/:brokerName/credentials",
|
|
406
|
+
(req, res, cxt) => {
|
|
407
|
+
requests.count++;
|
|
408
|
+
expect(req.params.accountId).toEqual("some-account-id");
|
|
409
|
+
expect(req.params.namespaceName).toEqual("some-namespace");
|
|
410
|
+
expect(req.params.brokerName).toEqual(expectedBrokerName);
|
|
411
|
+
return res.once(
|
|
412
|
+
cxt.status(200),
|
|
413
|
+
cxt.json({
|
|
414
|
+
success: true,
|
|
415
|
+
errors: [],
|
|
416
|
+
messages: [],
|
|
417
|
+
result: {
|
|
418
|
+
"MOCK-89T6DXG3SVG1WQRA": `<base-64-encoded-JWT>`,
|
|
419
|
+
"MOCK-393REE4WRRE4NHAV96": `<base-64-encoded-JWT>`,
|
|
420
|
+
},
|
|
421
|
+
})
|
|
422
|
+
);
|
|
423
|
+
}
|
|
424
|
+
)
|
|
323
425
|
);
|
|
324
426
|
return requests;
|
|
325
427
|
}
|
|
@@ -331,7 +433,13 @@ describe("wrangler", () => {
|
|
|
331
433
|
);
|
|
332
434
|
|
|
333
435
|
expect(std.err).toMatchInlineSnapshot(`""`);
|
|
334
|
-
|
|
436
|
+
expect(std.out).toMatchInlineSnapshot(`
|
|
437
|
+
"🔑 Issuing credential(s) for my-broker.some-namespace...
|
|
438
|
+
{
|
|
439
|
+
'MOCK-89T6DXG3SVG1WQRA': '<base-64-encoded-JWT>',
|
|
440
|
+
'MOCK-393REE4WRRE4NHAV96': '<base-64-encoded-JWT>'
|
|
441
|
+
}"
|
|
442
|
+
`);
|
|
335
443
|
expect(requests.count).toEqual(1);
|
|
336
444
|
});
|
|
337
445
|
});
|
|
@@ -339,14 +447,27 @@ describe("wrangler", () => {
|
|
|
339
447
|
describe("public-keys", () => {
|
|
340
448
|
function mockIssueRequest(expectedBrokerName: string) {
|
|
341
449
|
const requests = { count: 0 };
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
450
|
+
msw.use(
|
|
451
|
+
rest.get(
|
|
452
|
+
"*/accounts/:accountId/pubsub/namespaces/:namespaceName/brokers/:brokerName/publickeys",
|
|
453
|
+
(req, res, cxt) => {
|
|
454
|
+
requests.count++;
|
|
455
|
+
expect(req.params.accountId).toEqual("some-account-id");
|
|
456
|
+
expect(req.params.namespaceName).toEqual("some-namespace");
|
|
457
|
+
expect(req.params.brokerName).toEqual(expectedBrokerName);
|
|
458
|
+
return res.once(
|
|
459
|
+
cxt.status(200),
|
|
460
|
+
cxt.json({
|
|
461
|
+
success: true,
|
|
462
|
+
errors: [],
|
|
463
|
+
messages: [],
|
|
464
|
+
result: {
|
|
465
|
+
public_keys: "Mock-Public-Key",
|
|
466
|
+
},
|
|
467
|
+
})
|
|
468
|
+
);
|
|
469
|
+
}
|
|
470
|
+
)
|
|
350
471
|
);
|
|
351
472
|
return requests;
|
|
352
473
|
}
|
|
@@ -358,7 +479,9 @@ describe("wrangler", () => {
|
|
|
358
479
|
);
|
|
359
480
|
|
|
360
481
|
expect(std.err).toMatchInlineSnapshot(`""`);
|
|
361
|
-
|
|
482
|
+
expect(std.out).toMatchInlineSnapshot(
|
|
483
|
+
`"{ public_keys: 'Mock-Public-Key' }"`
|
|
484
|
+
);
|
|
362
485
|
expect(requests.count).toEqual(1);
|
|
363
486
|
});
|
|
364
487
|
});
|