@7365admin1/core 3.106.0 → 3.109.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/CHANGELOG.md +18 -0
- package/dist/index.d.ts +27 -7
- package/dist/index.js +119 -18
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +117 -18
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
- package/test/e2e/invite-org-scoping.e2e.test.mjs +6 -5
- package/test/e2e/invite-roles-owner-reach.e2e.test.mjs +73 -0
- package/test/e2e/org-invite-scope.e2e.test.mjs +188 -0
- package/test/e2e/site-delete-owner-only.e2e.test.mjs +148 -0
- package/test/invite-origin.test.mjs +42 -0
- package/test/notification-email.util.test.mjs +67 -0
- package/test/site-owner-edit.test.mjs +18 -0
- package/test/verification-scope.test.mjs +2 -1
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@7365admin1/core",
|
|
3
3
|
"license": "MIT",
|
|
4
|
-
"version": "3.
|
|
4
|
+
"version": "3.109.0",
|
|
5
5
|
"author": "7365admin1",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"module": "dist/index.mjs",
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"build": "tsup src/index.ts --format cjs,esm --dts && shx cp -r src/public dist && shx cp -r src/utils/handlebars dist",
|
|
14
14
|
"release": "yarn run build && changeset publish",
|
|
15
15
|
"lint": "tsc",
|
|
16
|
-
"test": "tsup src/config.ts src/utils/building-map.util.ts src/utils/robot-cloud.util.ts src/utils/robot-adapter.util.ts src/utils/png-encoder.util.ts src/services/demo.adapter.ts src/services/ounitech.adapter.ts src/services/open-rmf.adapter.ts src/utils/robot-credentials.util.ts src/utils/rmf-building.util.ts src/utils/door-contract.util.ts src/utils/robot-fault.util.ts src/utils/robot-tracking.util.ts src/utils/robot-apps.util.ts src/utils/robot-permission.util.ts src/utils/robot-network.util.ts src/utils/lift-contract.util.ts src/models/robot-building-map.model.ts src/utils/anpr-revoke.util.ts src/utils/anpr-plate.util.ts src/utils/vehicle-request.util.ts src/utils/camera-view.util.ts src/utils/camera-bulk-import.util.ts src/utils/dashboard-metrics.util.ts src/utils/camera-capability.util.ts src/utils/camera-playback.util.ts src/services/camera-device-http.service.ts src/utils/camera-alert.util.ts src/utils/dahua-protocol.util.ts src/utils/site-name.util.ts src/utils/site-owner-edit.util.ts src/utils/service-provider-invite.util.ts src/utils/notification-category.util.ts src/utils/notification-kind.util.ts src/utils/notification-email.util.ts src/models/notification.model.ts src/utils/hid-card.util.ts src/utils/hid-json.util.ts src/utils/hid-access.util.ts src/models/customer-site.model.ts src/models/site-camera.model.ts src/models/member.model.ts src/models/subscription.model.ts src/utils/session-id.util.ts src/utils/occurrence-query.util.ts src/utils/occurrence-book-create.util.ts src/utils/update-result.util.ts src/utils/hid-amico-authz.util.ts src/utils/promo-code-currency.util.ts src/utils/console-audit.util.ts src/utils/org-suspension.util.ts src/utils/session-revoke.util.ts src/models/hid-amico.model.ts src/models/patrol-email.model.ts src/utils/patrol-email-pdf.util.ts src/utils/visitor-status.util.ts src/utils/self-service-email.util.ts src/utils/hid-secret.util.ts src/models/visitor-invite.model.ts src/models/guard-invite.model.ts src/utils/site-timezone.util.ts src/utils/bulletin-service-apps.util.ts src/models/bulletin-board.model.ts src/utils/vehicle-import.util.ts src/utils/expired-vehicle-sweep.util.ts src/models/vehicle.model.ts src/controllers/chat.controller.ts src/utils/file-owner.util.ts src/utils/console-permission.util.ts src/utils/role-scope.util.ts src/utils/org-default-roles.util.ts src/utils/org-modules.util.ts src/utils/site-modules.util.ts src/utils/resident-app-modules.util.ts src/utils/resident-default-role.util.ts src/utils/invite-role-scope.util.ts src/models/personal-emergency-chain.model.ts src/utils/self-signup-files.util.ts src/models/person.model.ts src/utils/module-gate.util.ts src/utils/member-lookup.util.ts src/utils/notification-access.util.ts src/utils/module-access.util.ts src/services/module-gate.service.ts src/controllers/site.controller.ts src/controllers/organization.controller.ts src/controllers/member.controller.ts src/utils/org-owner-repair.util.ts src/utils/socket-session.util.ts src/utils/people-create-gate.util.ts src/utils/service-app-type.util.ts src/utils/customer-site-list.util.ts src/utils/org-search.util.ts --format esm --out-dir test/.build --no-dts --silent && node --test test/*.test.mjs",
|
|
16
|
+
"test": "tsup src/config.ts src/utils/building-map.util.ts src/utils/robot-cloud.util.ts src/utils/robot-adapter.util.ts src/utils/png-encoder.util.ts src/services/demo.adapter.ts src/services/ounitech.adapter.ts src/services/open-rmf.adapter.ts src/utils/robot-credentials.util.ts src/utils/rmf-building.util.ts src/utils/door-contract.util.ts src/utils/robot-fault.util.ts src/utils/robot-tracking.util.ts src/utils/robot-apps.util.ts src/utils/robot-permission.util.ts src/utils/robot-network.util.ts src/utils/lift-contract.util.ts src/models/robot-building-map.model.ts src/utils/anpr-revoke.util.ts src/utils/anpr-plate.util.ts src/utils/vehicle-request.util.ts src/utils/camera-view.util.ts src/utils/camera-bulk-import.util.ts src/utils/dashboard-metrics.util.ts src/utils/camera-capability.util.ts src/utils/camera-playback.util.ts src/services/camera-device-http.service.ts src/utils/camera-alert.util.ts src/utils/dahua-protocol.util.ts src/utils/site-name.util.ts src/utils/site-owner-edit.util.ts src/utils/service-provider-invite.util.ts src/utils/notification-category.util.ts src/utils/notification-kind.util.ts src/utils/notification-email.util.ts src/models/notification.model.ts src/utils/hid-card.util.ts src/utils/hid-json.util.ts src/utils/hid-access.util.ts src/models/customer-site.model.ts src/models/site-camera.model.ts src/models/member.model.ts src/models/subscription.model.ts src/utils/session-id.util.ts src/utils/occurrence-query.util.ts src/utils/occurrence-book-create.util.ts src/utils/update-result.util.ts src/utils/hid-amico-authz.util.ts src/utils/promo-code-currency.util.ts src/utils/console-audit.util.ts src/utils/org-suspension.util.ts src/utils/session-revoke.util.ts src/models/hid-amico.model.ts src/models/patrol-email.model.ts src/utils/patrol-email-pdf.util.ts src/utils/visitor-status.util.ts src/utils/self-service-email.util.ts src/utils/hid-secret.util.ts src/models/visitor-invite.model.ts src/models/guard-invite.model.ts src/utils/site-timezone.util.ts src/utils/bulletin-service-apps.util.ts src/models/bulletin-board.model.ts src/utils/vehicle-import.util.ts src/utils/expired-vehicle-sweep.util.ts src/models/vehicle.model.ts src/controllers/chat.controller.ts src/utils/file-owner.util.ts src/utils/console-permission.util.ts src/utils/role-scope.util.ts src/utils/org-default-roles.util.ts src/utils/org-modules.util.ts src/utils/site-modules.util.ts src/utils/resident-app-modules.util.ts src/utils/resident-default-role.util.ts src/utils/invite-role-scope.util.ts src/models/personal-emergency-chain.model.ts src/utils/self-signup-files.util.ts src/models/person.model.ts src/utils/module-gate.util.ts src/utils/member-lookup.util.ts src/utils/notification-access.util.ts src/utils/module-access.util.ts src/services/module-gate.service.ts src/controllers/site.controller.ts src/controllers/organization.controller.ts src/controllers/member.controller.ts src/utils/org-owner-repair.util.ts src/utils/socket-session.util.ts src/utils/people-create-gate.util.ts src/utils/service-app-type.util.ts src/utils/customer-site-list.util.ts src/utils/org-search.util.ts src/utils/invite-origin.util.ts --format esm --out-dir test/.build --no-dts --silent && node --test test/*.test.mjs",
|
|
17
17
|
"test:camera": "yarn test",
|
|
18
18
|
"test:e2e": "yarn build && node --test --test-concurrency=1 --test-timeout=600000 \"test/e2e/*.test.mjs\""
|
|
19
19
|
},
|
|
@@ -354,17 +354,18 @@ describe("invitations are scoped to an organisation the caller can reach", { con
|
|
|
354
354
|
assert.equal(res.status, 201, JSON.stringify(res.body));
|
|
355
355
|
});
|
|
356
356
|
|
|
357
|
-
record("18. an invitation that names NO organisation is
|
|
358
|
-
//
|
|
359
|
-
//
|
|
360
|
-
//
|
|
357
|
+
record("18. an invitation that names NO organisation is Seven365 staff's alone", async () => {
|
|
358
|
+
// Changed 2026-09-25 (owner report, org invite in the Seven365 console): an
|
|
359
|
+
// invitation naming no organisation is Seven365's - a new client or Seven365
|
|
360
|
+
// staff - and is listed as sent by Seven365 (`invite-origin.util.ts`). So
|
|
361
|
+
// an ordinary account can no longer send one; it used to get 201 here.
|
|
361
362
|
const res = await h.api("/auth/invite", {
|
|
362
363
|
method: "POST",
|
|
363
364
|
sid: mallorySid,
|
|
364
365
|
body: { email: "no-org@e2e.example.com", app: "organization", role: id.roleA.toString() },
|
|
365
366
|
});
|
|
366
367
|
|
|
367
|
-
assert.equal(res.status,
|
|
368
|
+
assert.equal(res.status, 401, JSON.stringify(res.body));
|
|
368
369
|
});
|
|
369
370
|
|
|
370
371
|
record("19. the seat-gated organisation invite still works for a member", async () => {
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
// Regression (prod 2026-09-25, Wing Tai / Winsland House I): the Invite member
|
|
2
|
+
// dialog's own request
|
|
3
|
+
// GET /api/roles?search&page=1&limit=100&type=property_management_agency&org=<org>&site=<site>
|
|
4
|
+
// must answer 200 with the organisation's roles for every way an owner/admin
|
|
5
|
+
// reaches their organisation. Run with: yarn test:e2e
|
|
6
|
+
import { after, before, describe, it } from "node:test";
|
|
7
|
+
import assert from "node:assert/strict";
|
|
8
|
+
import { ObjectId } from "mongodb";
|
|
9
|
+
import { startHarness } from "./harness.mjs";
|
|
10
|
+
|
|
11
|
+
const PASSWORD = "OwnerReach-Passw0rd!";
|
|
12
|
+
const PM = "property_management_agency";
|
|
13
|
+
const CASES = [
|
|
14
|
+
["PM member holding a '*' owner role", "pm-star@e2e.example.com", { type: PM, role: "pmOwner" }],
|
|
15
|
+
["org-console member holding an EMPTY-permission owner role", "org-empty@e2e.example.com", { type: "organization", role: "orgOwnerEmpty" }],
|
|
16
|
+
["member pinned to this site", "pinned@e2e.example.com", { type: PM, role: "pmOwner", pinSite: true }],
|
|
17
|
+
["org creator with no membership row yet", "creator@e2e.example.com", { creator: true }],
|
|
18
|
+
];
|
|
19
|
+
|
|
20
|
+
describe("Invite member role list: owner/admin reach", { concurrency: 1 }, () => {
|
|
21
|
+
let h; const id = {};
|
|
22
|
+
before(async () => { h = await startHarness(); Object.assign(id, await seed(h)); }, { timeout: 300000 });
|
|
23
|
+
after(async () => { if (h) await h.stop(); });
|
|
24
|
+
|
|
25
|
+
for (const [name, email] of CASES) {
|
|
26
|
+
it(`${name}: 200 with the org's roles`, async () => {
|
|
27
|
+
const sid = await h.login(email, PASSWORD);
|
|
28
|
+
const res = await h.api(`/roles?search&page=1&limit=100&type=${PM}&org=${id.org}&site=${id.site}`, { sid });
|
|
29
|
+
assert.equal(res.status, 200, JSON.stringify(res.body));
|
|
30
|
+
const names = res.body.items.map((r) => r.name).sort();
|
|
31
|
+
assert.ok(names.includes("owner"), JSON.stringify(names));
|
|
32
|
+
assert.equal(names.includes("Other site role"), false);
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
it("CONTROL: a member of ANOTHER organisation is refused", async () => {
|
|
37
|
+
const sid = await h.login("outsider@e2e.example.com", PASSWORD);
|
|
38
|
+
const res = await h.api(`/roles?search&page=1&limit=100&type=${PM}&org=${id.org}&site=${id.site}`, { sid });
|
|
39
|
+
assert.equal(res.status, 401);
|
|
40
|
+
});
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
async function seed(h) {
|
|
44
|
+
const now = new Date().toISOString();
|
|
45
|
+
const org = new ObjectId(), other = new ObjectId(), site = new ObjectId(), site2 = new ObjectId();
|
|
46
|
+
const r = { pmOwner: new ObjectId(), orgOwnerEmpty: new ObjectId(), otherSite: new ObjectId(), otherOrg: new ObjectId() };
|
|
47
|
+
const emails = [...CASES.map((c) => c[1]), "outsider@e2e.example.com"];
|
|
48
|
+
const users = await h.db.collection("users").insertMany(emails.map((email) => ({ email, name: email.split("@")[0], status: "active", createdAt: now })));
|
|
49
|
+
const uid = (e) => users.insertedIds[emails.indexOf(e)];
|
|
50
|
+
await h.db.collection("users").updateMany({ email: { $in: emails } }, { $set: { password: await h.hashPassword(PASSWORD) } });
|
|
51
|
+
await h.db.collection("organizations").insertMany([
|
|
52
|
+
{ _id: org, name: "Wing E2E", email: "wing-org@e2e.example.com", type: "org", nature: PM, status: "active", createdBy: uid("creator@e2e.example.com"), createdAt: now },
|
|
53
|
+
{ _id: other, name: "Other E2E", email: "other-org@e2e.example.com", type: "org", nature: PM, status: "active", createdAt: now },
|
|
54
|
+
]);
|
|
55
|
+
await h.db.collection("sites").insertMany([
|
|
56
|
+
{ _id: site, name: "Winsland E2E I", org, orgId: org, status: "active" },
|
|
57
|
+
{ _id: site2, name: "Winsland E2E II", org, orgId: org, status: "active" },
|
|
58
|
+
]);
|
|
59
|
+
await h.db.collection("roles").insertMany([
|
|
60
|
+
{ _id: r.pmOwner, name: "owner", type: PM, org, site: "", permissions: ["*"], default: true, status: "active" },
|
|
61
|
+
{ _id: r.orgOwnerEmpty, name: "owner", type: "organization", org, site: "", permissions: [], default: true, status: "active" },
|
|
62
|
+
{ _id: r.otherSite, name: "Other site role", type: PM, org, site: site2, permissions: [], status: "active" },
|
|
63
|
+
{ _id: r.otherOrg, name: "owner", type: PM, org: other, site: "", permissions: ["*"], status: "active" },
|
|
64
|
+
]);
|
|
65
|
+
const rows = [];
|
|
66
|
+
for (const [, email, m] of CASES) {
|
|
67
|
+
if (m.creator) continue;
|
|
68
|
+
rows.push({ user: uid(email), org, type: m.type, role: r[m.role], status: "active", ...(m.pinSite ? { siteId: site } : {}) });
|
|
69
|
+
}
|
|
70
|
+
rows.push({ user: uid("outsider@e2e.example.com"), org: other, type: PM, role: r.otherOrg, status: "active" });
|
|
71
|
+
await h.db.collection("members").insertMany(rows);
|
|
72
|
+
return { org, site };
|
|
73
|
+
}
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
// End-to-end proof for the owner report of 2026-09-25 (production): Aigle
|
|
2
|
+
// Security invited a person into its own organisation from the Organization
|
|
3
|
+
// app, and the invitation was listed in the Seven365 console's Invitations
|
|
4
|
+
// ("Invitations sent from Seven365") - which listed every client's invitations.
|
|
5
|
+
//
|
|
6
|
+
// Proved here against a real in-process MongoDB, over the real handlers:
|
|
7
|
+
// - a client's organisation invitation is stored with its org and role, is in
|
|
8
|
+
// the client's own list and never in Seven365's;
|
|
9
|
+
// - Seven365's own invitations (staff, new client, Invite Client into an
|
|
10
|
+
// existing client) are marked and listed, and so are unmarked org-less ones
|
|
11
|
+
// written before the marker;
|
|
12
|
+
// - only Seven365 staff may send an invitation naming no organisation, or read
|
|
13
|
+
// Seven365's list; an organisation invitation must name a role;
|
|
14
|
+
// - accepting the client's invitation makes the right membership.
|
|
15
|
+
//
|
|
16
|
+
// Nothing outside the harness is touched. Run with: yarn test:e2e
|
|
17
|
+
|
|
18
|
+
import { after, before, describe, it } from "node:test";
|
|
19
|
+
import assert from "node:assert/strict";
|
|
20
|
+
import { ObjectId } from "mongodb";
|
|
21
|
+
|
|
22
|
+
import { startHarness } from "./harness.mjs";
|
|
23
|
+
|
|
24
|
+
const PASSWORD = "OrgInviteScope-Passw0rd!";
|
|
25
|
+
const STAFF = "staff@e2e.example.com";
|
|
26
|
+
const OWNER = "aigle-owner@e2e.example.com";
|
|
27
|
+
const INVITEE = "kanesan@e2e.example.com";
|
|
28
|
+
const LIST = "/verifications?status=pending&type=user-invite,member-invite&limit=100";
|
|
29
|
+
|
|
30
|
+
describe("organisation invitations stay with their organisation", { concurrency: 1 }, () => {
|
|
31
|
+
let h;
|
|
32
|
+
let staff;
|
|
33
|
+
let owner;
|
|
34
|
+
const id = {};
|
|
35
|
+
let clientInvite;
|
|
36
|
+
|
|
37
|
+
before(async () => {
|
|
38
|
+
h = await startHarness();
|
|
39
|
+
Object.assign(id, await seed(h));
|
|
40
|
+
staff = await h.login(STAFF, PASSWORD);
|
|
41
|
+
owner = await h.login(OWNER, PASSWORD);
|
|
42
|
+
}, { timeout: 300000 });
|
|
43
|
+
|
|
44
|
+
after(async () => {
|
|
45
|
+
if (h) await h.stop();
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
const byEmail = (email) => h.db.collection("verifications").findOne({ email });
|
|
49
|
+
const seven365 = async () => {
|
|
50
|
+
const res = await h.api(`${LIST}&origin=seven365`, { sid: staff });
|
|
51
|
+
assert.equal(res.status, 200, JSON.stringify(res.body));
|
|
52
|
+
return res.body.items.map((i) => i.email);
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
it("the client's organisation invitation is stored with its org and role, and no origin", async () => {
|
|
56
|
+
const res = await h.api("/auth/invite/member", {
|
|
57
|
+
method: "POST",
|
|
58
|
+
sid: owner,
|
|
59
|
+
body: { email: INVITEE, app: "organization", org: id.aigle.toString(), role: id.aigleRole.toString(), siteId: "", siteName: "" },
|
|
60
|
+
});
|
|
61
|
+
assert.equal(res.status, 201, JSON.stringify(res.body));
|
|
62
|
+
clientInvite = await byEmail(INVITEE);
|
|
63
|
+
assert.equal(clientInvite.type, "member-invite");
|
|
64
|
+
assert.equal(String(clientInvite.metadata.org), String(id.aigle));
|
|
65
|
+
assert.equal(String(clientInvite.metadata.role), String(id.aigleRole));
|
|
66
|
+
assert.equal(clientInvite.metadata.app, "organization");
|
|
67
|
+
assert.equal(clientInvite.metadata.origin, undefined);
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
it("it is in the client's own Invitations list, with its role", async () => {
|
|
71
|
+
const res = await h.api(`/verifications?status=pending&type=member-invite&app=organization&orgId=${id.aigle}`, { sid: owner });
|
|
72
|
+
assert.equal(res.status, 200, JSON.stringify(res.body));
|
|
73
|
+
const row = res.body.items.find((i) => i.email === INVITEE);
|
|
74
|
+
assert.ok(row, "missing from the client's list");
|
|
75
|
+
assert.equal(row.roleName, "Aigle Supervisor");
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
it("Seven365's own invitations are marked seven365", async () => {
|
|
79
|
+
const staffInvite = await h.api("/auth/invite", {
|
|
80
|
+
method: "POST",
|
|
81
|
+
sid: staff,
|
|
82
|
+
body: { email: "new-staff@e2e.example.com", app: "admin", role: id.staffRole.toString(), name: "Super Admin" },
|
|
83
|
+
});
|
|
84
|
+
assert.equal(staffInvite.status, 201, JSON.stringify(staffInvite.body));
|
|
85
|
+
const newClient = await h.api("/auth/invite/user", {
|
|
86
|
+
method: "POST",
|
|
87
|
+
sid: staff,
|
|
88
|
+
body: { email: "new-client@e2e.example.com", app: ["security_agency"] },
|
|
89
|
+
});
|
|
90
|
+
assert.equal(newClient.status, 201, JSON.stringify(newClient.body));
|
|
91
|
+
const intoClient = await h.api("/auth/invite/user", {
|
|
92
|
+
method: "POST",
|
|
93
|
+
sid: staff,
|
|
94
|
+
body: { email: "console-into-aigle@e2e.example.com", app: ["organization"], org: id.aigle.toString(), role: id.aigleRole.toString() },
|
|
95
|
+
});
|
|
96
|
+
assert.equal(intoClient.status, 201, JSON.stringify(intoClient.body));
|
|
97
|
+
for (const email of ["new-staff@e2e.example.com", "new-client@e2e.example.com", "console-into-aigle@e2e.example.com"]) {
|
|
98
|
+
assert.equal((await byEmail(email)).metadata.origin, "seven365", email);
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
it("Seven365's list holds only what Seven365 sent - never the client's invitation", async () => {
|
|
103
|
+
const emails = await seven365();
|
|
104
|
+
assert.ok(!emails.includes(INVITEE), "the client's invitation is in Seven365's list");
|
|
105
|
+
assert.ok(!emails.includes("legacy-client@e2e.example.com"), "an unmarked client invitation is in Seven365's list");
|
|
106
|
+
for (const email of ["new-staff@e2e.example.com", "new-client@e2e.example.com", "console-into-aigle@e2e.example.com", "legacy-orgless@e2e.example.com"]) {
|
|
107
|
+
assert.ok(emails.includes(email), `${email} missing from Seven365's list`);
|
|
108
|
+
}
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
it("a client invitation sent by a Seven365 staff member from the Organization app is still the client's", async () => {
|
|
112
|
+
const res = await h.api("/auth/invite/member", {
|
|
113
|
+
method: "POST",
|
|
114
|
+
sid: staff,
|
|
115
|
+
body: { email: "staff-as-aigle@e2e.example.com", app: "organization", org: id.aigle.toString(), role: id.aigleRole.toString() },
|
|
116
|
+
});
|
|
117
|
+
assert.equal(res.status, 201, JSON.stringify(res.body));
|
|
118
|
+
assert.equal((await byEmail("staff-as-aigle@e2e.example.com")).metadata.origin, undefined);
|
|
119
|
+
assert.ok(!(await seven365()).includes("staff-as-aigle@e2e.example.com"));
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
it("a client cannot read Seven365's list, or send an invitation naming no organisation", async () => {
|
|
123
|
+
assert.equal((await h.api(`${LIST}&origin=seven365`, { sid: owner })).status, 401);
|
|
124
|
+
assert.equal((await h.api(`${LIST}&origin=seven365&orgId=${id.aigle}`, { sid: owner })).status, 401);
|
|
125
|
+
for (const [path, body] of [
|
|
126
|
+
["/auth/invite", { email: "orgless-1@e2e.example.com", app: "organization", role: id.aigleRole.toString() }],
|
|
127
|
+
["/auth/invite/member", { email: "orgless-2@e2e.example.com", app: "organization", role: id.aigleRole.toString() }],
|
|
128
|
+
["/auth/invite/user", { email: "orgless-3@e2e.example.com", app: ["organization"] }],
|
|
129
|
+
["/auth/v2/invite", { email: "orgless-4@e2e.example.com", app: "organization", role: id.aigleRole.toString() }],
|
|
130
|
+
]) {
|
|
131
|
+
const res = await h.api(path, { method: "POST", sid: owner, body });
|
|
132
|
+
assert.ok([400, 401].includes(res.status), `${path} ${res.status} ${JSON.stringify(res.body)}`);
|
|
133
|
+
}
|
|
134
|
+
assert.equal(await h.db.collection("verifications").countDocuments({ email: /^orgless-/ }), 0);
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
it("an organisation invitation must name a role", async () => {
|
|
138
|
+
const res = await h.api("/auth/invite/member", {
|
|
139
|
+
method: "POST",
|
|
140
|
+
sid: owner,
|
|
141
|
+
body: { email: "no-role@e2e.example.com", app: "organization", org: id.aigle.toString(), role: "" },
|
|
142
|
+
});
|
|
143
|
+
assert.equal(res.status, 400, JSON.stringify(res.body));
|
|
144
|
+
assert.match(JSON.stringify(res.body), /role/i);
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
it("accepting the client's invitation makes the membership in that client, with the chosen role", async () => {
|
|
148
|
+
const sid = await h.login(INVITEE, PASSWORD);
|
|
149
|
+
const res = await h.api(`/members/verification/${clientInvite._id}`, { method: "POST", sid });
|
|
150
|
+
assert.equal(res.status, 201, JSON.stringify(res.body));
|
|
151
|
+
const member = await h.db.collection("members").findOne({ user: id.invitee });
|
|
152
|
+
assert.ok(member, "no membership written");
|
|
153
|
+
assert.equal(String(member.org), String(id.aigle));
|
|
154
|
+
assert.equal(member.type, "organization");
|
|
155
|
+
assert.equal(String(member.role), String(id.aigleRole));
|
|
156
|
+
});
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
async function seed(h) {
|
|
160
|
+
const now = new Date().toISOString();
|
|
161
|
+
const later = new Date(Date.now() + 72 * 3600e3).toISOString();
|
|
162
|
+
const aigle = new ObjectId(), aigleRole = new ObjectId(), ownerRole = new ObjectId(), staffRole = new ObjectId();
|
|
163
|
+
|
|
164
|
+
await h.db.collection("organizations").insertOne({ _id: aigle, name: "Aigle E2E", email: "aigle@e2e.example.com", type: "org", nature: "security_agency", status: "active", createdAt: now });
|
|
165
|
+
await h.db.collection("roles").insertMany([
|
|
166
|
+
{ _id: staffRole, name: "Super Admin", type: "admin", default: true, permissions: [], status: "active" },
|
|
167
|
+
{ _id: ownerRole, name: "owner", type: "organization", org: aigle, site: "", permissions: ["*"], default: true, status: "active" },
|
|
168
|
+
{ _id: aigleRole, name: "Aigle Supervisor", type: "organization", org: aigle, site: "", permissions: [], status: "active" },
|
|
169
|
+
]);
|
|
170
|
+
await h.db.collection("subscriptions").insertOne({ org: aigle, type: "organization", status: "active", maxSeats: 0, paidSeats: 0, currentSeats: 0, createdAt: now });
|
|
171
|
+
|
|
172
|
+
const users = await h.db.collection("users").insertMany(
|
|
173
|
+
[STAFF, OWNER, INVITEE].map((email) => ({ email, name: email.split("@")[0], status: "active", createdAt: now })),
|
|
174
|
+
);
|
|
175
|
+
await h.db.collection("users").updateMany({}, { $set: { password: await h.hashPassword(PASSWORD) } });
|
|
176
|
+
await h.db.collection("members").insertMany([
|
|
177
|
+
{ user: users.insertedIds[0], type: "admin", role: staffRole, status: "active" },
|
|
178
|
+
{ user: users.insertedIds[1], org: aigle, type: "organization", role: ownerRole, status: "active" },
|
|
179
|
+
]);
|
|
180
|
+
|
|
181
|
+
// Written before the origin marker existed.
|
|
182
|
+
await h.db.collection("verifications").insertMany([
|
|
183
|
+
{ type: "user-invite", email: "legacy-orgless@e2e.example.com", metadata: { app: "security_agency", role: "", org: "" }, status: "pending", createdAt: now, expireAt: later },
|
|
184
|
+
{ type: "member-invite", email: "legacy-client@e2e.example.com", metadata: { app: "organization", role: aigleRole, org: aigle }, status: "pending", createdAt: now, expireAt: later },
|
|
185
|
+
]);
|
|
186
|
+
|
|
187
|
+
return { aigle, aigleRole, ownerRole, staffRole, invitee: users.insertedIds[2] };
|
|
188
|
+
}
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
// Owner decision (Harris, 2026-09-25): only the OWNING client organisation -
|
|
2
|
+
// a member whose role holds the existing "Delete Site" right (or `*`) - and
|
|
3
|
+
// Seven365 Super Admin may delete a site. A service provider that serves the
|
|
4
|
+
// site is refused with a plain message and keeps "Remove from your Sites".
|
|
5
|
+
//
|
|
6
|
+
// Everything runs against the throwaway in-process harness (in-memory MongoDB,
|
|
7
|
+
// loopback Redis and mail). Nothing outside this process is touched.
|
|
8
|
+
//
|
|
9
|
+
// Run with: yarn build && node --test test/e2e/site-delete-owner-only.e2e.test.mjs
|
|
10
|
+
|
|
11
|
+
import { after, before, describe, it } from "node:test";
|
|
12
|
+
import assert from "node:assert/strict";
|
|
13
|
+
import { ObjectId } from "mongodb";
|
|
14
|
+
|
|
15
|
+
import { startHarness } from "./harness.mjs";
|
|
16
|
+
|
|
17
|
+
const PASSWORD = "DeleteOwner-Passw0rd!";
|
|
18
|
+
const MANAGER = "do-manager@e2e.example.com"; // owning client, holds Delete Site
|
|
19
|
+
const VIEWER = "do-viewer@e2e.example.com"; // owning client, no Delete Site
|
|
20
|
+
const AGENCY = "do-agency@e2e.example.com"; // provider org admin, serves the site
|
|
21
|
+
const STAFF = "do-sevenadmin@e2e.example.com";
|
|
22
|
+
const REFUSAL =
|
|
23
|
+
"This site belongs to DO Client. Only they can delete it. You can remove it from your Sites list instead.";
|
|
24
|
+
|
|
25
|
+
describe("only the owning client (or Seven365) deletes a site", { concurrency: 1 }, () => {
|
|
26
|
+
let h;
|
|
27
|
+
const id = {};
|
|
28
|
+
const result = [];
|
|
29
|
+
const sid = {};
|
|
30
|
+
|
|
31
|
+
const record = (name, fn) =>
|
|
32
|
+
it(name, async () => {
|
|
33
|
+
try {
|
|
34
|
+
await fn();
|
|
35
|
+
result.push(["PASS", name]);
|
|
36
|
+
} catch (error) {
|
|
37
|
+
result.push(["FAIL", name]);
|
|
38
|
+
throw error;
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
const status = async (site) => (await h.db.collection("sites").findOne({ _id: site }))?.status;
|
|
43
|
+
|
|
44
|
+
before(async () => {
|
|
45
|
+
h = await startHarness();
|
|
46
|
+
Object.assign(id, await seed(h));
|
|
47
|
+
}, { timeout: 300000 });
|
|
48
|
+
|
|
49
|
+
after(async () => {
|
|
50
|
+
if (h) await h.stop();
|
|
51
|
+
console.log("\n--- site delete owner-only: per-case result ---");
|
|
52
|
+
for (const [verdict, name] of result) console.log(`${verdict} ${name}`);
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
record("0. baseline", async () => {
|
|
56
|
+
sid.manager = await h.login(MANAGER, PASSWORD);
|
|
57
|
+
sid.viewer = await h.login(VIEWER, PASSWORD);
|
|
58
|
+
sid.agency = await h.login(AGENCY, PASSWORD);
|
|
59
|
+
sid.staff = await h.login(STAFF, PASSWORD);
|
|
60
|
+
assert.equal(await status(id.tower), "active");
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
record("1. the provider that serves the site cannot delete it, and is told why", async () => {
|
|
64
|
+
const res = await h.api(`/sites/${id.tower}`, { method: "DELETE", sid: sid.agency });
|
|
65
|
+
assert.equal(res.status, 403, JSON.stringify(res.body));
|
|
66
|
+
assert.equal(res.body?.message, REFUSAL);
|
|
67
|
+
assert.equal(await status(id.tower), "active", "site untouched");
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
record("2. an owner-org member without Delete Site cannot delete it", async () => {
|
|
71
|
+
const res = await h.api(`/sites/${id.tower}`, { method: "DELETE", sid: sid.viewer });
|
|
72
|
+
assert.equal(res.status, 403, JSON.stringify(res.body));
|
|
73
|
+
assert.equal(res.body?.message, "You do not have permission to delete this site.");
|
|
74
|
+
assert.equal(await status(id.tower), "active");
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
record("3. the provider CAN still remove the site from its own Sites list", async () => {
|
|
78
|
+
const res = await h.api(`/customer-sites/${id.served}`, { method: "DELETE", sid: sid.agency });
|
|
79
|
+
assert.equal(res.status, 200, JSON.stringify(res.body));
|
|
80
|
+
const row = await h.db.collection("customer.sites").findOne({ _id: new ObjectId(id.served) });
|
|
81
|
+
assert.equal(row.status, "deleted");
|
|
82
|
+
assert.equal(await status(id.tower), "active", "the client's site itself is untouched");
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
record("4. the owner holding Delete Site CAN delete it", async () => {
|
|
86
|
+
const res = await h.api(`/sites/${id.tower}`, { method: "DELETE", sid: sid.manager });
|
|
87
|
+
assert.equal(res.status, 200, JSON.stringify(res.body));
|
|
88
|
+
assert.equal(await status(id.tower), "deleted");
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
record("5. Seven365 Super Admin CAN delete a client's site", async () => {
|
|
92
|
+
const res = await h.api(`/sites/${id.annex}`, { method: "DELETE", sid: sid.staff });
|
|
93
|
+
assert.equal(res.status, 200, JSON.stringify(res.body));
|
|
94
|
+
assert.equal(await status(id.annex), "deleted");
|
|
95
|
+
});
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
async function seed(h) {
|
|
99
|
+
const now = new Date().toISOString();
|
|
100
|
+
const client = new ObjectId();
|
|
101
|
+
const agency = new ObjectId();
|
|
102
|
+
const tower = new ObjectId();
|
|
103
|
+
const annex = new ObjectId();
|
|
104
|
+
const staffRole = new ObjectId();
|
|
105
|
+
const managerRole = new ObjectId();
|
|
106
|
+
const viewerRole = new ObjectId();
|
|
107
|
+
const agencyRole = new ObjectId();
|
|
108
|
+
|
|
109
|
+
await h.db.collection("organizations").insertMany([
|
|
110
|
+
{ _id: client, name: "DO Client", email: "do-client@e2e.example.com", type: "org", nature: "property_management_agency", status: "active", createdAt: now, defaultSite: tower.toString() },
|
|
111
|
+
{ _id: agency, name: "DO Agency", email: "do-agency-org@e2e.example.com", type: "org", nature: "security_agency", status: "active", createdAt: now },
|
|
112
|
+
]);
|
|
113
|
+
|
|
114
|
+
await h.db.collection("sites").insertMany([
|
|
115
|
+
{ _id: tower, name: "DO Tower", org: client, orgId: client, status: "active", timezone: "Asia/Singapore", createdAt: now },
|
|
116
|
+
{ _id: annex, name: "DO Annex", org: client, orgId: client, status: "active", timezone: "Asia/Singapore", createdAt: now },
|
|
117
|
+
]);
|
|
118
|
+
|
|
119
|
+
const rows = await h.db.collection("customer.sites").insertMany([
|
|
120
|
+
{ name: "DO Tower", org: agency, siteOrg: client, siteOrgName: "DO Client", site: tower, status: "active", createdAt: now },
|
|
121
|
+
{ name: "DO Tower", org: client, siteOrg: client, siteOrgName: "DO Client", site: tower, status: "active", createdAt: now },
|
|
122
|
+
]);
|
|
123
|
+
|
|
124
|
+
await h.db.collection("roles").insertMany([
|
|
125
|
+
{ _id: staffRole, name: "Super Admin", type: "admin", default: true, permissions: [], status: "active" },
|
|
126
|
+
{ _id: managerRole, name: "Site Admin", org: client, type: "organization", permissions: ["sites:see-all-sites", "sites:delete-site"], status: "active" },
|
|
127
|
+
{ _id: viewerRole, name: "Site Viewer", org: client, type: "organization", permissions: ["sites:see-all-sites"], status: "active" },
|
|
128
|
+
{ _id: agencyRole, name: "Owner", org: agency, type: "organization", permissions: ["*"], status: "active" },
|
|
129
|
+
]);
|
|
130
|
+
|
|
131
|
+
const emails = [MANAGER, VIEWER, AGENCY, STAFF];
|
|
132
|
+
const users = await h.db.collection("users").insertMany(
|
|
133
|
+
emails.map((email) => ({ email, name: email.split("@")[0], status: "active", createdAt: now })),
|
|
134
|
+
);
|
|
135
|
+
const hashed = await h.hashPassword(PASSWORD);
|
|
136
|
+
await h.db.collection("users").updateMany({ email: { $in: emails } }, { $set: { password: hashed } });
|
|
137
|
+
const [manager, viewer, agencyAdmin, staff] = [0, 1, 2, 3].map((i) => users.insertedIds[i]);
|
|
138
|
+
|
|
139
|
+
await h.db.collection("members").insertMany([
|
|
140
|
+
{ user: manager, org: client, type: "organization", role: managerRole, status: "active" },
|
|
141
|
+
{ user: viewer, org: client, type: "organization", role: viewerRole, status: "active" },
|
|
142
|
+
// the provider's company-wide admin: no membership in the client at all
|
|
143
|
+
{ user: agencyAdmin, org: agency, type: "organization", role: agencyRole, status: "active" },
|
|
144
|
+
{ user: staff, type: "admin", role: staffRole, status: "active" },
|
|
145
|
+
]);
|
|
146
|
+
|
|
147
|
+
return { tower, annex, served: rows.insertedIds[0].toString() };
|
|
148
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Who sent an invitation (owner report 2026-09-25: Aigle Security's own
|
|
3
|
+
* invitation was listed in the Seven365 console). The behaviour is proved over
|
|
4
|
+
* HTTP in `test/e2e/org-invite-scope.e2e.test.mjs`; this pins the filter and
|
|
5
|
+
* the wiring that silently rot when a handler is copied.
|
|
6
|
+
*/
|
|
7
|
+
import { test } from "node:test";
|
|
8
|
+
import assert from "node:assert/strict";
|
|
9
|
+
import { readFileSync } from "node:fs";
|
|
10
|
+
|
|
11
|
+
import {
|
|
12
|
+
SEVEN365_INVITE_ORIGIN,
|
|
13
|
+
seven365InviteQuery,
|
|
14
|
+
} from "./.build/utils/invite-origin.util.mjs";
|
|
15
|
+
|
|
16
|
+
test("Seven365's list = marked Seven365, or an unmarked invitation naming no organisation", () => {
|
|
17
|
+
assert.equal(SEVEN365_INVITE_ORIGIN, "seven365");
|
|
18
|
+
assert.deepEqual(seven365InviteQuery(), {
|
|
19
|
+
$or: [
|
|
20
|
+
{ "metadata.origin": "seven365" },
|
|
21
|
+
{ "metadata.origin": { $exists: false }, "metadata.org": { $in: ["", null] } },
|
|
22
|
+
],
|
|
23
|
+
});
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
const src = (f) => readFileSync(new URL(`../src/${f}`, import.meta.url), "utf8");
|
|
27
|
+
|
|
28
|
+
test("every member/user invite handler records its origin after its reach check", () => {
|
|
29
|
+
const v1 = src("controllers/verification.controller.ts");
|
|
30
|
+
const v2 = src("controllers/verification-v2.controller.ts");
|
|
31
|
+
assert.equal((v1.match(/requireInviteOrigin\(req, org, role\)/g) || []).length, 2);
|
|
32
|
+
assert.equal((v1.match(/requireInviteOrigin\(req, org, role, true\)/g) || []).length, 1);
|
|
33
|
+
assert.equal((v2.match(/requireInviteOrigin\(req, org, role\)/g) || []).length, 1);
|
|
34
|
+
assert.equal((v1.match(/\.\.\.origin/g) || []).length, 3);
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
test("the list endpoint takes origin and gates it to Seven365 staff", () => {
|
|
38
|
+
const v1 = src("controllers/verification.controller.ts");
|
|
39
|
+
assert.match(v1, /origin: Joi\.string\(\)\.valid\(SEVEN365_INVITE_ORIGIN\)/);
|
|
40
|
+
assert.match(v1, /requireVerificationListReach\(req, origin \? null : orgId\)/);
|
|
41
|
+
assert.match(src("repositories/verification.repo.ts"), /seven365InviteQuery\(\)/);
|
|
42
|
+
});
|
|
@@ -7,10 +7,12 @@ import {
|
|
|
7
7
|
DEFAULT_EMAIL_ALLOWLIST,
|
|
8
8
|
EMAIL_PER_MODULE_PER_HOUR,
|
|
9
9
|
codeMatches,
|
|
10
|
+
effectiveEmailAllowlist,
|
|
10
11
|
emailOpenToEveryone,
|
|
11
12
|
escapeHtml,
|
|
12
13
|
hashCode,
|
|
13
14
|
isEmailAllowed,
|
|
15
|
+
isProductionWebBase,
|
|
14
16
|
newCode,
|
|
15
17
|
notificationEmail,
|
|
16
18
|
offLink,
|
|
@@ -57,6 +59,71 @@ describe("allow-list (staging shares the production mailer)", () => {
|
|
|
57
59
|
});
|
|
58
60
|
});
|
|
59
61
|
|
|
62
|
+
const PROD = "https://account.app.iservice365.org";
|
|
63
|
+
const STAGING = "https://iservice365-staging-account.apptesting.work";
|
|
64
|
+
|
|
65
|
+
describe("which environment is production (positive identification only)", () => {
|
|
66
|
+
it("the production web domain is production", () => {
|
|
67
|
+
assert.equal(isProductionWebBase(PROD), true);
|
|
68
|
+
assert.equal(isProductionWebBase("https://app.iservice365.org"), true);
|
|
69
|
+
assert.equal(isProductionWebBase("https://iservice365.org/"), true);
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
it("staging, local, unset, unparsable and look-alikes are not", () => {
|
|
73
|
+
for (const base of [
|
|
74
|
+
STAGING,
|
|
75
|
+
"https://iservice365-staging-main.apptesting.work",
|
|
76
|
+
"http://localhost:3000",
|
|
77
|
+
"localhost",
|
|
78
|
+
"http:localhost:3000",
|
|
79
|
+
"",
|
|
80
|
+
"https://iservice365.org.evil.com",
|
|
81
|
+
"https://eviliservice365.org",
|
|
82
|
+
]) {
|
|
83
|
+
assert.equal(isProductionWebBase(base), false, base);
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
describe("the default when EMAIL_NOTIFICATIONS_ALLOWLIST is not set", () => {
|
|
89
|
+
it("env set: the list wins, on production too", () => {
|
|
90
|
+
assert.equal(effectiveEmailAllowlist("*@example.org", PROD), "*@example.org");
|
|
91
|
+
assert.equal(isEmailAllowed("someone@gmail.com", "*@seven365.com.sg", PROD), false);
|
|
92
|
+
assert.equal(emailOpenToEveryone("*@seven365.com.sg", PROD), false);
|
|
93
|
+
assert.equal(isEmailAllowed("someone@gmail.com", "*", STAGING), true);
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
it("production, unset: every verified address, and email is offered to everyone", () => {
|
|
97
|
+
for (const unset of [undefined, "", " "]) {
|
|
98
|
+
assert.equal(effectiveEmailAllowlist(unset, PROD), "*");
|
|
99
|
+
assert.equal(isEmailAllowed("someone@gmail.com", unset, PROD), true);
|
|
100
|
+
assert.equal(isEmailAllowed("security@seven365.com.sg", unset, PROD), true);
|
|
101
|
+
assert.equal(emailOpenToEveryone(unset, PROD), true);
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
it("staging, unset: Seven365 addresses only, email offered only to them", () => {
|
|
106
|
+
assert.equal(effectiveEmailAllowlist(undefined, STAGING), DEFAULT_EMAIL_ALLOWLIST);
|
|
107
|
+
assert.equal(isEmailAllowed("someone@gmail.com", undefined, STAGING), false);
|
|
108
|
+
assert.equal(isEmailAllowed("security@seven365.com.sg", undefined, STAGING), true);
|
|
109
|
+
assert.equal(emailOpenToEveryone(undefined, STAGING), false);
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
it("unknown or local, unset: fails closed like staging", () => {
|
|
113
|
+
for (const base of ["", "http://localhost:3000", "not a url"]) {
|
|
114
|
+
assert.equal(isEmailAllowed("someone@gmail.com", undefined, base), false, base);
|
|
115
|
+
assert.equal(isEmailAllowed("security@seven365.com.sg", undefined, base), true, base);
|
|
116
|
+
assert.equal(emailOpenToEveryone(undefined, base), false, base);
|
|
117
|
+
}
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
it("garbage is never allowed, even on production", () => {
|
|
121
|
+
for (const bad of ["", null, undefined, "no-at-sign", 42]) {
|
|
122
|
+
assert.equal(isEmailAllowed(bad, undefined, PROD), false, String(bad));
|
|
123
|
+
}
|
|
124
|
+
});
|
|
125
|
+
});
|
|
126
|
+
|
|
60
127
|
describe("turn-off token (no sign-in, tamper-proof)", () => {
|
|
61
128
|
const t = offToken(U, "feedback", SECRET);
|
|
62
129
|
|
|
@@ -2,7 +2,9 @@ import assert from "node:assert/strict";
|
|
|
2
2
|
import test from "node:test";
|
|
3
3
|
|
|
4
4
|
import {
|
|
5
|
+
mayDeleteSite,
|
|
5
6
|
mayEditSiteDetails,
|
|
7
|
+
siteDeleteOwnerOnlyMessage,
|
|
6
8
|
siteOwnerOnlyMessage,
|
|
7
9
|
touchesSiteOwnerFields,
|
|
8
10
|
} from "./.build/utils/site-owner-edit.util.mjs";
|
|
@@ -50,3 +52,19 @@ test("the refusal names the owner, or says another organisation", () => {
|
|
|
50
52
|
"This site belongs to another organisation. Only they can change its details.",
|
|
51
53
|
);
|
|
52
54
|
});
|
|
55
|
+
|
|
56
|
+
// Owner decision 2026-09-25: only the owning client (with "Delete Site") deletes a site.
|
|
57
|
+
test("deleting needs the owner's Delete Site right or the wildcard", () => {
|
|
58
|
+
assert.equal(mayDeleteSite(["sites:delete-site"]), true);
|
|
59
|
+
assert.equal(mayDeleteSite(["*"]), true);
|
|
60
|
+
assert.equal(mayDeleteSite(["sites:see-all-sites", "sites:add-site"]), false);
|
|
61
|
+
assert.equal(mayDeleteSite([]), false);
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
test("the provider's refusal names the owner and points at Remove from your Sites", () => {
|
|
65
|
+
assert.equal(
|
|
66
|
+
siteDeleteOwnerOnlyMessage("Management Pte Ltd"),
|
|
67
|
+
"This site belongs to Management Pte Ltd. Only they can delete it. You can remove it from your Sites list instead.",
|
|
68
|
+
);
|
|
69
|
+
assert.match(siteDeleteOwnerOnlyMessage(null), /^This site belongs to another organisation\./);
|
|
70
|
+
});
|
|
@@ -71,7 +71,8 @@ test("the cancel gate reads the STORED verification, never the request", () => {
|
|
|
71
71
|
|
|
72
72
|
test("the v1 list gate is handed the caller's own orgId, not a literal", () => {
|
|
73
73
|
const body = fn(v1, "getVerifications");
|
|
74
|
-
|
|
74
|
+
// Seven365's own list (origin) is staff-only whatever org is named.
|
|
75
|
+
assert.match(body, /requireVerificationListReach\(req, origin \? null : orgId\)/);
|
|
75
76
|
});
|
|
76
77
|
|
|
77
78
|
test("an omitted organisation costs Seven365 staff identity", () => {
|