@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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dooer/dooer-test-env",
3
- "version": "1.15.0",
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
- `setup` needs **VPN access** and a **kubectl credential** for the cluster — the compose file, the registry
18
- logins and the BankID cert all come from there.
18
+ You need exactly two things:
19
19
 
20
- - **[Getting access](./docs/getting-access.md)** — new developer: set up the VPN, get your kubectl
21
- certificate, and verify both actually work.
22
- - **[Issuing access](./docs/issuing-access.md)** admin: sign someone's certificate, bind their
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
- Already have both? Straight to the quick start.
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
- # 1. One-time: prereq checks, registry login, compose generation, BankID cert keychain.
31
- # Needs the VPN + kubectl access to dooer-staging (see "First time here?" above).
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|list sign in to an environment; session → keychain
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 talk to an environment's **public GraphQL endpoint** — the same one the
171
- frontends use — so reaching staging or live needs no VPN, no kubectl and no cluster credentials. It does
172
- need a session. Sign in once per environment; the token is kept in your keychain:
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 — exactly what HQ does, so you get your professional (hi) account
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 (prompted, hidden) — the only way to reach an ADMIN account
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 # who you are, in every environment
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`, `production`, and aliases
186
- like `dooer-staging` / `live` all resolve):
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 account you sign in as decides what you can do**, because one person has several user rows:
194
-
195
- | operation | needs | how to get it |
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
- BankID cannot reach an admin account at all: `loginWithBankIdV2` is pinned to `user_type: 'customer'`
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
- Signed in as an admin, you can assume a partner user without BankIDthe same thing back-office's
206
- **“Become user in X”** button does (`partner.user.become`, itself admin-gated):
211
+ `remote-environment token` prints the token and nothing else no colour, no labelso it drops straight
212
+ into a variable or a pipe:
207
213
 
208
214
  ```bash
209
- npx @dooer/dooer-test-env@latest remote-environment become someone@dooer.com --env staging
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
- npx @dooer/dooer-test-env@latest remote-environment become --revert --env staging
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
- Becoming replaces the stored session, so the admin token that authorised it is stashed first and
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
- The local env needs no login — it is signed with the shared dev keypair this CLI already holds.
224
+ ### Copy a real customer into the local env
219
225
 
220
- Writes are dry-run until `--execute`.
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
- ### Copy a real customer into the local env
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
- `--target-local` addresses this stack (Postgres on 55432 + MinIO); the source can be any k8s namespace
225
- (`--source-local` goes the other way). Reading production needs no confirmation — only *writing* to it does. Emails are always
226
- anonymized. Dry-run by default; add `--execute`.
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), `kubectl` with access to the `dooer-staging` namespace (VPN), and Node 18+.
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
- Don't have the VPN or a kubectl credential yet? **[Getting access](./docs/getting-access.md)**.
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.