@proconnect-gouv/proconnect.identite.runtime 0.3.1 → 0.5.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 +37 -0
- package/dist/activity/activity-context-schemas.d.ts +104 -0
- package/dist/activity/activity-context-schemas.d.ts.map +1 -1
- package/dist/activity/activity-context-schemas.js +6 -0
- package/dist/activity/types.d.ts +3 -0
- package/dist/activity/types.d.ts.map +1 -1
- package/dist/franceconnect/activities.d.ts +16 -0
- package/dist/franceconnect/activities.d.ts.map +1 -0
- package/dist/franceconnect/activities.js +17 -0
- package/dist/franceconnect/connect-franceconnect.d.ts +20 -0
- package/dist/franceconnect/connect-franceconnect.d.ts.map +1 -0
- package/dist/franceconnect/connect-franceconnect.js +59 -0
- package/dist/franceconnect/disconnect-franceconnect.d.ts +14 -0
- package/dist/franceconnect/disconnect-franceconnect.d.ts.map +1 -0
- package/dist/franceconnect/disconnect-franceconnect.js +29 -0
- package/dist/franceconnect/index.d.ts +4 -0
- package/dist/franceconnect/index.d.ts.map +1 -0
- package/dist/franceconnect/index.js +4 -0
- package/dist/journal/insert-activity.js +6 -0
- package/dist/memberships/activities.d.ts +27 -0
- package/dist/memberships/activities.d.ts.map +1 -1
- package/dist/memberships/activities.js +27 -0
- package/dist/memberships/add-membership.d.ts +22 -0
- package/dist/memberships/add-membership.d.ts.map +1 -0
- package/dist/memberships/add-membership.js +46 -0
- package/dist/memberships/index.d.ts +3 -0
- package/dist/memberships/index.d.ts.map +1 -1
- package/dist/memberships/index.js +3 -0
- package/dist/memberships/remove-membership.d.ts +19 -0
- package/dist/memberships/remove-membership.d.ts.map +1 -0
- package/dist/memberships/remove-membership.js +29 -0
- package/dist/memberships/update-membership.d.ts +31 -0
- package/dist/memberships/update-membership.d.ts.map +1 -0
- package/dist/memberships/update-membership.js +61 -0
- package/dist/moderations/activities.d.ts +11 -0
- package/dist/moderations/activities.d.ts.map +1 -0
- package/dist/moderations/activities.js +12 -0
- package/dist/moderations/index.d.ts +3 -0
- package/dist/moderations/index.d.ts.map +1 -0
- package/dist/moderations/index.js +3 -0
- package/dist/moderations/open-moderation.d.ts +18 -0
- package/dist/moderations/open-moderation.d.ts.map +1 -0
- package/dist/moderations/open-moderation.js +31 -0
- package/dist/runtime/create-identite-runtime.d.ts +152 -0
- package/dist/runtime/create-identite-runtime.d.ts.map +1 -1
- package/dist/runtime/create-identite-runtime.js +22 -0
- package/dist/users/activities.d.ts +62 -0
- package/dist/users/activities.d.ts.map +1 -0
- package/dist/users/activities.js +54 -0
- package/dist/users/change-password.d.ts +16 -0
- package/dist/users/change-password.d.ts.map +1 -0
- package/dist/users/change-password.js +38 -0
- package/dist/users/delete-user.d.ts +14 -0
- package/dist/users/delete-user.d.ts.map +1 -0
- package/dist/users/delete-user.js +39 -0
- package/dist/users/index.d.ts +6 -0
- package/dist/users/index.d.ts.map +1 -0
- package/dist/users/index.js +6 -0
- package/dist/users/reset-mfa.d.ts +14 -0
- package/dist/users/reset-mfa.d.ts.map +1 -0
- package/dist/users/reset-mfa.js +53 -0
- package/dist/users/update-personal-informations.d.ts +21 -0
- package/dist/users/update-personal-informations.d.ts.map +1 -0
- package/dist/users/update-personal-informations.js +53 -0
- package/package.json +5 -4
- package/src/activity/activity-context-schemas.ts +6 -0
- package/src/activity/types.ts +2 -1
- package/src/domains/mark-domain-as-verified.test.ts +162 -243
- package/src/franceconnect/activities.ts +20 -0
- package/src/franceconnect/connect-franceconnect.test.ts +197 -0
- package/src/franceconnect/connect-franceconnect.ts +96 -0
- package/src/franceconnect/disconnect-franceconnect.test.ts +94 -0
- package/src/franceconnect/disconnect-franceconnect.ts +53 -0
- package/src/franceconnect/index.ts +5 -0
- package/src/journal/insert-activity.ts +6 -0
- package/src/memberships/activities.ts +27 -0
- package/src/memberships/add-membership.test.ts +129 -0
- package/src/memberships/add-membership.ts +80 -0
- package/src/memberships/index.ts +3 -0
- package/src/memberships/remove-membership.test.ts +122 -0
- package/src/memberships/remove-membership.ts +59 -0
- package/src/memberships/update-membership.test.ts +202 -0
- package/src/memberships/update-membership.ts +106 -0
- package/src/moderations/activities.ts +15 -0
- package/src/moderations/index.ts +4 -0
- package/src/moderations/open-moderation.test.ts +99 -0
- package/src/moderations/open-moderation.ts +59 -0
- package/src/runtime/create-identite-runtime.test.ts +20 -51
- package/src/runtime/create-identite-runtime.ts +34 -0
- package/src/users/activities.ts +60 -0
- package/src/users/change-password.test.ts +91 -0
- package/src/users/change-password.ts +64 -0
- package/src/users/delete-user.test.ts +142 -0
- package/src/users/delete-user.ts +60 -0
- package/src/users/index.ts +7 -0
- package/src/users/reset-mfa.test.ts +128 -0
- package/src/users/reset-mfa.ts +79 -0
- package/src/users/update-personal-informations.test.ts +113 -0
- package/src/users/update-personal-informations.ts +97 -0
- package/testing/index.ts +25 -0
- package/tsconfig.json +1 -1
|
@@ -1,66 +1,104 @@
|
|
|
1
1
|
//
|
|
2
2
|
|
|
3
|
-
import type {
|
|
3
|
+
import type { IdentiteDatabase } from "#src/database";
|
|
4
4
|
import { createIdentiteRuntime } from "#src/runtime";
|
|
5
|
-
import {
|
|
5
|
+
import { createTestDatabase, readActivityLogs } from "#testing";
|
|
6
6
|
import * as schema from "@proconnect-gouv/proconnect.identite.database/drizzle";
|
|
7
|
-
import {
|
|
8
|
-
import { drizzle } from "drizzle-orm/pglite";
|
|
7
|
+
import { sql } from "drizzle-orm";
|
|
9
8
|
import assert from "node:assert/strict";
|
|
10
9
|
import { before, describe, it, mock } from "node:test";
|
|
11
10
|
|
|
12
11
|
//
|
|
13
12
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
13
|
+
async function setup() {
|
|
14
|
+
const db = await createTestDatabase();
|
|
15
|
+
await db.insert(schema.organizations).values([
|
|
16
|
+
{ id: 1, siret: "🦁" },
|
|
17
|
+
{ id: 2, siret: "🐺" },
|
|
18
|
+
]);
|
|
19
|
+
await db.insert(schema.users).values(
|
|
20
|
+
[
|
|
21
|
+
"lion.eljonson+promoted@darkangels.world",
|
|
22
|
+
"azrael+promoted@darkangels.world",
|
|
23
|
+
"luther+kept-dirigeant@darkangels.world",
|
|
24
|
+
"leman.russ+kept-other-domain@spacewolves.world",
|
|
25
|
+
].map((email, index) => ({
|
|
26
|
+
created_at: "4444-04-04",
|
|
27
|
+
email,
|
|
28
|
+
id: index + 1,
|
|
29
|
+
updated_at: "4444-04-04",
|
|
30
|
+
})),
|
|
31
|
+
);
|
|
32
|
+
await db.insert(schema.users_organizations).values(
|
|
33
|
+
[
|
|
34
|
+
{
|
|
35
|
+
organization_id: 1,
|
|
36
|
+
user_id: 1,
|
|
37
|
+
verification_type:
|
|
38
|
+
"no_verification_means_for_entreprise_unipersonnelle",
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
organization_id: 1,
|
|
42
|
+
user_id: 2,
|
|
43
|
+
verification_type: "domain_not_verified_yet",
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
organization_id: 1,
|
|
47
|
+
user_id: 3,
|
|
48
|
+
verification_type: "organization_dirigeant",
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
organization_id: 1,
|
|
52
|
+
user_id: 4,
|
|
53
|
+
verification_type: "no_validation_means_available",
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
organization_id: 2,
|
|
57
|
+
user_id: 1,
|
|
58
|
+
verification_type: "no_validation_means_available",
|
|
59
|
+
},
|
|
60
|
+
].map((membership) => ({
|
|
61
|
+
...membership,
|
|
62
|
+
created_at: "4444-04-04",
|
|
63
|
+
updated_at: "4444-04-04",
|
|
64
|
+
})),
|
|
65
|
+
);
|
|
66
|
+
await db.insert(schema.email_domains).values(
|
|
67
|
+
[
|
|
68
|
+
{
|
|
69
|
+
domain: "darkangels.world",
|
|
70
|
+
organization_id: 1,
|
|
71
|
+
verification_type: "not_verified_yet",
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
domain: "darkangels.world",
|
|
75
|
+
organization_id: 1,
|
|
76
|
+
verification_type: "refused",
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
domain: "calibanites.world",
|
|
80
|
+
organization_id: 1,
|
|
81
|
+
verification_type: "verified",
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
domain: "darkangels.world",
|
|
85
|
+
organization_id: 2,
|
|
86
|
+
verification_type: "not_verified_yet",
|
|
87
|
+
},
|
|
88
|
+
].map((email_domain, index) => ({
|
|
89
|
+
...email_domain,
|
|
90
|
+
created_at: "4444-04-04",
|
|
91
|
+
id: index + 1,
|
|
92
|
+
updated_at: "4444-04-04",
|
|
93
|
+
})),
|
|
94
|
+
);
|
|
57
95
|
|
|
58
96
|
return {
|
|
59
|
-
|
|
60
|
-
runtime: createIdentiteRuntime({
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
})
|
|
97
|
+
db,
|
|
98
|
+
runtime: createIdentiteRuntime({ app: "hyyypertool", db }).as({
|
|
99
|
+
type: "moderator",
|
|
100
|
+
sub: "moderator+verifies-darkangels.world",
|
|
101
|
+
}),
|
|
64
102
|
};
|
|
65
103
|
}
|
|
66
104
|
|
|
@@ -70,12 +108,12 @@ describe("markDomainAsVerified", () => {
|
|
|
70
108
|
});
|
|
71
109
|
|
|
72
110
|
it("❎ returns organization_not_found for an unknown organization", async () => {
|
|
73
|
-
const {
|
|
74
|
-
const before = await snapshot(
|
|
111
|
+
const { db, runtime } = await setup();
|
|
112
|
+
const before = await snapshot(db);
|
|
75
113
|
|
|
76
114
|
const outcome = await runtime.markDomainAsVerified({
|
|
77
115
|
domain: "notfound.world",
|
|
78
|
-
domain_verification_type: "
|
|
116
|
+
domain_verification_type: "verified",
|
|
79
117
|
organization_id: 404,
|
|
80
118
|
});
|
|
81
119
|
|
|
@@ -83,30 +121,30 @@ describe("markDomainAsVerified", () => {
|
|
|
83
121
|
kind: "organization_not_found",
|
|
84
122
|
organization_id: 404,
|
|
85
123
|
});
|
|
86
|
-
assert.deepEqual(await snapshot(
|
|
87
|
-
assert.deepEqual(await readActivityLogs(
|
|
124
|
+
assert.deepEqual(await snapshot(db), before);
|
|
125
|
+
assert.deepEqual(await readActivityLogs(db), []);
|
|
88
126
|
});
|
|
89
127
|
|
|
90
|
-
it("✅ replaces the domain states, promotes the domain members and journals the verification and each promotion", async () => {
|
|
91
|
-
const {
|
|
128
|
+
it("✅ replaces the domain states, promotes the domain members and journals the verification under the moderator and each promotion under the app", async () => {
|
|
129
|
+
const { db, runtime } = await setup();
|
|
92
130
|
|
|
93
131
|
const outcome = await runtime.markDomainAsVerified({
|
|
94
132
|
domain: "darkangels.world",
|
|
95
|
-
domain_verification_type: "
|
|
133
|
+
domain_verification_type: "verified",
|
|
96
134
|
organization_id: 1,
|
|
97
135
|
});
|
|
98
136
|
|
|
99
|
-
const {
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
);
|
|
137
|
+
const verified_domain = await db.query.email_domains.findFirst({
|
|
138
|
+
columns: { id: true },
|
|
139
|
+
where: (table, { and, eq }) =>
|
|
140
|
+
and(eq(table.domain, "darkangels.world"), eq(table.organization_id, 1)),
|
|
141
|
+
});
|
|
104
142
|
assert.deepEqual(outcome, {
|
|
105
143
|
kind: "domain_verified",
|
|
106
144
|
activity_id: 1,
|
|
107
145
|
email_domain: {
|
|
108
|
-
id:
|
|
109
|
-
verification_type: "
|
|
146
|
+
id: verified_domain?.id,
|
|
147
|
+
verification_type: "verified",
|
|
110
148
|
},
|
|
111
149
|
promoted_members: [
|
|
112
150
|
{
|
|
@@ -119,23 +157,25 @@ describe("markDomainAsVerified", () => {
|
|
|
119
157
|
replaced_verification_types: ["not_verified_yet", "refused"],
|
|
120
158
|
});
|
|
121
159
|
assert.deepEqual(
|
|
122
|
-
(
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
160
|
+
await db.query.email_domains.findMany({
|
|
161
|
+
columns: {
|
|
162
|
+
can_be_suggested: true,
|
|
163
|
+
created_at: true,
|
|
164
|
+
domain: true,
|
|
165
|
+
organization_id: true,
|
|
166
|
+
verification_type: true,
|
|
167
|
+
verified_at: true,
|
|
168
|
+
},
|
|
169
|
+
orderBy: (table, { asc }) => [
|
|
170
|
+
asc(table.organization_id),
|
|
171
|
+
asc(table.domain),
|
|
172
|
+
asc(table.verification_type),
|
|
173
|
+
],
|
|
174
|
+
}),
|
|
135
175
|
[
|
|
136
176
|
{
|
|
137
177
|
can_be_suggested: true,
|
|
138
|
-
created_at:
|
|
178
|
+
created_at: "4444-04-04 00:00:00+00",
|
|
139
179
|
domain: "calibanites.world",
|
|
140
180
|
organization_id: 1,
|
|
141
181
|
verification_type: "verified",
|
|
@@ -143,15 +183,15 @@ describe("markDomainAsVerified", () => {
|
|
|
143
183
|
},
|
|
144
184
|
{
|
|
145
185
|
can_be_suggested: true,
|
|
146
|
-
created_at:
|
|
186
|
+
created_at: "5555-05-05 00:00:00+00",
|
|
147
187
|
domain: "darkangels.world",
|
|
148
188
|
organization_id: 1,
|
|
149
|
-
verification_type: "
|
|
150
|
-
verified_at:
|
|
189
|
+
verification_type: "verified",
|
|
190
|
+
verified_at: "5555-05-05 00:00:00+00",
|
|
151
191
|
},
|
|
152
192
|
{
|
|
153
193
|
can_be_suggested: true,
|
|
154
|
-
created_at:
|
|
194
|
+
created_at: "4444-04-04 00:00:00+00",
|
|
155
195
|
domain: "darkangels.world",
|
|
156
196
|
organization_id: 2,
|
|
157
197
|
verification_type: "not_verified_yet",
|
|
@@ -160,149 +200,52 @@ describe("markDomainAsVerified", () => {
|
|
|
160
200
|
],
|
|
161
201
|
);
|
|
162
202
|
assert.deepEqual(
|
|
163
|
-
(
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
203
|
+
await db.query.users_organizations.findMany({
|
|
204
|
+
columns: {
|
|
205
|
+
organization_id: true,
|
|
206
|
+
updated_at: true,
|
|
207
|
+
user_id: true,
|
|
208
|
+
verification_type: true,
|
|
209
|
+
},
|
|
210
|
+
orderBy: (table, { asc }) => [
|
|
211
|
+
asc(table.organization_id),
|
|
212
|
+
asc(table.user_id),
|
|
213
|
+
],
|
|
214
|
+
}),
|
|
174
215
|
[
|
|
175
216
|
{
|
|
176
217
|
organization_id: 1,
|
|
177
|
-
updated_at:
|
|
218
|
+
updated_at: "5555-05-05 00:00:00+00",
|
|
178
219
|
user_id: 1,
|
|
179
220
|
verification_type: "domain",
|
|
180
221
|
},
|
|
181
222
|
{
|
|
182
223
|
organization_id: 1,
|
|
183
|
-
updated_at:
|
|
224
|
+
updated_at: "5555-05-05 00:00:00+00",
|
|
184
225
|
user_id: 2,
|
|
185
226
|
verification_type: "domain",
|
|
186
227
|
},
|
|
187
228
|
{
|
|
188
229
|
organization_id: 1,
|
|
189
|
-
updated_at:
|
|
230
|
+
updated_at: "4444-04-04 00:00:00+00",
|
|
190
231
|
user_id: 3,
|
|
191
232
|
verification_type: "organization_dirigeant",
|
|
192
233
|
},
|
|
193
234
|
{
|
|
194
235
|
organization_id: 1,
|
|
195
|
-
updated_at:
|
|
236
|
+
updated_at: "4444-04-04 00:00:00+00",
|
|
196
237
|
user_id: 4,
|
|
197
238
|
verification_type: "no_validation_means_available",
|
|
198
239
|
},
|
|
199
240
|
{
|
|
200
241
|
organization_id: 2,
|
|
201
|
-
updated_at:
|
|
242
|
+
updated_at: "4444-04-04 00:00:00+00",
|
|
202
243
|
user_id: 1,
|
|
203
244
|
verification_type: "no_validation_means_available",
|
|
204
245
|
},
|
|
205
246
|
],
|
|
206
247
|
);
|
|
207
|
-
assert.deepEqual(await readActivityLogs(
|
|
208
|
-
{
|
|
209
|
-
action: "domain.verified",
|
|
210
|
-
actor_ref: "join.official_contact",
|
|
211
|
-
actor_type: "app",
|
|
212
|
-
app: "proconnect-identite",
|
|
213
|
-
cause_activity_id: null,
|
|
214
|
-
context: {
|
|
215
|
-
inputs: {
|
|
216
|
-
domain: "darkangels.world",
|
|
217
|
-
verification_type: "official_contact",
|
|
218
|
-
},
|
|
219
|
-
outcome: {
|
|
220
|
-
email_domain_id: official_contact_domain?.id,
|
|
221
|
-
replaced_verification_types: ["not_verified_yet", "refused"],
|
|
222
|
-
},
|
|
223
|
-
},
|
|
224
|
-
created_at: new Date("5555-05-05"),
|
|
225
|
-
id: 1,
|
|
226
|
-
interaction_cid: null,
|
|
227
|
-
moderation_id: null,
|
|
228
|
-
organization_id: 1,
|
|
229
|
-
user_id: null,
|
|
230
|
-
},
|
|
231
|
-
{
|
|
232
|
-
action: "member.promoted",
|
|
233
|
-
actor_ref: "domain.promote_members",
|
|
234
|
-
actor_type: "app",
|
|
235
|
-
app: "proconnect-identite",
|
|
236
|
-
cause_activity_id: 1,
|
|
237
|
-
context: {
|
|
238
|
-
inputs: {
|
|
239
|
-
previous_verification_type:
|
|
240
|
-
"no_verification_means_for_entreprise_unipersonnelle",
|
|
241
|
-
},
|
|
242
|
-
outcome: { verification_type: "domain" },
|
|
243
|
-
},
|
|
244
|
-
created_at: new Date("5555-05-05"),
|
|
245
|
-
id: 2,
|
|
246
|
-
interaction_cid: null,
|
|
247
|
-
moderation_id: null,
|
|
248
|
-
organization_id: 1,
|
|
249
|
-
user_id: 1,
|
|
250
|
-
},
|
|
251
|
-
{
|
|
252
|
-
action: "member.promoted",
|
|
253
|
-
actor_ref: "domain.promote_members",
|
|
254
|
-
actor_type: "app",
|
|
255
|
-
app: "proconnect-identite",
|
|
256
|
-
cause_activity_id: 1,
|
|
257
|
-
context: {
|
|
258
|
-
inputs: { previous_verification_type: "domain_not_verified_yet" },
|
|
259
|
-
outcome: { verification_type: "domain" },
|
|
260
|
-
},
|
|
261
|
-
created_at: new Date("5555-05-05"),
|
|
262
|
-
id: 3,
|
|
263
|
-
interaction_cid: null,
|
|
264
|
-
moderation_id: null,
|
|
265
|
-
organization_id: 1,
|
|
266
|
-
user_id: 2,
|
|
267
|
-
},
|
|
268
|
-
]);
|
|
269
|
-
});
|
|
270
|
-
|
|
271
|
-
it("✅ journals the verification under the moderator and each promotion under the app", async () => {
|
|
272
|
-
const { pg, runtime } = await setup({
|
|
273
|
-
actor: { type: "moderator", sub: "moderator+verifies-darkangels.world" },
|
|
274
|
-
app: "hyyypertool",
|
|
275
|
-
});
|
|
276
|
-
|
|
277
|
-
const outcome = await runtime.markDomainAsVerified({
|
|
278
|
-
domain: "darkangels.world",
|
|
279
|
-
domain_verification_type: "verified",
|
|
280
|
-
organization_id: 1,
|
|
281
|
-
});
|
|
282
|
-
|
|
283
|
-
const {
|
|
284
|
-
rows: [verified_domain],
|
|
285
|
-
} = await pg.query<{ id: number }>(
|
|
286
|
-
"SELECT id FROM email_domains WHERE domain = 'darkangels.world' AND verification_type = 'verified'",
|
|
287
|
-
);
|
|
288
|
-
assert.deepEqual(outcome, {
|
|
289
|
-
kind: "domain_verified",
|
|
290
|
-
activity_id: 1,
|
|
291
|
-
email_domain: {
|
|
292
|
-
id: verified_domain?.id,
|
|
293
|
-
verification_type: "verified",
|
|
294
|
-
},
|
|
295
|
-
promoted_members: [
|
|
296
|
-
{
|
|
297
|
-
previous_verification_type:
|
|
298
|
-
"no_verification_means_for_entreprise_unipersonnelle",
|
|
299
|
-
user_id: 1,
|
|
300
|
-
},
|
|
301
|
-
{ previous_verification_type: "domain_not_verified_yet", user_id: 2 },
|
|
302
|
-
],
|
|
303
|
-
replaced_verification_types: ["not_verified_yet", "refused"],
|
|
304
|
-
});
|
|
305
|
-
assert.deepEqual(await readActivityLogs(pg), [
|
|
248
|
+
assert.deepEqual(await readActivityLogs(db), [
|
|
306
249
|
{
|
|
307
250
|
action: "domain.verified",
|
|
308
251
|
actor_ref: "moderator+verifies-darkangels.world",
|
|
@@ -319,8 +262,6 @@ describe("markDomainAsVerified", () => {
|
|
|
319
262
|
replaced_verification_types: ["not_verified_yet", "refused"],
|
|
320
263
|
},
|
|
321
264
|
},
|
|
322
|
-
created_at: new Date("5555-05-05"),
|
|
323
|
-
id: 1,
|
|
324
265
|
interaction_cid: null,
|
|
325
266
|
moderation_id: null,
|
|
326
267
|
organization_id: 1,
|
|
@@ -339,8 +280,6 @@ describe("markDomainAsVerified", () => {
|
|
|
339
280
|
},
|
|
340
281
|
outcome: { verification_type: "domain" },
|
|
341
282
|
},
|
|
342
|
-
created_at: new Date("5555-05-05"),
|
|
343
|
-
id: 2,
|
|
344
283
|
interaction_cid: null,
|
|
345
284
|
moderation_id: null,
|
|
346
285
|
organization_id: 1,
|
|
@@ -356,8 +295,6 @@ describe("markDomainAsVerified", () => {
|
|
|
356
295
|
inputs: { previous_verification_type: "domain_not_verified_yet" },
|
|
357
296
|
outcome: { verification_type: "domain" },
|
|
358
297
|
},
|
|
359
|
-
created_at: new Date("5555-05-05"),
|
|
360
|
-
id: 3,
|
|
361
298
|
interaction_cid: null,
|
|
362
299
|
moderation_id: null,
|
|
363
300
|
organization_id: 1,
|
|
@@ -367,57 +304,39 @@ describe("markDomainAsVerified", () => {
|
|
|
367
304
|
});
|
|
368
305
|
|
|
369
306
|
it("❎ rolls back the domain state and its journal row when a member update fails", async () => {
|
|
370
|
-
const {
|
|
371
|
-
await
|
|
307
|
+
const { db, runtime } = await setup();
|
|
308
|
+
await db.execute(sql`
|
|
372
309
|
ALTER TABLE users_organizations
|
|
373
310
|
ADD CONSTRAINT users_organizations_never_domain
|
|
374
|
-
CHECK (verification_type <> 'domain')
|
|
311
|
+
CHECK (verification_type <> 'domain')
|
|
375
312
|
`);
|
|
376
|
-
const before = await snapshot(
|
|
313
|
+
const before = await snapshot(db);
|
|
377
314
|
|
|
378
315
|
await assert.rejects(
|
|
379
316
|
runtime.markDomainAsVerified({
|
|
380
317
|
domain: "darkangels.world",
|
|
381
|
-
domain_verification_type: "
|
|
318
|
+
domain_verification_type: "verified",
|
|
382
319
|
organization_id: 1,
|
|
383
320
|
}),
|
|
384
321
|
(error: Error) =>
|
|
385
322
|
error.cause instanceof Error &&
|
|
386
323
|
error.cause.message.includes("users_organizations_never_domain"),
|
|
387
324
|
);
|
|
388
|
-
assert.deepEqual(await snapshot(
|
|
389
|
-
assert.deepEqual(await readActivityLogs(
|
|
325
|
+
assert.deepEqual(await snapshot(db), before);
|
|
326
|
+
assert.deepEqual(await readActivityLogs(db), []);
|
|
390
327
|
});
|
|
391
328
|
});
|
|
392
329
|
|
|
393
|
-
async function snapshot(
|
|
394
|
-
|
|
395
|
-
await
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
)
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
const { rows } = await pg.query(`
|
|
406
|
-
SELECT
|
|
407
|
-
action,
|
|
408
|
-
actor_ref,
|
|
409
|
-
actor_type,
|
|
410
|
-
app,
|
|
411
|
-
cause_activity_id,
|
|
412
|
-
context,
|
|
413
|
-
created_at,
|
|
414
|
-
id,
|
|
415
|
-
interaction_cid,
|
|
416
|
-
moderation_id,
|
|
417
|
-
organization_id,
|
|
418
|
-
user_id
|
|
419
|
-
FROM activity_logs
|
|
420
|
-
ORDER BY id
|
|
421
|
-
`);
|
|
422
|
-
return rows;
|
|
330
|
+
async function snapshot(db: IdentiteDatabase) {
|
|
331
|
+
return {
|
|
332
|
+
email_domains: await db.query.email_domains.findMany({
|
|
333
|
+
orderBy: (table, { asc }) => asc(table.id),
|
|
334
|
+
}),
|
|
335
|
+
users_organizations: await db.query.users_organizations.findMany({
|
|
336
|
+
orderBy: (table, { asc }) => [
|
|
337
|
+
asc(table.organization_id),
|
|
338
|
+
asc(table.user_id),
|
|
339
|
+
],
|
|
340
|
+
}),
|
|
341
|
+
};
|
|
423
342
|
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
//
|
|
2
|
+
|
|
3
|
+
import * as z from "zod";
|
|
4
|
+
|
|
5
|
+
//
|
|
6
|
+
|
|
7
|
+
export const franceconnectActivities = {
|
|
8
|
+
"franceconnect.connected": z.object({
|
|
9
|
+
inputs: z.object({}),
|
|
10
|
+
outcome: z.object({
|
|
11
|
+
connected_at: z.string(),
|
|
12
|
+
}),
|
|
13
|
+
}),
|
|
14
|
+
"franceconnect.disconnected": z.object({
|
|
15
|
+
inputs: z.object({}),
|
|
16
|
+
outcome: z.object({
|
|
17
|
+
connected_at: z.string(),
|
|
18
|
+
}),
|
|
19
|
+
}),
|
|
20
|
+
};
|