@7365admin1/core 3.73.0 → 3.73.1
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/CHANGELOG.md +6 -0
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/test/e2e/person-write-scope.e2e.test.mjs +57 -0
- package/test/people-create-gate.test.mjs +16 -13
package/package.json
CHANGED
|
@@ -260,6 +260,63 @@ describe("people writes are scoped to a site the caller can reach", { concurrenc
|
|
|
260
260
|
assert.equal(res.status, 200, JSON.stringify(res.body));
|
|
261
261
|
assert.equal((await load(id.residentPerson)).name, "Resubmitted By Themselves");
|
|
262
262
|
});
|
|
263
|
+
|
|
264
|
+
// ---- creating a person: POST /api/people -------------------------------
|
|
265
|
+
// The signed-in branch of `add` used to check only that somebody was signed
|
|
266
|
+
// in, while `site`/`org` came from the body. The reach gate is enforced by
|
|
267
|
+
// default now; these cases pin both halves of that.
|
|
268
|
+
|
|
269
|
+
const newPerson = (tag) => ({
|
|
270
|
+
name: `Created ${tag}`,
|
|
271
|
+
contact: "90000001",
|
|
272
|
+
type: "guest",
|
|
273
|
+
isOwner: false,
|
|
274
|
+
org: String(id.orgB),
|
|
275
|
+
site: String(id.siteB),
|
|
276
|
+
});
|
|
277
|
+
const countCreated = (tag) =>
|
|
278
|
+
h.db.collection("site.people").countDocuments({ name: `Created ${tag}` });
|
|
279
|
+
|
|
280
|
+
record("13. an outsider cannot create a person at site B", async () => {
|
|
281
|
+
const res = await h.api("/people", { method: "POST", body: newPerson("outsider"), sid: outsiderSid });
|
|
282
|
+
|
|
283
|
+
assert.equal(res.status, 401, JSON.stringify(res.body));
|
|
284
|
+
assert.equal(await countCreated("outsider"), 0, "nothing may be written");
|
|
285
|
+
});
|
|
286
|
+
|
|
287
|
+
record("14. nor by naming only site B's organisation", async () => {
|
|
288
|
+
const { site, ...orgOnly } = newPerson("outsider-org");
|
|
289
|
+
const res = await h.api("/people", { method: "POST", body: orgOnly, sid: outsiderSid });
|
|
290
|
+
|
|
291
|
+
assert.equal(res.status, 401, JSON.stringify(res.body));
|
|
292
|
+
assert.equal(await countCreated("outsider-org"), 0);
|
|
293
|
+
});
|
|
294
|
+
|
|
295
|
+
record("15. the site's own manager CAN create one", async () => {
|
|
296
|
+
// `web-app-property-management components/PeopleFormMgmt.vue` -> `usePeople.create`
|
|
297
|
+
const res = await h.api("/people", { method: "POST", body: newPerson("manager"), sid: managerSid });
|
|
298
|
+
|
|
299
|
+
assert.equal(res.status, 201, JSON.stringify(res.body));
|
|
300
|
+
assert.equal(await countCreated("manager"), 1);
|
|
301
|
+
});
|
|
302
|
+
|
|
303
|
+
record("16. and so can the agency guard posted at site B", async () => {
|
|
304
|
+
// the field guard app registers visitors at the site it is posted to
|
|
305
|
+
const res = await h.api("/people", { method: "POST", body: newPerson("guard"), sid: guardSid });
|
|
306
|
+
|
|
307
|
+
assert.equal(res.status, 201, JSON.stringify(res.body));
|
|
308
|
+
assert.equal(await countCreated("guard"), 1);
|
|
309
|
+
});
|
|
310
|
+
|
|
311
|
+
record("17. log mode is a real kill switch: the outsider is let through", async () => {
|
|
312
|
+
process.env.PEOPLE_CREATE_REACH_MODE = "log";
|
|
313
|
+
try {
|
|
314
|
+
const res = await h.api("/people", { method: "POST", body: newPerson("logmode"), sid: outsiderSid });
|
|
315
|
+
assert.equal(res.status, 201, JSON.stringify(res.body));
|
|
316
|
+
} finally {
|
|
317
|
+
delete process.env.PEOPLE_CREATE_REACH_MODE;
|
|
318
|
+
}
|
|
319
|
+
});
|
|
263
320
|
});
|
|
264
321
|
|
|
265
322
|
async function seed(h) {
|
|
@@ -7,10 +7,9 @@
|
|
|
7
7
|
* `site.people` is the collection every site-reach decision reads its verdict
|
|
8
8
|
* from, so a row written there manufactures reach into another client's estate.
|
|
9
9
|
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
* default, so it cannot become enforcing by accident.
|
|
10
|
+
* The gate shipped in `log` first and is ENFORCED by default since 2026-09-15,
|
|
11
|
+
* after a staging measurement showed nobody legitimate is refused. These tests
|
|
12
|
+
* pin that default; `log` stays available as the kill switch.
|
|
14
13
|
*/
|
|
15
14
|
import test from "node:test";
|
|
16
15
|
import assert from "node:assert/strict";
|
|
@@ -21,11 +20,12 @@ import {
|
|
|
21
20
|
peopleCreateVerdict,
|
|
22
21
|
} from "./.build/utils/people-create-gate.util.mjs";
|
|
23
22
|
|
|
24
|
-
test("the code default is
|
|
25
|
-
assert.equal(PEOPLE_CREATE_REACH_MODE_DEFAULT, "
|
|
26
|
-
assert.equal(peopleCreateReachMode({}), "
|
|
27
|
-
// An unrecognised value falls back to the
|
|
28
|
-
assert.equal(peopleCreateReachMode({ PEOPLE_CREATE_REACH_MODE: "nonsense" }), "
|
|
23
|
+
test("the code default is ENFORCE, with log kept as the kill switch", () => {
|
|
24
|
+
assert.equal(PEOPLE_CREATE_REACH_MODE_DEFAULT, "enforce");
|
|
25
|
+
assert.equal(peopleCreateReachMode({}), "enforce");
|
|
26
|
+
// An unrecognised value falls back to the default, so a typo cannot reopen the hole.
|
|
27
|
+
assert.equal(peopleCreateReachMode({ PEOPLE_CREATE_REACH_MODE: "nonsense" }), "enforce");
|
|
28
|
+
assert.equal(peopleCreateReachMode({ PEOPLE_CREATE_REACH_MODE: "log" }), "log");
|
|
29
29
|
assert.equal(peopleCreateReachMode({ PEOPLE_CREATE_REACH_MODE: "ENFORCE" }), "enforce");
|
|
30
30
|
assert.equal(peopleCreateReachMode({ PEOPLE_CREATE_REACH_MODE: "off" }), "off");
|
|
31
31
|
});
|
|
@@ -63,9 +63,12 @@ test("OFF does not even look", () => {
|
|
|
63
63
|
});
|
|
64
64
|
|
|
65
65
|
test("the flag is the only thing between counting and refusing", () => {
|
|
66
|
-
//
|
|
67
|
-
//
|
|
66
|
+
// The default refuses an unreachable estate; `log` is the kill switch that
|
|
67
|
+
// counts instead. If either half fails, the hole is open or the switch is gone.
|
|
68
68
|
const unreachable = { reachable: false };
|
|
69
|
-
assert.equal(peopleCreateVerdict({ mode: peopleCreateReachMode({}), ...unreachable }).refuse,
|
|
70
|
-
assert.equal(
|
|
69
|
+
assert.equal(peopleCreateVerdict({ mode: peopleCreateReachMode({}), ...unreachable }).refuse, true);
|
|
70
|
+
assert.equal(
|
|
71
|
+
peopleCreateVerdict({ mode: peopleCreateReachMode({ PEOPLE_CREATE_REACH_MODE: "log" }), ...unreachable }).refuse,
|
|
72
|
+
false,
|
|
73
|
+
);
|
|
71
74
|
});
|