@dooer/dooer-test-env 1.15.0 → 1.17.0
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/docs/getting-access.md +35 -70
- package/docs/issuing-access.md +9 -0
- package/docs/user-management.md +246 -0
- package/lib/bankid.js +28 -1
- package/lib/command/bankid.js +2 -2
- package/lib/command/customer.js +28 -32
- package/lib/command/db.js +58 -1
- package/lib/command/env.js +15 -3
- package/lib/command/remote-environment.js +11 -0
- package/lib/command/setup.js +25 -16
- package/lib/compose/generate.js +5 -1
- package/lib/compose/manifests.js +7 -0
- package/lib/copy.js +101 -0
- package/lib/db/migrate-stale.js +60 -0
- package/lib/db/roles.js +6 -0
- package/lib/env-spec.js +65 -0
- package/lib/registry.js +28 -0
- package/lib/remote.js +11 -5
- package/lib/runtime.js +6 -3
- package/lib/service-client.js +161 -0
- package/package.json +1 -1
- package/readme.md +65 -45
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dooer/dooer-test-env",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.17.0",
|
|
4
4
|
"description": "Run the whole Dooer backend locally (staging DB minus customers), copy/purge customers between environments, and shred — one CLI.",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"repository": "Dooer/cli-dooer-test-env",
|
package/readme.md
CHANGED
|
@@ -6,7 +6,8 @@ organizations). Copy specific customers in when you need them, spin up empty tes
|
|
|
6
6
|
across the whole stack, and measure resource usage.
|
|
7
7
|
|
|
8
8
|
Runs on an Apple-Silicon Mac (images run under emulation) — 32 GB RAM / ~150 GB free disk is comfortable.
|
|
9
|
-
See **[ENVIRONMENT-PLAN.md](./ENVIRONMENT-PLAN.md)** for the full design and rationale
|
|
9
|
+
See **[ENVIRONMENT-PLAN.md](./ENVIRONMENT-PLAN.md)** for the full design and rationale, and
|
|
10
|
+
**[REVERT-POINT.md](./REVERT-POINT.md)** for the last version that works without `service-dooer-test-env`.
|
|
10
11
|
|
|
11
12
|
```bash
|
|
12
13
|
npx @dooer/dooer-test-env <command>
|
|
@@ -14,21 +15,32 @@ npx @dooer/dooer-test-env <command>
|
|
|
14
15
|
|
|
15
16
|
## First time here?
|
|
16
17
|
|
|
17
|
-
|
|
18
|
-
logins and the BankID cert all come from there.
|
|
18
|
+
You need exactly two things:
|
|
19
19
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
permissions, and revoke them again.
|
|
20
|
+
1. **The VPN** — everything this tool talks to lives inside the cluster network.
|
|
21
|
+
2. **An admin session for staging** — `remote-environment login`. That is what authorizes the tool to
|
|
22
|
+
fetch the environment spec, the registry credentials and the BankID material.
|
|
24
23
|
|
|
25
|
-
|
|
24
|
+
**No kubectl. No cluster credential. No `new-infrastructure` checkout.** All of that moved behind
|
|
25
|
+
`service-dooer-test-env`, which runs in each environment and exposes only the operations this tool needs
|
|
26
|
+
— each one admin-gated and recorded. See
|
|
27
|
+
[the specification](./_specification/service-dooer-test-env.md) for what it replaced and why.
|
|
28
|
+
|
|
29
|
+
- **[Getting access](./docs/getting-access.md)** — new developer: set up the VPN and log in.
|
|
30
|
+
- **[Logins and user management](./docs/user-management.md)** — signing in as a customer, partner or admin
|
|
31
|
+
user; creating users; partner membership; using the token from scripts.
|
|
32
|
+
- **[Issuing access](./docs/issuing-access.md)** — admin: VPN tunnels, and cluster certificates for the
|
|
33
|
+
people who actually operate the cluster. **Not needed to use this tool any more.**
|
|
26
34
|
|
|
27
35
|
## Quick start
|
|
28
36
|
|
|
29
37
|
```bash
|
|
30
|
-
#
|
|
31
|
-
#
|
|
38
|
+
# 0. Log in to staging as an ADMIN — the local stack is built from staging's live Deployments.
|
|
39
|
+
# BankID cannot reach an admin account; this has to be email + password.
|
|
40
|
+
npx @dooer/dooer-test-env remote-environment login --env staging --email you+admin@dooer.com
|
|
41
|
+
|
|
42
|
+
# 1. One-time: prereqs, registry login, environment spec, compose generation, BankID cert → keychain.
|
|
43
|
+
# Needs the VPN and the admin session above.
|
|
32
44
|
npx @dooer/dooer-test-env setup
|
|
33
45
|
|
|
34
46
|
# 2. Bring the whole stack up (all staging services + frontends)
|
|
@@ -53,7 +65,7 @@ db roles (re)create per-service DB role
|
|
|
53
65
|
db snapshot <name> | db rollback <name> local restore points
|
|
54
66
|
customer new "<name>" --owner <userId> --execute empty functional account: company + Owner + subscriptions + partner dooer
|
|
55
67
|
customer copy | customer purge copy / delete one org between environments (emails anonymized)
|
|
56
|
-
remote-environment login|become|status|logout
|
|
68
|
+
remote-environment login|become|token|status|logout sign in to an environment; session → keychain
|
|
57
69
|
user search | get | create | partners find/inspect/create users (local env unless --env)
|
|
58
70
|
partner list | users | assign | unassign partners and who belongs to them, at which level
|
|
59
71
|
shred anonymize the LOCAL db (localhost only)
|
|
@@ -167,63 +179,67 @@ user's `--role` at Dooer. Only **`hi`** users can belong to a partner; the CLI a
|
|
|
167
179
|
|
|
168
180
|
### Look at (or fix) users in a real environment
|
|
169
181
|
|
|
170
|
-
The `user` and `partner` commands
|
|
171
|
-
frontends use — so
|
|
172
|
-
need a session
|
|
182
|
+
The `user` and `partner` commands reach an environment through its **public GraphQL endpoint** — the same
|
|
183
|
+
one the frontends use — so staging and live need no VPN, no kubectl and no cluster credentials. They do
|
|
184
|
+
need a session:
|
|
173
185
|
|
|
174
186
|
```bash
|
|
175
|
-
# BankID —
|
|
187
|
+
# BankID — what HQ does, so you get your professional (hi) account
|
|
176
188
|
npx @dooer/dooer-test-env@latest remote-environment login --env staging
|
|
177
189
|
|
|
178
|
-
# email + password
|
|
190
|
+
# email + password — the only route to an ADMIN account (BankID cannot reach one)
|
|
179
191
|
npx @dooer/dooer-test-env@latest remote-environment login --env staging --email you+admin@dooer.com
|
|
180
192
|
|
|
181
|
-
npx @dooer/dooer-test-env@latest remote-environment status --all
|
|
182
|
-
npx @dooer/dooer-test-env@latest remote-environment logout --env staging
|
|
193
|
+
npx @dooer/dooer-test-env@latest remote-environment status --all
|
|
183
194
|
```
|
|
184
195
|
|
|
185
|
-
Then point any command at it with `--env` (`local` is the default; `staging
|
|
186
|
-
like `dooer-staging` / `live`
|
|
196
|
+
Then point any command at it with `--env` (`local` is the default; `staging` / `production` and aliases
|
|
197
|
+
like `dooer-staging` / `live` resolve too):
|
|
187
198
|
|
|
188
199
|
```bash
|
|
189
200
|
npx @dooer/dooer-test-env@latest user search someone@dooer.com --env staging
|
|
190
201
|
npx @dooer/dooer-test-env@latest partner list --env production
|
|
191
202
|
```
|
|
192
203
|
|
|
193
|
-
**Which
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
| reads (`user search`, `user get`) | any session | either login |
|
|
198
|
-
| `partner assign` / `unassign` | a **partner** session | BankID login, or `become` from an admin session |
|
|
199
|
-
| `user create` | an **admin** session | password login as your admin account |
|
|
204
|
+
**Which of your accounts you sign in as decides what you can do** — reads work from any session, partner
|
|
205
|
+
membership needs a partner session, and creating a user needs an admin one. See
|
|
206
|
+
**[Logins and user management](./docs/user-management.md)** for the full picture: the three kinds of user,
|
|
207
|
+
`become`, and the permission matrix.
|
|
200
208
|
|
|
201
|
-
|
|
202
|
-
server-side, and HQ's partner flow resolves your `hi` user. When a session lacks the level, the CLI says
|
|
203
|
-
which one is required and who you are currently signed in as, rather than surfacing a raw `Forbidden`.
|
|
209
|
+
### Use the session token in your own scripts
|
|
204
210
|
|
|
205
|
-
|
|
206
|
-
|
|
211
|
+
`remote-environment token` prints the token and nothing else — no colour, no label — so it drops straight
|
|
212
|
+
into a variable or a pipe:
|
|
207
213
|
|
|
208
214
|
```bash
|
|
209
|
-
npx @dooer/dooer-test-env@latest remote-environment
|
|
210
|
-
# …--partner "Dooer Devteam" if they belong to more than one
|
|
215
|
+
TOKEN=$(npx @dooer/dooer-test-env@latest remote-environment token --env staging)
|
|
211
216
|
|
|
212
|
-
|
|
217
|
+
curl -s https://api.s-e032.com/graphql \
|
|
218
|
+
-H "content-type: application/json" -H "authorization: Bearer $TOKEN" \
|
|
219
|
+
-d '{"query":"{ currentUser { id email userType } }"}'
|
|
213
220
|
```
|
|
214
221
|
|
|
215
|
-
|
|
216
|
-
`--revert` puts it back — otherwise you would have to log in again just to get where you were.
|
|
222
|
+
The local env needs no login for this — with no stored session it mints one from the shared dev keypair.
|
|
217
223
|
|
|
218
|
-
|
|
224
|
+
### Copy a real customer into the local env
|
|
219
225
|
|
|
220
|
-
|
|
226
|
+
`--target-local` addresses this stack; the source can be any environment (`--source-local` goes the other
|
|
227
|
+
way). Emails are always anonymized. Dry-run by default; add `--execute`.
|
|
221
228
|
|
|
222
|
-
|
|
229
|
+
**You need an admin session in BOTH ends.** A copy is two locally-authorized halves — an export authorized
|
|
230
|
+
by admin in the *source* and an import authorized by admin in the *target* — because each environment
|
|
231
|
+
signs its own tokens and neither service will ever validate the other's. That is a stronger check than the
|
|
232
|
+
kubeconfig it replaces, where reaching the cluster was enough. The command is unchanged; the split is
|
|
233
|
+
internal.
|
|
223
234
|
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
235
|
+
```bash
|
|
236
|
+
npx @dooer/dooer-test-env@latest remote-environment login --env production --email you+admin@dooer.com
|
|
237
|
+
npx @dooer/dooer-test-env@latest remote-environment login --env staging --email you+admin@dooer.com
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
Both halves are async, so the command prints progress while it waits. If the source could not read a
|
|
241
|
+
table, the copy says so as a **WARNING** rather than quietly producing a partial org, and both ends record
|
|
242
|
+
the operation in their audit trail (`remote-environment` → the service's `/v1/operations`).
|
|
227
243
|
|
|
228
244
|
```bash
|
|
229
245
|
# copy Ghost Inspector out of LIVE into the local env, as a new org owned by a local user
|
|
@@ -386,6 +402,10 @@ Inbound *input* validation always runs — this only affects response validation
|
|
|
386
402
|
|
|
387
403
|
## Prerequisites
|
|
388
404
|
|
|
389
|
-
Docker (Desktop),
|
|
405
|
+
Docker (Desktop), the **VPN**, an **admin session for staging**, and Node 18+.
|
|
406
|
+
|
|
407
|
+
No kubectl, no cluster certificate, no `new-infrastructure` checkout — `service-dooer-test-env` supplies
|
|
408
|
+
what those used to. Don't have the VPN yet? → **[Getting access](./docs/getting-access.md)**.
|
|
390
409
|
|
|
391
|
-
|
|
410
|
+
`DOOER_TEST_ENV_MANIFESTS=<dir>` still generates from local manifest yaml instead of the live cluster,
|
|
411
|
+
which is useful when you are working on a manifest that is not deployed yet.
|