@nymphjs/tilmeld 1.0.0-beta.120 → 1.0.0-beta.121

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.
@@ -9,7 +9,9 @@ import Tilmeld from './Tilmeld.js';
9
9
  import { AccessControlError } from './errors/index.js';
10
10
  import type { AccessControlData } from './Tilmeld.types.js';
11
11
  import type UserClass from './User.js';
12
+ import { UserTest } from './User.testArtifacts.js';
12
13
  import type GroupClass from './Group.js';
14
+ import { GroupTest } from './Group.testArtifacts.js';
13
15
 
14
16
  export type TestModelData = {
15
17
  name?: string;
@@ -47,6 +49,7 @@ const TestModelClass = TestModel;
47
49
 
48
50
  export function TilmeldTest(
49
51
  nymphBase: Nymph,
52
+ describe: (name: string, fn: () => void) => void,
50
53
  it: (name: string, fn: () => void) => void,
51
54
  ) {
52
55
  const tilmeld = new Tilmeld({
@@ -67,1900 +70,1910 @@ export function TilmeldTest(
67
70
  });
68
71
  const nymph = new Nymph(nymphBase.config, nymphBase.driver, tilmeld);
69
72
 
70
- const User = tilmeld.User;
71
- const Group = tilmeld.Group;
72
- const TestModel = nymph.addEntityClass(TestModelClass);
73
-
74
- async function deleteTestData() {
75
- let all: (TestModel | UserClass | GroupClass)[] = await nymph.getEntities({
76
- class: TestModel,
77
- });
78
- expect(Array.isArray(all)).toEqual(true);
79
- for (const cur of all) {
80
- expect(await cur.$deleteSkipAC()).toEqual(true);
73
+ describe('Tilmeld', () => {
74
+ UserTest(nymph, tilmeld, describe, it);
75
+ GroupTest(nymph, tilmeld, describe, it);
76
+
77
+ const User = tilmeld.User;
78
+ const Group = tilmeld.Group;
79
+ const TestModel = nymph.addEntityClass(TestModelClass);
80
+
81
+ async function deleteTestData() {
82
+ let all: (TestModel | UserClass | GroupClass)[] = await nymph.getEntities(
83
+ {
84
+ class: TestModel,
85
+ },
86
+ );
87
+ expect(Array.isArray(all)).toEqual(true);
88
+ for (const cur of all) {
89
+ expect(await cur.$deleteSkipAC()).toEqual(true);
90
+ }
91
+
92
+ all = await nymph.getEntities({ class: TestModel });
93
+ expect(all.length).toEqual(0);
94
+
95
+ all = await nymph.getEntities({ class: User });
96
+ expect(Array.isArray(all)).toEqual(true);
97
+ for (const cur of all) {
98
+ expect(await cur.$deleteSkipAC()).toEqual(true);
99
+ }
100
+
101
+ all = await nymph.getEntities({ class: User });
102
+ expect(all.length).toEqual(0);
103
+
104
+ all = await nymph.getEntities({ class: Group });
105
+ expect(Array.isArray(all)).toEqual(true);
106
+ for (const cur of all) {
107
+ expect(await cur.$deleteSkipAC()).toEqual(true);
108
+ }
109
+
110
+ all = await nymph.getEntities({ class: Group });
111
+ expect(all.length).toEqual(0);
81
112
  }
82
113
 
83
- all = await nymph.getEntities({ class: TestModel });
84
- expect(all.length).toEqual(0);
85
-
86
- all = await nymph.getEntities({ class: User });
87
- expect(Array.isArray(all)).toEqual(true);
88
- for (const cur of all) {
89
- expect(await cur.$deleteSkipAC()).toEqual(true);
114
+ async function makeUsers() {
115
+ const admin = await User.factoryUsername('admin');
116
+ const bob = await User.factoryUsername('bob');
117
+ const alice = await User.factoryUsername('alice');
118
+ const abgroup = await Group.factoryGroupname('abgroup');
119
+
120
+ if (admin.guid == null) {
121
+ admin.username = 'admin';
122
+ admin.email = 'admin@localhost';
123
+ admin.nameFirst = 'Admin';
124
+ admin.nameLast = 'User';
125
+ admin.name = 'Admin User';
126
+ admin.$password('password');
127
+ admin.$grant('system/admin');
128
+ await admin.$saveSkipAC();
129
+ }
130
+
131
+ if (abgroup.guid == null) {
132
+ abgroup.groupname = 'abgroup';
133
+ abgroup.email = 'abgroup@localhost';
134
+ abgroup.name = 'AB Group';
135
+ await abgroup.$saveSkipAC();
136
+ }
137
+
138
+ if (bob.guid == null) {
139
+ bob.username = 'bob';
140
+ bob.email = 'bob@localhost';
141
+ bob.nameFirst = 'Bob';
142
+ bob.nameLast = 'User';
143
+ bob.name = 'Bob User';
144
+ bob.$password('password');
145
+ bob.$addGroup(abgroup);
146
+ await bob.$saveSkipAC();
147
+ }
148
+
149
+ if (alice.guid == null) {
150
+ alice.username = 'alice';
151
+ alice.email = 'alice@localhost';
152
+ alice.nameFirst = 'Alice';
153
+ alice.nameLast = 'User';
154
+ alice.name = 'Alice User';
155
+ alice.$password('password');
156
+ alice.$addGroup(abgroup);
157
+ await alice.$saveSkipAC();
158
+ }
159
+
160
+ return { admin, bob, alice, abgroup };
90
161
  }
91
162
 
92
- all = await nymph.getEntities({ class: User });
93
- expect(all.length).toEqual(0);
163
+ it('delete old test data', async () => {
164
+ await deleteTestData();
165
+ });
94
166
 
95
- all = await nymph.getEntities({ class: Group });
96
- expect(Array.isArray(all)).toEqual(true);
97
- for (const cur of all) {
98
- expect(await cur.$deleteSkipAC()).toEqual(true);
99
- }
167
+ it('users can log in', async () => {
168
+ const { admin, bob, alice } = await makeUsers();
100
169
 
101
- all = await nymph.getEntities({ class: Group });
102
- expect(all.length).toEqual(0);
103
- }
170
+ let result = await admin.$login({
171
+ username: 'admin',
172
+ password: 'password',
173
+ });
104
174
 
105
- async function makeUsers() {
106
- const admin = await User.factoryUsername('admin');
107
- const bob = await User.factoryUsername('bob');
108
- const alice = await User.factoryUsername('alice');
109
- const abgroup = await Group.factoryGroupname('abgroup');
110
-
111
- if (admin.guid == null) {
112
- admin.username = 'admin';
113
- admin.email = 'admin@localhost';
114
- admin.nameFirst = 'Admin';
115
- admin.nameLast = 'User';
116
- admin.name = 'Admin User';
117
- admin.$password('password');
118
- admin.$grant('system/admin');
119
- await admin.$saveSkipAC();
120
- }
175
+ expect(result.result).toEqual(true);
176
+ expect(admin.$is(User.current())).toEqual(true);
121
177
 
122
- if (abgroup.guid == null) {
123
- abgroup.groupname = 'abgroup';
124
- abgroup.email = 'abgroup@localhost';
125
- abgroup.name = 'AB Group';
126
- await abgroup.$saveSkipAC();
127
- }
178
+ result = await admin.$logout();
128
179
 
129
- if (bob.guid == null) {
130
- bob.username = 'bob';
131
- bob.email = 'bob@localhost';
132
- bob.nameFirst = 'Bob';
133
- bob.nameLast = 'User';
134
- bob.name = 'Bob User';
135
- bob.$password('password');
136
- bob.$addGroup(abgroup);
137
- await bob.$saveSkipAC();
138
- }
180
+ expect(result.result).toEqual(true);
181
+ expect(User.current()).toBeNull();
139
182
 
140
- if (alice.guid == null) {
141
- alice.username = 'alice';
142
- alice.email = 'alice@localhost';
143
- alice.nameFirst = 'Alice';
144
- alice.nameLast = 'User';
145
- alice.name = 'Alice User';
146
- alice.$password('password');
147
- alice.$addGroup(abgroup);
148
- await alice.$saveSkipAC();
149
- }
183
+ result = await bob.$login({
184
+ username: 'bob',
185
+ password: 'password',
186
+ });
150
187
 
151
- return { admin, bob, alice, abgroup };
152
- }
188
+ expect(result.result).toEqual(true);
189
+ expect(bob.$is(User.current())).toEqual(true);
153
190
 
154
- it('delete old test data', async () => {
155
- await deleteTestData();
156
- });
191
+ result = await bob.$logout();
157
192
 
158
- it('users can log in', async () => {
159
- const { admin, bob, alice } = await makeUsers();
193
+ expect(result.result).toEqual(true);
194
+ expect(User.current()).toBeNull();
160
195
 
161
- let result = await admin.$login({
162
- username: 'admin',
163
- password: 'password',
164
- });
165
-
166
- expect(result.result).toEqual(true);
167
- expect(admin.$is(User.current())).toEqual(true);
196
+ result = await alice.$login({
197
+ username: 'alice',
198
+ password: 'password',
199
+ });
168
200
 
169
- result = await admin.$logout();
201
+ expect(result.result).toEqual(true);
202
+ expect(alice.$is(User.current())).toEqual(true);
170
203
 
171
- expect(result.result).toEqual(true);
172
- expect(User.current()).toBeNull();
204
+ result = await alice.$logout();
173
205
 
174
- result = await bob.$login({
175
- username: 'bob',
176
- password: 'password',
206
+ expect(result.result).toEqual(true);
207
+ expect(User.current()).toBeNull();
177
208
  });
178
209
 
179
- expect(result.result).toEqual(true);
180
- expect(bob.$is(User.current())).toEqual(true);
181
-
182
- result = await bob.$logout();
183
-
184
- expect(result.result).toEqual(true);
185
- expect(User.current()).toBeNull();
186
-
187
- result = await alice.$login({
188
- username: 'alice',
189
- password: 'password',
210
+ it('creates tables for test model', async () => {
211
+ const testEntity = await nymph.getEntity({ class: TestModel });
212
+ expect(testEntity).toBeNull();
190
213
  });
191
214
 
192
- expect(result.result).toEqual(true);
193
- expect(alice.$is(User.current())).toEqual(true);
194
-
195
- result = await alice.$logout();
196
-
197
- expect(result.result).toEqual(true);
198
- expect(User.current()).toBeNull();
199
- });
200
-
201
- it('creates tables for test model', async () => {
202
- const testEntity = await nymph.getEntity({ class: TestModel });
203
- expect(testEntity).toBeNull();
204
- });
205
-
206
- it('user ownership, group ownership, and access controls are added on entities', async () => {
207
- const { bob } = await makeUsers();
208
-
209
- await tilmeld.fillSession(bob);
210
-
211
- const bobsEntity = await TestModel.factory();
212
- bobsEntity.name = "Bob's Entity";
213
- expect(await bobsEntity.$save()).toEqual(true);
214
-
215
- expect(bobsEntity.guid).not.toBeNull();
216
- expect(bob.$is(bobsEntity.user)).toEqual(true);
217
-
218
- const testEntityBob = await nymph.getEntity(
219
- { class: TestModel },
220
- { type: '&', guid: bobsEntity.guid || '' },
221
- );
222
-
223
- expect(testEntityBob).not.toBeNull();
224
- expect(testEntityBob?.guid).toEqual(bobsEntity.guid);
225
- expect(testEntityBob?.user?.$is(bob)).toEqual(true);
226
- expect(testEntityBob?.group?.$is(bob.group)).toEqual(true);
227
- expect(testEntityBob?.acUser).toEqual(TilmeldAccessLevels.FULL_ACCESS);
228
- expect(testEntityBob?.acGroup).toEqual(TilmeldAccessLevels.READ_ACCESS);
229
- expect(testEntityBob?.acOther).toEqual(TilmeldAccessLevels.NO_ACCESS);
230
- expect(testEntityBob?.acRead).toEqual([]);
231
- expect(testEntityBob?.acWrite).toEqual([]);
232
- expect(testEntityBob?.acFull).toEqual([]);
233
- });
215
+ it('user ownership, group ownership, and access controls are added on entities', async () => {
216
+ const { bob } = await makeUsers();
217
+
218
+ await tilmeld.fillSession(bob);
219
+
220
+ const bobsEntity = await TestModel.factory();
221
+ bobsEntity.name = "Bob's Entity";
222
+ expect(await bobsEntity.$save()).toEqual(true);
223
+
224
+ expect(bobsEntity.guid).not.toBeNull();
225
+ expect(bob.$is(bobsEntity.user)).toEqual(true);
226
+
227
+ const testEntityBob = await nymph.getEntity(
228
+ { class: TestModel },
229
+ { type: '&', guid: bobsEntity.guid || '' },
230
+ );
231
+
232
+ expect(testEntityBob).not.toBeNull();
233
+ expect(testEntityBob?.guid).toEqual(bobsEntity.guid);
234
+ expect(testEntityBob?.user?.$is(bob)).toEqual(true);
235
+ expect(testEntityBob?.group?.$is(bob.group)).toEqual(true);
236
+ expect(testEntityBob?.acUser).toEqual(TilmeldAccessLevels.FULL_ACCESS);
237
+ expect(testEntityBob?.acGroup).toEqual(TilmeldAccessLevels.READ_ACCESS);
238
+ expect(testEntityBob?.acOther).toEqual(TilmeldAccessLevels.NO_ACCESS);
239
+ expect(testEntityBob?.acRead).toEqual([]);
240
+ expect(testEntityBob?.acWrite).toEqual([]);
241
+ expect(testEntityBob?.acFull).toEqual([]);
242
+ });
234
243
 
235
- it("alice can't access an entity owned by bob", async () => {
236
- const { bob, alice } = await makeUsers();
244
+ it("alice can't access an entity owned by bob", async () => {
245
+ const { bob, alice } = await makeUsers();
237
246
 
238
- await tilmeld.fillSession(bob);
247
+ await tilmeld.fillSession(bob);
239
248
 
240
- const bobsEntity = await TestModel.factory();
241
- bobsEntity.name = "Bob's Entity";
242
- expect(await bobsEntity.$save()).toEqual(true);
249
+ const bobsEntity = await TestModel.factory();
250
+ bobsEntity.name = "Bob's Entity";
251
+ expect(await bobsEntity.$save()).toEqual(true);
243
252
 
244
- expect(bobsEntity.guid).not.toBeNull();
245
- expect(bob.$is(bobsEntity.user)).toEqual(true);
253
+ expect(bobsEntity.guid).not.toBeNull();
254
+ expect(bob.$is(bobsEntity.user)).toEqual(true);
246
255
 
247
- const testEntityBob = await nymph.getEntity(
248
- { class: TestModel },
249
- { type: '&', guid: bobsEntity.guid || '' },
250
- );
256
+ const testEntityBob = await nymph.getEntity(
257
+ { class: TestModel },
258
+ { type: '&', guid: bobsEntity.guid || '' },
259
+ );
251
260
 
252
- expect(testEntityBob).not.toBeNull();
253
- expect(testEntityBob?.guid).toEqual(bobsEntity.guid);
261
+ expect(testEntityBob).not.toBeNull();
262
+ expect(testEntityBob?.guid).toEqual(bobsEntity.guid);
254
263
 
255
- tilmeld.clearSession();
256
- await tilmeld.fillSession(alice);
264
+ tilmeld.clearSession();
265
+ await tilmeld.fillSession(alice);
257
266
 
258
- const testEntityAlice = await nymph.getEntity(
259
- { class: TestModel },
260
- { type: '&', guid: bobsEntity.guid || '' },
261
- );
267
+ const testEntityAlice = await nymph.getEntity(
268
+ { class: TestModel },
269
+ { type: '&', guid: bobsEntity.guid || '' },
270
+ );
262
271
 
263
- expect(testEntityAlice).toBeNull();
264
- });
272
+ expect(testEntityAlice).toBeNull();
273
+ });
265
274
 
266
- it("alice can't write to an entity she doesn't have write permission for", async () => {
267
- const { bob, alice } = await makeUsers();
275
+ it("alice can't write to an entity she doesn't have write permission for", async () => {
276
+ const { bob, alice } = await makeUsers();
268
277
 
269
- await tilmeld.fillSession(bob);
278
+ await tilmeld.fillSession(bob);
270
279
 
271
- const bobsEntity = await TestModel.factory();
272
- bobsEntity.name = "Bob's Entity";
273
- bobsEntity.acRead = [alice.guid ?? ''];
274
- expect(await bobsEntity.$save()).toEqual(true);
280
+ const bobsEntity = await TestModel.factory();
281
+ bobsEntity.name = "Bob's Entity";
282
+ bobsEntity.acRead = [alice.guid ?? ''];
283
+ expect(await bobsEntity.$save()).toEqual(true);
275
284
 
276
- expect(bobsEntity.guid).not.toBeNull();
277
- expect(bob.$is(bobsEntity.user)).toEqual(true);
285
+ expect(bobsEntity.guid).not.toBeNull();
286
+ expect(bob.$is(bobsEntity.user)).toEqual(true);
278
287
 
279
- const testEntityBob = await nymph.getEntity(
280
- { class: TestModel },
281
- { type: '&', guid: bobsEntity.guid || '' },
282
- );
288
+ const testEntityBob = await nymph.getEntity(
289
+ { class: TestModel },
290
+ { type: '&', guid: bobsEntity.guid || '' },
291
+ );
283
292
 
284
- expect(testEntityBob).not.toBeNull();
285
- expect(testEntityBob?.guid).toEqual(bobsEntity.guid);
293
+ expect(testEntityBob).not.toBeNull();
294
+ expect(testEntityBob?.guid).toEqual(bobsEntity.guid);
286
295
 
287
- tilmeld.clearSession();
288
- await tilmeld.fillSession(alice);
296
+ tilmeld.clearSession();
297
+ await tilmeld.fillSession(alice);
289
298
 
290
- const testEntityAlice = await nymph.getEntity(
291
- { class: TestModel },
292
- { type: '&', guid: bobsEntity.guid || '' },
293
- );
299
+ const testEntityAlice = await nymph.getEntity(
300
+ { class: TestModel },
301
+ { type: '&', guid: bobsEntity.guid || '' },
302
+ );
294
303
 
295
- expect(testEntityAlice).not.toBeNull();
296
- expect(testEntityAlice?.guid).toEqual(bobsEntity.guid);
304
+ expect(testEntityAlice).not.toBeNull();
305
+ expect(testEntityAlice?.guid).toEqual(bobsEntity.guid);
297
306
 
298
- if (testEntityAlice == null) {
299
- throw new Error();
300
- }
307
+ if (testEntityAlice == null) {
308
+ throw new Error();
309
+ }
301
310
 
302
- testEntityAlice.name = "Haha! It's mine now!";
303
- try {
304
- await testEntityAlice.$save();
305
- throw new Error('It should have thrown AccessControlError.');
306
- } catch (e: any) {
307
- expect(e).toBeInstanceOf(AccessControlError);
308
- }
311
+ testEntityAlice.name = "Haha! It's mine now!";
312
+ try {
313
+ await testEntityAlice.$save();
314
+ throw new Error('It should have thrown AccessControlError.');
315
+ } catch (e: any) {
316
+ expect(e).toBeInstanceOf(AccessControlError);
317
+ }
309
318
 
310
- expect(await testEntityAlice.$refresh()).toEqual(true);
311
- expect(testEntityAlice.name).toEqual("Bob's Entity");
312
- });
319
+ expect(await testEntityAlice.$refresh()).toEqual(true);
320
+ expect(testEntityAlice.name).toEqual("Bob's Entity");
321
+ });
313
322
 
314
- it('alice can write to an entity she has write permission for', async () => {
315
- const { bob, alice } = await makeUsers();
323
+ it('alice can write to an entity she has write permission for', async () => {
324
+ const { bob, alice } = await makeUsers();
316
325
 
317
- await tilmeld.fillSession(bob);
326
+ await tilmeld.fillSession(bob);
318
327
 
319
- const bobsEntity = await TestModel.factory();
320
- bobsEntity.name = "Bob's Entity";
321
- bobsEntity.acWrite = [alice.guid ?? ''];
322
- expect(await bobsEntity.$save()).toEqual(true);
328
+ const bobsEntity = await TestModel.factory();
329
+ bobsEntity.name = "Bob's Entity";
330
+ bobsEntity.acWrite = [alice.guid ?? ''];
331
+ expect(await bobsEntity.$save()).toEqual(true);
323
332
 
324
- expect(bobsEntity.guid).not.toBeNull();
325
- expect(bob.$is(bobsEntity.user)).toEqual(true);
333
+ expect(bobsEntity.guid).not.toBeNull();
334
+ expect(bob.$is(bobsEntity.user)).toEqual(true);
326
335
 
327
- const testEntityBob = await nymph.getEntity(
328
- { class: TestModel },
329
- { type: '&', guid: bobsEntity.guid || '' },
330
- );
336
+ const testEntityBob = await nymph.getEntity(
337
+ { class: TestModel },
338
+ { type: '&', guid: bobsEntity.guid || '' },
339
+ );
331
340
 
332
- expect(testEntityBob).not.toBeNull();
333
- expect(testEntityBob?.guid).toEqual(bobsEntity.guid);
341
+ expect(testEntityBob).not.toBeNull();
342
+ expect(testEntityBob?.guid).toEqual(bobsEntity.guid);
334
343
 
335
- tilmeld.clearSession();
336
- await tilmeld.fillSession(alice);
344
+ tilmeld.clearSession();
345
+ await tilmeld.fillSession(alice);
337
346
 
338
- const testEntityAlice = await nymph.getEntity(
339
- { class: TestModel },
340
- { type: '&', guid: bobsEntity.guid || '' },
341
- );
347
+ const testEntityAlice = await nymph.getEntity(
348
+ { class: TestModel },
349
+ { type: '&', guid: bobsEntity.guid || '' },
350
+ );
342
351
 
343
- expect(testEntityAlice).not.toBeNull();
344
- expect(testEntityAlice?.guid).toEqual(bobsEntity.guid);
352
+ expect(testEntityAlice).not.toBeNull();
353
+ expect(testEntityAlice?.guid).toEqual(bobsEntity.guid);
345
354
 
346
- if (testEntityAlice == null) {
347
- throw new Error();
348
- }
355
+ if (testEntityAlice == null) {
356
+ throw new Error();
357
+ }
349
358
 
350
- testEntityAlice.name = "Haha! It's mine now!";
351
- expect(await testEntityAlice.$save()).toEqual(true);
359
+ testEntityAlice.name = "Haha! It's mine now!";
360
+ expect(await testEntityAlice.$save()).toEqual(true);
352
361
 
353
- expect(await testEntityAlice.$refresh()).toEqual(true);
354
- expect(testEntityAlice.name).toEqual("Haha! It's mine now!");
355
- });
362
+ expect(await testEntityAlice.$refresh()).toEqual(true);
363
+ expect(testEntityAlice.name).toEqual("Haha! It's mine now!");
364
+ });
356
365
 
357
- it("alice can't delete an entity she doesn't have full permission for", async () => {
358
- const { bob, alice } = await makeUsers();
366
+ it("alice can't delete an entity she doesn't have full permission for", async () => {
367
+ const { bob, alice } = await makeUsers();
359
368
 
360
- await tilmeld.fillSession(bob);
369
+ await tilmeld.fillSession(bob);
361
370
 
362
- const bobsEntity = await TestModel.factory();
363
- bobsEntity.name = "Bob's Entity";
364
- bobsEntity.acWrite = [alice.guid ?? ''];
365
- expect(await bobsEntity.$save()).toEqual(true);
371
+ const bobsEntity = await TestModel.factory();
372
+ bobsEntity.name = "Bob's Entity";
373
+ bobsEntity.acWrite = [alice.guid ?? ''];
374
+ expect(await bobsEntity.$save()).toEqual(true);
366
375
 
367
- expect(bobsEntity.guid).not.toBeNull();
368
- expect(bob.$is(bobsEntity.user)).toEqual(true);
376
+ expect(bobsEntity.guid).not.toBeNull();
377
+ expect(bob.$is(bobsEntity.user)).toEqual(true);
369
378
 
370
- const testEntityBob = await nymph.getEntity(
371
- { class: TestModel },
372
- { type: '&', guid: bobsEntity.guid || '' },
373
- );
379
+ const testEntityBob = await nymph.getEntity(
380
+ { class: TestModel },
381
+ { type: '&', guid: bobsEntity.guid || '' },
382
+ );
374
383
 
375
- expect(testEntityBob).not.toBeNull();
376
- expect(testEntityBob?.guid).toEqual(bobsEntity.guid);
384
+ expect(testEntityBob).not.toBeNull();
385
+ expect(testEntityBob?.guid).toEqual(bobsEntity.guid);
377
386
 
378
- tilmeld.clearSession();
379
- await tilmeld.fillSession(alice);
387
+ tilmeld.clearSession();
388
+ await tilmeld.fillSession(alice);
380
389
 
381
- const testEntityAlice = await nymph.getEntity(
382
- { class: TestModel },
383
- { type: '&', guid: bobsEntity.guid || '' },
384
- );
390
+ const testEntityAlice = await nymph.getEntity(
391
+ { class: TestModel },
392
+ { type: '&', guid: bobsEntity.guid || '' },
393
+ );
385
394
 
386
- expect(testEntityAlice).not.toBeNull();
387
- expect(testEntityAlice?.guid).toEqual(bobsEntity.guid);
395
+ expect(testEntityAlice).not.toBeNull();
396
+ expect(testEntityAlice?.guid).toEqual(bobsEntity.guid);
388
397
 
389
- if (testEntityAlice == null) {
390
- throw new Error();
391
- }
398
+ if (testEntityAlice == null) {
399
+ throw new Error();
400
+ }
392
401
 
393
- try {
394
- await testEntityAlice.$delete();
395
- throw new Error('It should have thrown AccessControlError.');
396
- } catch (e: any) {
397
- expect(e).toBeInstanceOf(AccessControlError);
398
- }
402
+ try {
403
+ await testEntityAlice.$delete();
404
+ throw new Error('It should have thrown AccessControlError.');
405
+ } catch (e: any) {
406
+ expect(e).toBeInstanceOf(AccessControlError);
407
+ }
399
408
 
400
- expect(await testEntityAlice.$refresh()).toEqual(true);
401
- expect(testEntityAlice.guid).toEqual(bobsEntity.guid);
402
- });
409
+ expect(await testEntityAlice.$refresh()).toEqual(true);
410
+ expect(testEntityAlice.guid).toEqual(bobsEntity.guid);
411
+ });
403
412
 
404
- it('alice can delete an entity she has full permission for', async () => {
405
- const { bob, alice } = await makeUsers();
413
+ it('alice can delete an entity she has full permission for', async () => {
414
+ const { bob, alice } = await makeUsers();
406
415
 
407
- await tilmeld.fillSession(bob);
416
+ await tilmeld.fillSession(bob);
408
417
 
409
- const bobsEntity = await TestModel.factory();
410
- bobsEntity.name = "Bob's Entity";
411
- bobsEntity.acFull = [alice.guid ?? ''];
412
- expect(await bobsEntity.$save()).toEqual(true);
418
+ const bobsEntity = await TestModel.factory();
419
+ bobsEntity.name = "Bob's Entity";
420
+ bobsEntity.acFull = [alice.guid ?? ''];
421
+ expect(await bobsEntity.$save()).toEqual(true);
413
422
 
414
- expect(bobsEntity.guid).not.toBeNull();
415
- expect(bob.$is(bobsEntity.user)).toEqual(true);
423
+ expect(bobsEntity.guid).not.toBeNull();
424
+ expect(bob.$is(bobsEntity.user)).toEqual(true);
416
425
 
417
- const testEntityBob = await nymph.getEntity(
418
- { class: TestModel },
419
- { type: '&', guid: bobsEntity.guid || '' },
420
- );
426
+ const testEntityBob = await nymph.getEntity(
427
+ { class: TestModel },
428
+ { type: '&', guid: bobsEntity.guid || '' },
429
+ );
421
430
 
422
- expect(testEntityBob).not.toBeNull();
423
- expect(testEntityBob?.guid).toEqual(bobsEntity.guid);
431
+ expect(testEntityBob).not.toBeNull();
432
+ expect(testEntityBob?.guid).toEqual(bobsEntity.guid);
424
433
 
425
- tilmeld.clearSession();
426
- await tilmeld.fillSession(alice);
434
+ tilmeld.clearSession();
435
+ await tilmeld.fillSession(alice);
427
436
 
428
- const testEntityAlice = await nymph.getEntity(
429
- { class: TestModel },
430
- { type: '&', guid: bobsEntity.guid || '' },
431
- );
437
+ const testEntityAlice = await nymph.getEntity(
438
+ { class: TestModel },
439
+ { type: '&', guid: bobsEntity.guid || '' },
440
+ );
432
441
 
433
- expect(testEntityAlice).not.toBeNull();
434
- expect(testEntityAlice?.guid).toEqual(bobsEntity.guid);
442
+ expect(testEntityAlice).not.toBeNull();
443
+ expect(testEntityAlice?.guid).toEqual(bobsEntity.guid);
435
444
 
436
- if (testEntityAlice == null) {
437
- throw new Error();
438
- }
445
+ if (testEntityAlice == null) {
446
+ throw new Error();
447
+ }
439
448
 
440
- expect(await testEntityAlice.$delete()).toEqual(true);
441
- const verifyEntityAlice = await nymph.getEntity(
442
- { class: TestModel },
443
- { type: '&', guid: bobsEntity.guid || '' },
444
- );
445
- expect(verifyEntityAlice).toBeNull();
446
- });
449
+ expect(await testEntityAlice.$delete()).toEqual(true);
450
+ const verifyEntityAlice = await nymph.getEntity(
451
+ { class: TestModel },
452
+ { type: '&', guid: bobsEntity.guid || '' },
453
+ );
454
+ expect(verifyEntityAlice).toBeNull();
455
+ });
447
456
 
448
- it('alice can access an entity her group has permission for', async () => {
449
- const { bob, alice, abgroup } = await makeUsers();
457
+ it('alice can access an entity her group has permission for', async () => {
458
+ const { bob, alice, abgroup } = await makeUsers();
450
459
 
451
- await tilmeld.fillSession(bob);
460
+ await tilmeld.fillSession(bob);
452
461
 
453
- const bobsEntity = await TestModel.factory();
454
- bobsEntity.name = "Bob's Entity";
455
- bobsEntity.acRead = [abgroup.guid ?? ''];
456
- expect(await bobsEntity.$save()).toEqual(true);
462
+ const bobsEntity = await TestModel.factory();
463
+ bobsEntity.name = "Bob's Entity";
464
+ bobsEntity.acRead = [abgroup.guid ?? ''];
465
+ expect(await bobsEntity.$save()).toEqual(true);
457
466
 
458
- expect(bobsEntity.guid).not.toBeNull();
459
- expect(bob.$is(bobsEntity.user)).toEqual(true);
467
+ expect(bobsEntity.guid).not.toBeNull();
468
+ expect(bob.$is(bobsEntity.user)).toEqual(true);
460
469
 
461
- const testEntityBob = await nymph.getEntity(
462
- { class: TestModel },
463
- { type: '&', guid: bobsEntity.guid || '' },
464
- );
470
+ const testEntityBob = await nymph.getEntity(
471
+ { class: TestModel },
472
+ { type: '&', guid: bobsEntity.guid || '' },
473
+ );
465
474
 
466
- expect(testEntityBob).not.toBeNull();
467
- expect(testEntityBob?.guid).toEqual(bobsEntity.guid);
475
+ expect(testEntityBob).not.toBeNull();
476
+ expect(testEntityBob?.guid).toEqual(bobsEntity.guid);
468
477
 
469
- tilmeld.clearSession();
470
- await tilmeld.fillSession(alice);
478
+ tilmeld.clearSession();
479
+ await tilmeld.fillSession(alice);
471
480
 
472
- const testEntityAlice = await nymph.getEntity(
473
- { class: TestModel },
474
- { type: '&', guid: bobsEntity.guid || '' },
475
- );
481
+ const testEntityAlice = await nymph.getEntity(
482
+ { class: TestModel },
483
+ { type: '&', guid: bobsEntity.guid || '' },
484
+ );
476
485
 
477
- expect(testEntityAlice).not.toBeNull();
478
- expect(testEntityAlice?.guid).toEqual(bobsEntity.guid);
479
- });
486
+ expect(testEntityAlice).not.toBeNull();
487
+ expect(testEntityAlice?.guid).toEqual(bobsEntity.guid);
488
+ });
480
489
 
481
- it("alice can't write to an entity her group doesn't have write permission for", async () => {
482
- const { bob, alice, abgroup } = await makeUsers();
490
+ it("alice can't write to an entity her group doesn't have write permission for", async () => {
491
+ const { bob, alice, abgroup } = await makeUsers();
483
492
 
484
- await tilmeld.fillSession(bob);
493
+ await tilmeld.fillSession(bob);
485
494
 
486
- const bobsEntity = await TestModel.factory();
487
- bobsEntity.name = "Bob's Entity";
488
- bobsEntity.acRead = [abgroup.guid ?? ''];
489
- expect(await bobsEntity.$save()).toEqual(true);
495
+ const bobsEntity = await TestModel.factory();
496
+ bobsEntity.name = "Bob's Entity";
497
+ bobsEntity.acRead = [abgroup.guid ?? ''];
498
+ expect(await bobsEntity.$save()).toEqual(true);
490
499
 
491
- expect(bobsEntity.guid).not.toBeNull();
492
- expect(bob.$is(bobsEntity.user)).toEqual(true);
500
+ expect(bobsEntity.guid).not.toBeNull();
501
+ expect(bob.$is(bobsEntity.user)).toEqual(true);
493
502
 
494
- const testEntityBob = await nymph.getEntity(
495
- { class: TestModel },
496
- { type: '&', guid: bobsEntity.guid || '' },
497
- );
503
+ const testEntityBob = await nymph.getEntity(
504
+ { class: TestModel },
505
+ { type: '&', guid: bobsEntity.guid || '' },
506
+ );
498
507
 
499
- expect(testEntityBob).not.toBeNull();
500
- expect(testEntityBob?.guid).toEqual(bobsEntity.guid);
508
+ expect(testEntityBob).not.toBeNull();
509
+ expect(testEntityBob?.guid).toEqual(bobsEntity.guid);
501
510
 
502
- tilmeld.clearSession();
503
- await tilmeld.fillSession(alice);
511
+ tilmeld.clearSession();
512
+ await tilmeld.fillSession(alice);
504
513
 
505
- const testEntityAlice = await nymph.getEntity(
506
- { class: TestModel },
507
- { type: '&', guid: bobsEntity.guid || '' },
508
- );
514
+ const testEntityAlice = await nymph.getEntity(
515
+ { class: TestModel },
516
+ { type: '&', guid: bobsEntity.guid || '' },
517
+ );
509
518
 
510
- expect(testEntityAlice).not.toBeNull();
511
- expect(testEntityAlice?.guid).toEqual(bobsEntity.guid);
519
+ expect(testEntityAlice).not.toBeNull();
520
+ expect(testEntityAlice?.guid).toEqual(bobsEntity.guid);
512
521
 
513
- if (testEntityAlice == null) {
514
- throw new Error();
515
- }
522
+ if (testEntityAlice == null) {
523
+ throw new Error();
524
+ }
516
525
 
517
- testEntityAlice.name = "Haha! It's mine now!";
518
- try {
519
- await testEntityAlice.$save();
520
- throw new Error('It should have thrown AccessControlError.');
521
- } catch (e: any) {
522
- expect(e).toBeInstanceOf(AccessControlError);
523
- }
526
+ testEntityAlice.name = "Haha! It's mine now!";
527
+ try {
528
+ await testEntityAlice.$save();
529
+ throw new Error('It should have thrown AccessControlError.');
530
+ } catch (e: any) {
531
+ expect(e).toBeInstanceOf(AccessControlError);
532
+ }
524
533
 
525
- expect(await testEntityAlice.$refresh()).toEqual(true);
526
- expect(testEntityAlice.name).toEqual("Bob's Entity");
527
- });
534
+ expect(await testEntityAlice.$refresh()).toEqual(true);
535
+ expect(testEntityAlice.name).toEqual("Bob's Entity");
536
+ });
528
537
 
529
- it('alice can write to an entity her group has write permission for', async () => {
530
- const { bob, alice, abgroup } = await makeUsers();
538
+ it('alice can write to an entity her group has write permission for', async () => {
539
+ const { bob, alice, abgroup } = await makeUsers();
531
540
 
532
- await tilmeld.fillSession(bob);
541
+ await tilmeld.fillSession(bob);
533
542
 
534
- const bobsEntity = await TestModel.factory();
535
- bobsEntity.name = "Bob's Entity";
536
- bobsEntity.acWrite = [abgroup.guid ?? ''];
537
- expect(await bobsEntity.$save()).toEqual(true);
543
+ const bobsEntity = await TestModel.factory();
544
+ bobsEntity.name = "Bob's Entity";
545
+ bobsEntity.acWrite = [abgroup.guid ?? ''];
546
+ expect(await bobsEntity.$save()).toEqual(true);
538
547
 
539
- expect(bobsEntity.guid).not.toBeNull();
540
- expect(bob.$is(bobsEntity.user)).toEqual(true);
548
+ expect(bobsEntity.guid).not.toBeNull();
549
+ expect(bob.$is(bobsEntity.user)).toEqual(true);
541
550
 
542
- const testEntityBob = await nymph.getEntity(
543
- { class: TestModel },
544
- { type: '&', guid: bobsEntity.guid || '' },
545
- );
551
+ const testEntityBob = await nymph.getEntity(
552
+ { class: TestModel },
553
+ { type: '&', guid: bobsEntity.guid || '' },
554
+ );
546
555
 
547
- expect(testEntityBob).not.toBeNull();
548
- expect(testEntityBob?.guid).toEqual(bobsEntity.guid);
556
+ expect(testEntityBob).not.toBeNull();
557
+ expect(testEntityBob?.guid).toEqual(bobsEntity.guid);
549
558
 
550
- tilmeld.clearSession();
551
- await tilmeld.fillSession(alice);
559
+ tilmeld.clearSession();
560
+ await tilmeld.fillSession(alice);
552
561
 
553
- const testEntityAlice = await nymph.getEntity(
554
- { class: TestModel },
555
- { type: '&', guid: bobsEntity.guid || '' },
556
- );
562
+ const testEntityAlice = await nymph.getEntity(
563
+ { class: TestModel },
564
+ { type: '&', guid: bobsEntity.guid || '' },
565
+ );
557
566
 
558
- expect(testEntityAlice).not.toBeNull();
559
- expect(testEntityAlice?.guid).toEqual(bobsEntity.guid);
567
+ expect(testEntityAlice).not.toBeNull();
568
+ expect(testEntityAlice?.guid).toEqual(bobsEntity.guid);
560
569
 
561
- if (testEntityAlice == null) {
562
- throw new Error();
563
- }
570
+ if (testEntityAlice == null) {
571
+ throw new Error();
572
+ }
564
573
 
565
- testEntityAlice.name = "Haha! It's mine now!";
566
- expect(await testEntityAlice.$save()).toEqual(true);
574
+ testEntityAlice.name = "Haha! It's mine now!";
575
+ expect(await testEntityAlice.$save()).toEqual(true);
567
576
 
568
- expect(await testEntityAlice.$refresh()).toEqual(true);
569
- expect(testEntityAlice.name).toEqual("Haha! It's mine now!");
570
- });
577
+ expect(await testEntityAlice.$refresh()).toEqual(true);
578
+ expect(testEntityAlice.name).toEqual("Haha! It's mine now!");
579
+ });
571
580
 
572
- it("alice can't delete an entity her group doesn't have full permission for", async () => {
573
- const { bob, alice, abgroup } = await makeUsers();
581
+ it("alice can't delete an entity her group doesn't have full permission for", async () => {
582
+ const { bob, alice, abgroup } = await makeUsers();
574
583
 
575
- await tilmeld.fillSession(bob);
584
+ await tilmeld.fillSession(bob);
576
585
 
577
- const bobsEntity = await TestModel.factory();
578
- bobsEntity.name = "Bob's Entity";
579
- bobsEntity.acWrite = [abgroup.guid ?? ''];
580
- expect(await bobsEntity.$save()).toEqual(true);
586
+ const bobsEntity = await TestModel.factory();
587
+ bobsEntity.name = "Bob's Entity";
588
+ bobsEntity.acWrite = [abgroup.guid ?? ''];
589
+ expect(await bobsEntity.$save()).toEqual(true);
581
590
 
582
- expect(bobsEntity.guid).not.toBeNull();
583
- expect(bob.$is(bobsEntity.user)).toEqual(true);
591
+ expect(bobsEntity.guid).not.toBeNull();
592
+ expect(bob.$is(bobsEntity.user)).toEqual(true);
584
593
 
585
- const testEntityBob = await nymph.getEntity(
586
- { class: TestModel },
587
- { type: '&', guid: bobsEntity.guid || '' },
588
- );
594
+ const testEntityBob = await nymph.getEntity(
595
+ { class: TestModel },
596
+ { type: '&', guid: bobsEntity.guid || '' },
597
+ );
589
598
 
590
- expect(testEntityBob).not.toBeNull();
591
- expect(testEntityBob?.guid).toEqual(bobsEntity.guid);
599
+ expect(testEntityBob).not.toBeNull();
600
+ expect(testEntityBob?.guid).toEqual(bobsEntity.guid);
592
601
 
593
- tilmeld.clearSession();
594
- await tilmeld.fillSession(alice);
602
+ tilmeld.clearSession();
603
+ await tilmeld.fillSession(alice);
595
604
 
596
- const testEntityAlice = await nymph.getEntity(
597
- { class: TestModel },
598
- { type: '&', guid: bobsEntity.guid || '' },
599
- );
605
+ const testEntityAlice = await nymph.getEntity(
606
+ { class: TestModel },
607
+ { type: '&', guid: bobsEntity.guid || '' },
608
+ );
600
609
 
601
- expect(testEntityAlice).not.toBeNull();
602
- expect(testEntityAlice?.guid).toEqual(bobsEntity.guid);
610
+ expect(testEntityAlice).not.toBeNull();
611
+ expect(testEntityAlice?.guid).toEqual(bobsEntity.guid);
603
612
 
604
- if (testEntityAlice == null) {
605
- throw new Error();
606
- }
613
+ if (testEntityAlice == null) {
614
+ throw new Error();
615
+ }
607
616
 
608
- try {
609
- await testEntityAlice.$delete();
610
- throw new Error('It should have thrown AccessControlError.');
611
- } catch (e: any) {
612
- expect(e).toBeInstanceOf(AccessControlError);
613
- }
617
+ try {
618
+ await testEntityAlice.$delete();
619
+ throw new Error('It should have thrown AccessControlError.');
620
+ } catch (e: any) {
621
+ expect(e).toBeInstanceOf(AccessControlError);
622
+ }
614
623
 
615
- expect(await testEntityAlice.$refresh()).toEqual(true);
616
- expect(testEntityAlice.guid).toEqual(bobsEntity.guid);
617
- });
624
+ expect(await testEntityAlice.$refresh()).toEqual(true);
625
+ expect(testEntityAlice.guid).toEqual(bobsEntity.guid);
626
+ });
618
627
 
619
- it('alice can delete an entity her group has full permission for', async () => {
620
- const { bob, alice, abgroup } = await makeUsers();
628
+ it('alice can delete an entity her group has full permission for', async () => {
629
+ const { bob, alice, abgroup } = await makeUsers();
621
630
 
622
- await tilmeld.fillSession(bob);
631
+ await tilmeld.fillSession(bob);
623
632
 
624
- const bobsEntity = await TestModel.factory();
625
- bobsEntity.name = "Bob's Entity";
626
- bobsEntity.acFull = [abgroup.guid ?? ''];
627
- expect(await bobsEntity.$save()).toEqual(true);
633
+ const bobsEntity = await TestModel.factory();
634
+ bobsEntity.name = "Bob's Entity";
635
+ bobsEntity.acFull = [abgroup.guid ?? ''];
636
+ expect(await bobsEntity.$save()).toEqual(true);
628
637
 
629
- expect(bobsEntity.guid).not.toBeNull();
630
- expect(bob.$is(bobsEntity.user)).toEqual(true);
638
+ expect(bobsEntity.guid).not.toBeNull();
639
+ expect(bob.$is(bobsEntity.user)).toEqual(true);
631
640
 
632
- const testEntityBob = await nymph.getEntity(
633
- { class: TestModel },
634
- { type: '&', guid: bobsEntity.guid || '' },
635
- );
641
+ const testEntityBob = await nymph.getEntity(
642
+ { class: TestModel },
643
+ { type: '&', guid: bobsEntity.guid || '' },
644
+ );
636
645
 
637
- expect(testEntityBob).not.toBeNull();
638
- expect(testEntityBob?.guid).toEqual(bobsEntity.guid);
646
+ expect(testEntityBob).not.toBeNull();
647
+ expect(testEntityBob?.guid).toEqual(bobsEntity.guid);
639
648
 
640
- tilmeld.clearSession();
641
- await tilmeld.fillSession(alice);
649
+ tilmeld.clearSession();
650
+ await tilmeld.fillSession(alice);
642
651
 
643
- const testEntityAlice = await nymph.getEntity(
644
- { class: TestModel },
645
- { type: '&', guid: bobsEntity.guid || '' },
646
- );
652
+ const testEntityAlice = await nymph.getEntity(
653
+ { class: TestModel },
654
+ { type: '&', guid: bobsEntity.guid || '' },
655
+ );
647
656
 
648
- expect(testEntityAlice).not.toBeNull();
649
- expect(testEntityAlice?.guid).toEqual(bobsEntity.guid);
657
+ expect(testEntityAlice).not.toBeNull();
658
+ expect(testEntityAlice?.guid).toEqual(bobsEntity.guid);
650
659
 
651
- if (testEntityAlice == null) {
652
- throw new Error();
653
- }
660
+ if (testEntityAlice == null) {
661
+ throw new Error();
662
+ }
654
663
 
655
- expect(await testEntityAlice.$delete()).toEqual(true);
656
- const verifyEntityAlice = await nymph.getEntity(
657
- { class: TestModel },
658
- { type: '&', guid: bobsEntity.guid || '' },
659
- );
660
- expect(verifyEntityAlice).toBeNull();
661
- });
664
+ expect(await testEntityAlice.$delete()).toEqual(true);
665
+ const verifyEntityAlice = await nymph.getEntity(
666
+ { class: TestModel },
667
+ { type: '&', guid: bobsEntity.guid || '' },
668
+ );
669
+ expect(verifyEntityAlice).toBeNull();
670
+ });
662
671
 
663
- it('alice can access an entity her primary group has permission for', async () => {
664
- const { bob, alice } = await makeUsers();
672
+ it('alice can access an entity her primary group has permission for', async () => {
673
+ const { bob, alice } = await makeUsers();
665
674
 
666
- await tilmeld.fillSession(bob);
675
+ await tilmeld.fillSession(bob);
667
676
 
668
- const bobsEntity = await TestModel.factory();
669
- bobsEntity.name = "Bob's Entity";
670
- bobsEntity.group = alice.group;
671
- expect(await bobsEntity.$save()).toEqual(true);
677
+ const bobsEntity = await TestModel.factory();
678
+ bobsEntity.name = "Bob's Entity";
679
+ bobsEntity.group = alice.group;
680
+ expect(await bobsEntity.$save()).toEqual(true);
672
681
 
673
- expect(bobsEntity.guid).not.toBeNull();
674
- expect(bob.$is(bobsEntity.user)).toEqual(true);
682
+ expect(bobsEntity.guid).not.toBeNull();
683
+ expect(bob.$is(bobsEntity.user)).toEqual(true);
675
684
 
676
- const testEntityBob = await nymph.getEntity(
677
- { class: TestModel },
678
- { type: '&', guid: bobsEntity.guid || '' },
679
- );
685
+ const testEntityBob = await nymph.getEntity(
686
+ { class: TestModel },
687
+ { type: '&', guid: bobsEntity.guid || '' },
688
+ );
680
689
 
681
- expect(testEntityBob).not.toBeNull();
682
- expect(testEntityBob?.guid).toEqual(bobsEntity.guid);
690
+ expect(testEntityBob).not.toBeNull();
691
+ expect(testEntityBob?.guid).toEqual(bobsEntity.guid);
683
692
 
684
- tilmeld.clearSession();
685
- await tilmeld.fillSession(alice);
693
+ tilmeld.clearSession();
694
+ await tilmeld.fillSession(alice);
686
695
 
687
- const testEntityAlice = await nymph.getEntity(
688
- { class: TestModel },
689
- { type: '&', guid: bobsEntity.guid || '' },
690
- );
696
+ const testEntityAlice = await nymph.getEntity(
697
+ { class: TestModel },
698
+ { type: '&', guid: bobsEntity.guid || '' },
699
+ );
691
700
 
692
- expect(testEntityAlice).not.toBeNull();
693
- expect(testEntityAlice?.guid).toEqual(bobsEntity.guid);
694
- });
701
+ expect(testEntityAlice).not.toBeNull();
702
+ expect(testEntityAlice?.guid).toEqual(bobsEntity.guid);
703
+ });
695
704
 
696
- it("alice can't write to an entity her primary group doesn't have write permission for", async () => {
697
- const { bob, alice } = await makeUsers();
705
+ it("alice can't write to an entity her primary group doesn't have write permission for", async () => {
706
+ const { bob, alice } = await makeUsers();
698
707
 
699
- await tilmeld.fillSession(bob);
708
+ await tilmeld.fillSession(bob);
700
709
 
701
- const bobsEntity = await TestModel.factory();
702
- bobsEntity.name = "Bob's Entity";
703
- bobsEntity.group = alice.group;
704
- expect(await bobsEntity.$save()).toEqual(true);
710
+ const bobsEntity = await TestModel.factory();
711
+ bobsEntity.name = "Bob's Entity";
712
+ bobsEntity.group = alice.group;
713
+ expect(await bobsEntity.$save()).toEqual(true);
705
714
 
706
- expect(bobsEntity.guid).not.toBeNull();
707
- expect(bob.$is(bobsEntity.user)).toEqual(true);
715
+ expect(bobsEntity.guid).not.toBeNull();
716
+ expect(bob.$is(bobsEntity.user)).toEqual(true);
708
717
 
709
- const testEntityBob = await nymph.getEntity(
710
- { class: TestModel },
711
- { type: '&', guid: bobsEntity.guid || '' },
712
- );
718
+ const testEntityBob = await nymph.getEntity(
719
+ { class: TestModel },
720
+ { type: '&', guid: bobsEntity.guid || '' },
721
+ );
713
722
 
714
- expect(testEntityBob).not.toBeNull();
715
- expect(testEntityBob?.guid).toEqual(bobsEntity.guid);
723
+ expect(testEntityBob).not.toBeNull();
724
+ expect(testEntityBob?.guid).toEqual(bobsEntity.guid);
716
725
 
717
- tilmeld.clearSession();
718
- await tilmeld.fillSession(alice);
726
+ tilmeld.clearSession();
727
+ await tilmeld.fillSession(alice);
719
728
 
720
- const testEntityAlice = await nymph.getEntity(
721
- { class: TestModel },
722
- { type: '&', guid: bobsEntity.guid || '' },
723
- );
729
+ const testEntityAlice = await nymph.getEntity(
730
+ { class: TestModel },
731
+ { type: '&', guid: bobsEntity.guid || '' },
732
+ );
724
733
 
725
- expect(testEntityAlice).not.toBeNull();
726
- expect(testEntityAlice?.guid).toEqual(bobsEntity.guid);
734
+ expect(testEntityAlice).not.toBeNull();
735
+ expect(testEntityAlice?.guid).toEqual(bobsEntity.guid);
727
736
 
728
- if (testEntityAlice == null) {
729
- throw new Error();
730
- }
737
+ if (testEntityAlice == null) {
738
+ throw new Error();
739
+ }
731
740
 
732
- testEntityAlice.name = "Haha! It's mine now!";
733
- try {
734
- await testEntityAlice.$save();
735
- throw new Error('It should have thrown AccessControlError.');
736
- } catch (e: any) {
737
- expect(e).toBeInstanceOf(AccessControlError);
738
- }
741
+ testEntityAlice.name = "Haha! It's mine now!";
742
+ try {
743
+ await testEntityAlice.$save();
744
+ throw new Error('It should have thrown AccessControlError.');
745
+ } catch (e: any) {
746
+ expect(e).toBeInstanceOf(AccessControlError);
747
+ }
739
748
 
740
- expect(await testEntityAlice.$refresh()).toEqual(true);
741
- expect(testEntityAlice.name).toEqual("Bob's Entity");
742
- });
749
+ expect(await testEntityAlice.$refresh()).toEqual(true);
750
+ expect(testEntityAlice.name).toEqual("Bob's Entity");
751
+ });
743
752
 
744
- it('alice can write to an entity her primary group has write permission for', async () => {
745
- const { bob, alice } = await makeUsers();
753
+ it('alice can write to an entity her primary group has write permission for', async () => {
754
+ const { bob, alice } = await makeUsers();
746
755
 
747
- await tilmeld.fillSession(bob);
756
+ await tilmeld.fillSession(bob);
748
757
 
749
- const bobsEntity = await TestModel.factory();
750
- bobsEntity.name = "Bob's Entity";
751
- bobsEntity.group = alice.group;
752
- bobsEntity.acGroup = TilmeldAccessLevels.WRITE_ACCESS;
753
- expect(await bobsEntity.$save()).toEqual(true);
758
+ const bobsEntity = await TestModel.factory();
759
+ bobsEntity.name = "Bob's Entity";
760
+ bobsEntity.group = alice.group;
761
+ bobsEntity.acGroup = TilmeldAccessLevels.WRITE_ACCESS;
762
+ expect(await bobsEntity.$save()).toEqual(true);
754
763
 
755
- expect(bobsEntity.guid).not.toBeNull();
756
- expect(bob.$is(bobsEntity.user)).toEqual(true);
764
+ expect(bobsEntity.guid).not.toBeNull();
765
+ expect(bob.$is(bobsEntity.user)).toEqual(true);
757
766
 
758
- const testEntityBob = await nymph.getEntity(
759
- { class: TestModel },
760
- { type: '&', guid: bobsEntity.guid || '' },
761
- );
767
+ const testEntityBob = await nymph.getEntity(
768
+ { class: TestModel },
769
+ { type: '&', guid: bobsEntity.guid || '' },
770
+ );
762
771
 
763
- expect(testEntityBob).not.toBeNull();
764
- expect(testEntityBob?.guid).toEqual(bobsEntity.guid);
772
+ expect(testEntityBob).not.toBeNull();
773
+ expect(testEntityBob?.guid).toEqual(bobsEntity.guid);
765
774
 
766
- tilmeld.clearSession();
767
- await tilmeld.fillSession(alice);
775
+ tilmeld.clearSession();
776
+ await tilmeld.fillSession(alice);
768
777
 
769
- const testEntityAlice = await nymph.getEntity(
770
- { class: TestModel },
771
- { type: '&', guid: bobsEntity.guid || '' },
772
- );
778
+ const testEntityAlice = await nymph.getEntity(
779
+ { class: TestModel },
780
+ { type: '&', guid: bobsEntity.guid || '' },
781
+ );
773
782
 
774
- expect(testEntityAlice).not.toBeNull();
775
- expect(testEntityAlice?.guid).toEqual(bobsEntity.guid);
783
+ expect(testEntityAlice).not.toBeNull();
784
+ expect(testEntityAlice?.guid).toEqual(bobsEntity.guid);
776
785
 
777
- if (testEntityAlice == null) {
778
- throw new Error();
779
- }
786
+ if (testEntityAlice == null) {
787
+ throw new Error();
788
+ }
780
789
 
781
- testEntityAlice.name = "Haha! It's mine now!";
782
- expect(await testEntityAlice.$save()).toEqual(true);
790
+ testEntityAlice.name = "Haha! It's mine now!";
791
+ expect(await testEntityAlice.$save()).toEqual(true);
783
792
 
784
- expect(await testEntityAlice.$refresh()).toEqual(true);
785
- expect(testEntityAlice.name).toEqual("Haha! It's mine now!");
786
- });
793
+ expect(await testEntityAlice.$refresh()).toEqual(true);
794
+ expect(testEntityAlice.name).toEqual("Haha! It's mine now!");
795
+ });
787
796
 
788
- it("alice can't delete an entity her primary group doesn't have full permission for", async () => {
789
- const { bob, alice } = await makeUsers();
797
+ it("alice can't delete an entity her primary group doesn't have full permission for", async () => {
798
+ const { bob, alice } = await makeUsers();
790
799
 
791
- await tilmeld.fillSession(bob);
800
+ await tilmeld.fillSession(bob);
792
801
 
793
- const bobsEntity = await TestModel.factory();
794
- bobsEntity.name = "Bob's Entity";
795
- bobsEntity.group = alice.group;
796
- bobsEntity.acGroup = TilmeldAccessLevels.WRITE_ACCESS;
797
- expect(await bobsEntity.$save()).toEqual(true);
802
+ const bobsEntity = await TestModel.factory();
803
+ bobsEntity.name = "Bob's Entity";
804
+ bobsEntity.group = alice.group;
805
+ bobsEntity.acGroup = TilmeldAccessLevels.WRITE_ACCESS;
806
+ expect(await bobsEntity.$save()).toEqual(true);
798
807
 
799
- expect(bobsEntity.guid).not.toBeNull();
800
- expect(bob.$is(bobsEntity.user)).toEqual(true);
808
+ expect(bobsEntity.guid).not.toBeNull();
809
+ expect(bob.$is(bobsEntity.user)).toEqual(true);
801
810
 
802
- const testEntityBob = await nymph.getEntity(
803
- { class: TestModel },
804
- { type: '&', guid: bobsEntity.guid || '' },
805
- );
811
+ const testEntityBob = await nymph.getEntity(
812
+ { class: TestModel },
813
+ { type: '&', guid: bobsEntity.guid || '' },
814
+ );
806
815
 
807
- expect(testEntityBob).not.toBeNull();
808
- expect(testEntityBob?.guid).toEqual(bobsEntity.guid);
816
+ expect(testEntityBob).not.toBeNull();
817
+ expect(testEntityBob?.guid).toEqual(bobsEntity.guid);
809
818
 
810
- tilmeld.clearSession();
811
- await tilmeld.fillSession(alice);
819
+ tilmeld.clearSession();
820
+ await tilmeld.fillSession(alice);
812
821
 
813
- const testEntityAlice = await nymph.getEntity(
814
- { class: TestModel },
815
- { type: '&', guid: bobsEntity.guid || '' },
816
- );
822
+ const testEntityAlice = await nymph.getEntity(
823
+ { class: TestModel },
824
+ { type: '&', guid: bobsEntity.guid || '' },
825
+ );
817
826
 
818
- expect(testEntityAlice).not.toBeNull();
819
- expect(testEntityAlice?.guid).toEqual(bobsEntity.guid);
827
+ expect(testEntityAlice).not.toBeNull();
828
+ expect(testEntityAlice?.guid).toEqual(bobsEntity.guid);
820
829
 
821
- if (testEntityAlice == null) {
822
- throw new Error();
823
- }
830
+ if (testEntityAlice == null) {
831
+ throw new Error();
832
+ }
824
833
 
825
- try {
826
- await testEntityAlice.$delete();
827
- throw new Error('It should have thrown AccessControlError.');
828
- } catch (e: any) {
829
- expect(e).toBeInstanceOf(AccessControlError);
830
- }
834
+ try {
835
+ await testEntityAlice.$delete();
836
+ throw new Error('It should have thrown AccessControlError.');
837
+ } catch (e: any) {
838
+ expect(e).toBeInstanceOf(AccessControlError);
839
+ }
831
840
 
832
- expect(await testEntityAlice.$refresh()).toEqual(true);
833
- expect(testEntityAlice.guid).toEqual(bobsEntity.guid);
834
- });
841
+ expect(await testEntityAlice.$refresh()).toEqual(true);
842
+ expect(testEntityAlice.guid).toEqual(bobsEntity.guid);
843
+ });
835
844
 
836
- it('alice can delete an entity her primary group has full permission for', async () => {
837
- const { bob, alice } = await makeUsers();
845
+ it('alice can delete an entity her primary group has full permission for', async () => {
846
+ const { bob, alice } = await makeUsers();
838
847
 
839
- await tilmeld.fillSession(bob);
848
+ await tilmeld.fillSession(bob);
840
849
 
841
- const bobsEntity = await TestModel.factory();
842
- bobsEntity.name = "Bob's Entity";
843
- bobsEntity.group = alice.group;
844
- bobsEntity.acGroup = TilmeldAccessLevels.FULL_ACCESS;
845
- expect(await bobsEntity.$save()).toEqual(true);
850
+ const bobsEntity = await TestModel.factory();
851
+ bobsEntity.name = "Bob's Entity";
852
+ bobsEntity.group = alice.group;
853
+ bobsEntity.acGroup = TilmeldAccessLevels.FULL_ACCESS;
854
+ expect(await bobsEntity.$save()).toEqual(true);
846
855
 
847
- expect(bobsEntity.guid).not.toBeNull();
848
- expect(bob.$is(bobsEntity.user)).toEqual(true);
856
+ expect(bobsEntity.guid).not.toBeNull();
857
+ expect(bob.$is(bobsEntity.user)).toEqual(true);
849
858
 
850
- const testEntityBob = await nymph.getEntity(
851
- { class: TestModel },
852
- { type: '&', guid: bobsEntity.guid || '' },
853
- );
859
+ const testEntityBob = await nymph.getEntity(
860
+ { class: TestModel },
861
+ { type: '&', guid: bobsEntity.guid || '' },
862
+ );
854
863
 
855
- expect(testEntityBob).not.toBeNull();
856
- expect(testEntityBob?.guid).toEqual(bobsEntity.guid);
864
+ expect(testEntityBob).not.toBeNull();
865
+ expect(testEntityBob?.guid).toEqual(bobsEntity.guid);
857
866
 
858
- tilmeld.clearSession();
859
- await tilmeld.fillSession(alice);
867
+ tilmeld.clearSession();
868
+ await tilmeld.fillSession(alice);
860
869
 
861
- const testEntityAlice = await nymph.getEntity(
862
- { class: TestModel },
863
- { type: '&', guid: bobsEntity.guid || '' },
864
- );
870
+ const testEntityAlice = await nymph.getEntity(
871
+ { class: TestModel },
872
+ { type: '&', guid: bobsEntity.guid || '' },
873
+ );
865
874
 
866
- expect(testEntityAlice).not.toBeNull();
867
- expect(testEntityAlice?.guid).toEqual(bobsEntity.guid);
875
+ expect(testEntityAlice).not.toBeNull();
876
+ expect(testEntityAlice?.guid).toEqual(bobsEntity.guid);
868
877
 
869
- if (testEntityAlice == null) {
870
- throw new Error();
871
- }
878
+ if (testEntityAlice == null) {
879
+ throw new Error();
880
+ }
872
881
 
873
- expect(await testEntityAlice.$delete()).toEqual(true);
874
- const verifyEntityAlice = await nymph.getEntity(
875
- { class: TestModel },
876
- { type: '&', guid: bobsEntity.guid || '' },
877
- );
878
- expect(verifyEntityAlice).toBeNull();
879
- });
882
+ expect(await testEntityAlice.$delete()).toEqual(true);
883
+ const verifyEntityAlice = await nymph.getEntity(
884
+ { class: TestModel },
885
+ { type: '&', guid: bobsEntity.guid || '' },
886
+ );
887
+ expect(verifyEntityAlice).toBeNull();
888
+ });
880
889
 
881
- it('alice can access an entity everyone has permission for', async () => {
882
- const { bob, alice } = await makeUsers();
890
+ it('alice can access an entity everyone has permission for', async () => {
891
+ const { bob, alice } = await makeUsers();
883
892
 
884
- await tilmeld.fillSession(bob);
893
+ await tilmeld.fillSession(bob);
885
894
 
886
- const bobsEntity = await TestModel.factory();
887
- bobsEntity.name = "Bob's Entity";
888
- bobsEntity.acOther = TilmeldAccessLevels.READ_ACCESS;
889
- expect(await bobsEntity.$save()).toEqual(true);
895
+ const bobsEntity = await TestModel.factory();
896
+ bobsEntity.name = "Bob's Entity";
897
+ bobsEntity.acOther = TilmeldAccessLevels.READ_ACCESS;
898
+ expect(await bobsEntity.$save()).toEqual(true);
890
899
 
891
- expect(bobsEntity.guid).not.toBeNull();
892
- expect(bob.$is(bobsEntity.user)).toEqual(true);
900
+ expect(bobsEntity.guid).not.toBeNull();
901
+ expect(bob.$is(bobsEntity.user)).toEqual(true);
893
902
 
894
- const testEntityBob = await nymph.getEntity(
895
- { class: TestModel },
896
- { type: '&', guid: bobsEntity.guid || '' },
897
- );
903
+ const testEntityBob = await nymph.getEntity(
904
+ { class: TestModel },
905
+ { type: '&', guid: bobsEntity.guid || '' },
906
+ );
898
907
 
899
- expect(testEntityBob).not.toBeNull();
900
- expect(testEntityBob?.guid).toEqual(bobsEntity.guid);
908
+ expect(testEntityBob).not.toBeNull();
909
+ expect(testEntityBob?.guid).toEqual(bobsEntity.guid);
901
910
 
902
- tilmeld.clearSession();
903
- await tilmeld.fillSession(alice);
911
+ tilmeld.clearSession();
912
+ await tilmeld.fillSession(alice);
904
913
 
905
- const testEntityAlice = await nymph.getEntity(
906
- { class: TestModel },
907
- { type: '&', guid: bobsEntity.guid || '' },
908
- );
914
+ const testEntityAlice = await nymph.getEntity(
915
+ { class: TestModel },
916
+ { type: '&', guid: bobsEntity.guid || '' },
917
+ );
909
918
 
910
- expect(testEntityAlice).not.toBeNull();
911
- expect(testEntityAlice?.guid).toEqual(bobsEntity.guid);
912
- });
919
+ expect(testEntityAlice).not.toBeNull();
920
+ expect(testEntityAlice?.guid).toEqual(bobsEntity.guid);
921
+ });
913
922
 
914
- it("alice can't write to an entity everyone doesn't have write permission for", async () => {
915
- const { bob, alice } = await makeUsers();
923
+ it("alice can't write to an entity everyone doesn't have write permission for", async () => {
924
+ const { bob, alice } = await makeUsers();
916
925
 
917
- await tilmeld.fillSession(bob);
926
+ await tilmeld.fillSession(bob);
918
927
 
919
- const bobsEntity = await TestModel.factory();
920
- bobsEntity.name = "Bob's Entity";
921
- bobsEntity.acOther = TilmeldAccessLevels.READ_ACCESS;
922
- expect(await bobsEntity.$save()).toEqual(true);
928
+ const bobsEntity = await TestModel.factory();
929
+ bobsEntity.name = "Bob's Entity";
930
+ bobsEntity.acOther = TilmeldAccessLevels.READ_ACCESS;
931
+ expect(await bobsEntity.$save()).toEqual(true);
923
932
 
924
- expect(bobsEntity.guid).not.toBeNull();
925
- expect(bob.$is(bobsEntity.user)).toEqual(true);
933
+ expect(bobsEntity.guid).not.toBeNull();
934
+ expect(bob.$is(bobsEntity.user)).toEqual(true);
926
935
 
927
- const testEntityBob = await nymph.getEntity(
928
- { class: TestModel },
929
- { type: '&', guid: bobsEntity.guid || '' },
930
- );
936
+ const testEntityBob = await nymph.getEntity(
937
+ { class: TestModel },
938
+ { type: '&', guid: bobsEntity.guid || '' },
939
+ );
931
940
 
932
- expect(testEntityBob).not.toBeNull();
933
- expect(testEntityBob?.guid).toEqual(bobsEntity.guid);
941
+ expect(testEntityBob).not.toBeNull();
942
+ expect(testEntityBob?.guid).toEqual(bobsEntity.guid);
934
943
 
935
- tilmeld.clearSession();
936
- await tilmeld.fillSession(alice);
944
+ tilmeld.clearSession();
945
+ await tilmeld.fillSession(alice);
937
946
 
938
- const testEntityAlice = await nymph.getEntity(
939
- { class: TestModel },
940
- { type: '&', guid: bobsEntity.guid || '' },
941
- );
947
+ const testEntityAlice = await nymph.getEntity(
948
+ { class: TestModel },
949
+ { type: '&', guid: bobsEntity.guid || '' },
950
+ );
942
951
 
943
- expect(testEntityAlice).not.toBeNull();
944
- expect(testEntityAlice?.guid).toEqual(bobsEntity.guid);
952
+ expect(testEntityAlice).not.toBeNull();
953
+ expect(testEntityAlice?.guid).toEqual(bobsEntity.guid);
945
954
 
946
- if (testEntityAlice == null) {
947
- throw new Error();
948
- }
955
+ if (testEntityAlice == null) {
956
+ throw new Error();
957
+ }
949
958
 
950
- testEntityAlice.name = "Haha! It's mine now!";
951
- try {
952
- await testEntityAlice.$save();
953
- throw new Error('It should have thrown AccessControlError.');
954
- } catch (e: any) {
955
- expect(e).toBeInstanceOf(AccessControlError);
956
- }
959
+ testEntityAlice.name = "Haha! It's mine now!";
960
+ try {
961
+ await testEntityAlice.$save();
962
+ throw new Error('It should have thrown AccessControlError.');
963
+ } catch (e: any) {
964
+ expect(e).toBeInstanceOf(AccessControlError);
965
+ }
957
966
 
958
- expect(await testEntityAlice.$refresh()).toEqual(true);
959
- expect(testEntityAlice.name).toEqual("Bob's Entity");
960
- });
967
+ expect(await testEntityAlice.$refresh()).toEqual(true);
968
+ expect(testEntityAlice.name).toEqual("Bob's Entity");
969
+ });
961
970
 
962
- it('alice can write to an entity everyone has write permission for', async () => {
963
- const { bob, alice } = await makeUsers();
971
+ it('alice can write to an entity everyone has write permission for', async () => {
972
+ const { bob, alice } = await makeUsers();
964
973
 
965
- await tilmeld.fillSession(bob);
974
+ await tilmeld.fillSession(bob);
966
975
 
967
- const bobsEntity = await TestModel.factory();
968
- bobsEntity.name = "Bob's Entity";
969
- bobsEntity.acOther = TilmeldAccessLevels.WRITE_ACCESS;
970
- expect(await bobsEntity.$save()).toEqual(true);
976
+ const bobsEntity = await TestModel.factory();
977
+ bobsEntity.name = "Bob's Entity";
978
+ bobsEntity.acOther = TilmeldAccessLevels.WRITE_ACCESS;
979
+ expect(await bobsEntity.$save()).toEqual(true);
971
980
 
972
- expect(bobsEntity.guid).not.toBeNull();
973
- expect(bob.$is(bobsEntity.user)).toEqual(true);
981
+ expect(bobsEntity.guid).not.toBeNull();
982
+ expect(bob.$is(bobsEntity.user)).toEqual(true);
974
983
 
975
- const testEntityBob = await nymph.getEntity(
976
- { class: TestModel },
977
- { type: '&', guid: bobsEntity.guid || '' },
978
- );
984
+ const testEntityBob = await nymph.getEntity(
985
+ { class: TestModel },
986
+ { type: '&', guid: bobsEntity.guid || '' },
987
+ );
979
988
 
980
- expect(testEntityBob).not.toBeNull();
981
- expect(testEntityBob?.guid).toEqual(bobsEntity.guid);
989
+ expect(testEntityBob).not.toBeNull();
990
+ expect(testEntityBob?.guid).toEqual(bobsEntity.guid);
982
991
 
983
- tilmeld.clearSession();
984
- await tilmeld.fillSession(alice);
992
+ tilmeld.clearSession();
993
+ await tilmeld.fillSession(alice);
985
994
 
986
- const testEntityAlice = await nymph.getEntity(
987
- { class: TestModel },
988
- { type: '&', guid: bobsEntity.guid || '' },
989
- );
995
+ const testEntityAlice = await nymph.getEntity(
996
+ { class: TestModel },
997
+ { type: '&', guid: bobsEntity.guid || '' },
998
+ );
990
999
 
991
- expect(testEntityAlice).not.toBeNull();
992
- expect(testEntityAlice?.guid).toEqual(bobsEntity.guid);
1000
+ expect(testEntityAlice).not.toBeNull();
1001
+ expect(testEntityAlice?.guid).toEqual(bobsEntity.guid);
993
1002
 
994
- if (testEntityAlice == null) {
995
- throw new Error();
996
- }
1003
+ if (testEntityAlice == null) {
1004
+ throw new Error();
1005
+ }
997
1006
 
998
- testEntityAlice.name = "Haha! It's mine now!";
999
- expect(await testEntityAlice.$save()).toEqual(true);
1007
+ testEntityAlice.name = "Haha! It's mine now!";
1008
+ expect(await testEntityAlice.$save()).toEqual(true);
1000
1009
 
1001
- expect(await testEntityAlice.$refresh()).toEqual(true);
1002
- expect(testEntityAlice.name).toEqual("Haha! It's mine now!");
1003
- });
1010
+ expect(await testEntityAlice.$refresh()).toEqual(true);
1011
+ expect(testEntityAlice.name).toEqual("Haha! It's mine now!");
1012
+ });
1004
1013
 
1005
- it("alice can't delete an entity everyone doesn't have full permission for", async () => {
1006
- const { bob, alice } = await makeUsers();
1014
+ it("alice can't delete an entity everyone doesn't have full permission for", async () => {
1015
+ const { bob, alice } = await makeUsers();
1007
1016
 
1008
- await tilmeld.fillSession(bob);
1017
+ await tilmeld.fillSession(bob);
1009
1018
 
1010
- const bobsEntity = await TestModel.factory();
1011
- bobsEntity.name = "Bob's Entity";
1012
- bobsEntity.acOther = TilmeldAccessLevels.WRITE_ACCESS;
1013
- expect(await bobsEntity.$save()).toEqual(true);
1019
+ const bobsEntity = await TestModel.factory();
1020
+ bobsEntity.name = "Bob's Entity";
1021
+ bobsEntity.acOther = TilmeldAccessLevels.WRITE_ACCESS;
1022
+ expect(await bobsEntity.$save()).toEqual(true);
1014
1023
 
1015
- expect(bobsEntity.guid).not.toBeNull();
1016
- expect(bob.$is(bobsEntity.user)).toEqual(true);
1024
+ expect(bobsEntity.guid).not.toBeNull();
1025
+ expect(bob.$is(bobsEntity.user)).toEqual(true);
1017
1026
 
1018
- const testEntityBob = await nymph.getEntity(
1019
- { class: TestModel },
1020
- { type: '&', guid: bobsEntity.guid || '' },
1021
- );
1027
+ const testEntityBob = await nymph.getEntity(
1028
+ { class: TestModel },
1029
+ { type: '&', guid: bobsEntity.guid || '' },
1030
+ );
1022
1031
 
1023
- expect(testEntityBob).not.toBeNull();
1024
- expect(testEntityBob?.guid).toEqual(bobsEntity.guid);
1032
+ expect(testEntityBob).not.toBeNull();
1033
+ expect(testEntityBob?.guid).toEqual(bobsEntity.guid);
1025
1034
 
1026
- tilmeld.clearSession();
1027
- await tilmeld.fillSession(alice);
1035
+ tilmeld.clearSession();
1036
+ await tilmeld.fillSession(alice);
1028
1037
 
1029
- const testEntityAlice = await nymph.getEntity(
1030
- { class: TestModel },
1031
- { type: '&', guid: bobsEntity.guid || '' },
1032
- );
1038
+ const testEntityAlice = await nymph.getEntity(
1039
+ { class: TestModel },
1040
+ { type: '&', guid: bobsEntity.guid || '' },
1041
+ );
1033
1042
 
1034
- expect(testEntityAlice).not.toBeNull();
1035
- expect(testEntityAlice?.guid).toEqual(bobsEntity.guid);
1043
+ expect(testEntityAlice).not.toBeNull();
1044
+ expect(testEntityAlice?.guid).toEqual(bobsEntity.guid);
1036
1045
 
1037
- if (testEntityAlice == null) {
1038
- throw new Error();
1039
- }
1046
+ if (testEntityAlice == null) {
1047
+ throw new Error();
1048
+ }
1040
1049
 
1041
- try {
1042
- await testEntityAlice.$delete();
1043
- throw new Error('It should have thrown AccessControlError.');
1044
- } catch (e: any) {
1045
- expect(e).toBeInstanceOf(AccessControlError);
1046
- }
1050
+ try {
1051
+ await testEntityAlice.$delete();
1052
+ throw new Error('It should have thrown AccessControlError.');
1053
+ } catch (e: any) {
1054
+ expect(e).toBeInstanceOf(AccessControlError);
1055
+ }
1047
1056
 
1048
- expect(await testEntityAlice.$refresh()).toEqual(true);
1049
- expect(testEntityAlice.guid).toEqual(bobsEntity.guid);
1050
- });
1057
+ expect(await testEntityAlice.$refresh()).toEqual(true);
1058
+ expect(testEntityAlice.guid).toEqual(bobsEntity.guid);
1059
+ });
1051
1060
 
1052
- it('alice can delete an entity everyone has full permission for', async () => {
1053
- const { bob, alice } = await makeUsers();
1061
+ it('alice can delete an entity everyone has full permission for', async () => {
1062
+ const { bob, alice } = await makeUsers();
1054
1063
 
1055
- await tilmeld.fillSession(bob);
1064
+ await tilmeld.fillSession(bob);
1056
1065
 
1057
- const bobsEntity = await TestModel.factory();
1058
- bobsEntity.name = "Bob's Entity";
1059
- bobsEntity.acOther = TilmeldAccessLevels.FULL_ACCESS;
1060
- expect(await bobsEntity.$save()).toEqual(true);
1066
+ const bobsEntity = await TestModel.factory();
1067
+ bobsEntity.name = "Bob's Entity";
1068
+ bobsEntity.acOther = TilmeldAccessLevels.FULL_ACCESS;
1069
+ expect(await bobsEntity.$save()).toEqual(true);
1061
1070
 
1062
- expect(bobsEntity.guid).not.toBeNull();
1063
- expect(bob.$is(bobsEntity.user)).toEqual(true);
1071
+ expect(bobsEntity.guid).not.toBeNull();
1072
+ expect(bob.$is(bobsEntity.user)).toEqual(true);
1064
1073
 
1065
- const testEntityBob = await nymph.getEntity(
1066
- { class: TestModel },
1067
- { type: '&', guid: bobsEntity.guid || '' },
1068
- );
1074
+ const testEntityBob = await nymph.getEntity(
1075
+ { class: TestModel },
1076
+ { type: '&', guid: bobsEntity.guid || '' },
1077
+ );
1069
1078
 
1070
- expect(testEntityBob).not.toBeNull();
1071
- expect(testEntityBob?.guid).toEqual(bobsEntity.guid);
1079
+ expect(testEntityBob).not.toBeNull();
1080
+ expect(testEntityBob?.guid).toEqual(bobsEntity.guid);
1072
1081
 
1073
- tilmeld.clearSession();
1074
- await tilmeld.fillSession(alice);
1082
+ tilmeld.clearSession();
1083
+ await tilmeld.fillSession(alice);
1075
1084
 
1076
- const testEntityAlice = await nymph.getEntity(
1077
- { class: TestModel },
1078
- { type: '&', guid: bobsEntity.guid || '' },
1079
- );
1085
+ const testEntityAlice = await nymph.getEntity(
1086
+ { class: TestModel },
1087
+ { type: '&', guid: bobsEntity.guid || '' },
1088
+ );
1080
1089
 
1081
- expect(testEntityAlice).not.toBeNull();
1082
- expect(testEntityAlice?.guid).toEqual(bobsEntity.guid);
1090
+ expect(testEntityAlice).not.toBeNull();
1091
+ expect(testEntityAlice?.guid).toEqual(bobsEntity.guid);
1083
1092
 
1084
- if (testEntityAlice == null) {
1085
- throw new Error();
1086
- }
1093
+ if (testEntityAlice == null) {
1094
+ throw new Error();
1095
+ }
1087
1096
 
1088
- expect(await testEntityAlice.$delete()).toEqual(true);
1089
- const verifyEntityAlice = await nymph.getEntity(
1090
- { class: TestModel },
1091
- { type: '&', guid: bobsEntity.guid || '' },
1092
- );
1093
- expect(verifyEntityAlice).toBeNull();
1094
- });
1097
+ expect(await testEntityAlice.$delete()).toEqual(true);
1098
+ const verifyEntityAlice = await nymph.getEntity(
1099
+ { class: TestModel },
1100
+ { type: '&', guid: bobsEntity.guid || '' },
1101
+ );
1102
+ expect(verifyEntityAlice).toBeNull();
1103
+ });
1095
1104
 
1096
- it('a clear session can delete an entity everyone has full permission for', async () => {
1097
- const { bob } = await makeUsers();
1105
+ it('a clear session can delete an entity everyone has full permission for', async () => {
1106
+ const { bob } = await makeUsers();
1098
1107
 
1099
- await tilmeld.fillSession(bob);
1108
+ await tilmeld.fillSession(bob);
1100
1109
 
1101
- const bobsEntity = await TestModel.factory();
1102
- bobsEntity.name = "Bob's Entity";
1103
- bobsEntity.acOther = TilmeldAccessLevels.FULL_ACCESS;
1104
- expect(await bobsEntity.$save()).toEqual(true);
1110
+ const bobsEntity = await TestModel.factory();
1111
+ bobsEntity.name = "Bob's Entity";
1112
+ bobsEntity.acOther = TilmeldAccessLevels.FULL_ACCESS;
1113
+ expect(await bobsEntity.$save()).toEqual(true);
1105
1114
 
1106
- expect(bobsEntity.guid).not.toBeNull();
1107
- expect(bob.$is(bobsEntity.user)).toEqual(true);
1115
+ expect(bobsEntity.guid).not.toBeNull();
1116
+ expect(bob.$is(bobsEntity.user)).toEqual(true);
1108
1117
 
1109
- const testEntityBob = await nymph.getEntity(
1110
- { class: TestModel },
1111
- { type: '&', guid: bobsEntity.guid || '' },
1112
- );
1118
+ const testEntityBob = await nymph.getEntity(
1119
+ { class: TestModel },
1120
+ { type: '&', guid: bobsEntity.guid || '' },
1121
+ );
1113
1122
 
1114
- expect(testEntityBob).not.toBeNull();
1115
- expect(testEntityBob?.guid).toEqual(bobsEntity.guid);
1123
+ expect(testEntityBob).not.toBeNull();
1124
+ expect(testEntityBob?.guid).toEqual(bobsEntity.guid);
1116
1125
 
1117
- tilmeld.clearSession();
1126
+ tilmeld.clearSession();
1118
1127
 
1119
- const testEntityNobody = await nymph.getEntity(
1120
- { class: TestModel },
1121
- { type: '&', guid: bobsEntity.guid || '' },
1122
- );
1128
+ const testEntityNobody = await nymph.getEntity(
1129
+ { class: TestModel },
1130
+ { type: '&', guid: bobsEntity.guid || '' },
1131
+ );
1123
1132
 
1124
- expect(testEntityNobody).not.toBeNull();
1125
- expect(testEntityNobody?.guid).toEqual(bobsEntity.guid);
1133
+ expect(testEntityNobody).not.toBeNull();
1134
+ expect(testEntityNobody?.guid).toEqual(bobsEntity.guid);
1126
1135
 
1127
- if (testEntityNobody == null) {
1128
- throw new Error();
1129
- }
1136
+ if (testEntityNobody == null) {
1137
+ throw new Error();
1138
+ }
1130
1139
 
1131
- expect(await testEntityNobody.$delete()).toEqual(true);
1132
- const verifyEntityNobody = await nymph.getEntity(
1133
- { class: TestModel },
1134
- { type: '&', guid: bobsEntity.guid || '' },
1135
- );
1136
- expect(verifyEntityNobody).toBeNull();
1137
- });
1140
+ expect(await testEntityNobody.$delete()).toEqual(true);
1141
+ const verifyEntityNobody = await nymph.getEntity(
1142
+ { class: TestModel },
1143
+ { type: '&', guid: bobsEntity.guid || '' },
1144
+ );
1145
+ expect(verifyEntityNobody).toBeNull();
1146
+ });
1138
1147
 
1139
- it('allows skip ac deletions', async () => {
1140
- const allEntities = [
1141
- ...(await nymph.getEntities({ class: TestModel, skipAc: true })),
1142
- ...(await nymph.getEntities({ class: User, skipAc: true })),
1143
- ...(await nymph.getEntities({ class: Group, skipAc: true })),
1144
- ];
1145
- for (let entity of allEntities) {
1146
- expect(await entity.$deleteSkipAC()).toEqual(true);
1147
- }
1148
- });
1148
+ it('allows skip ac deletions', async () => {
1149
+ const allEntities = [
1150
+ ...(await nymph.getEntities({ class: TestModel, skipAc: true })),
1151
+ ...(await nymph.getEntities({ class: User, skipAc: true })),
1152
+ ...(await nymph.getEntities({ class: Group, skipAc: true })),
1153
+ ];
1154
+ for (let entity of allEntities) {
1155
+ expect(await entity.$deleteSkipAC()).toEqual(true);
1156
+ }
1157
+ });
1149
1158
 
1150
- it('entity can be retrieved by queries on ac properties', async () => {
1151
- const { bob, alice } = await makeUsers();
1152
-
1153
- await tilmeld.fillSession(bob);
1154
-
1155
- const bobsEntity = await TestModel.factory();
1156
- bobsEntity.name = "Bob's Entity";
1157
- bobsEntity.acRead = [
1158
- alice.guid ?? '',
1159
- bob.guid ?? '',
1160
- ...(bob.group ? [bob.group.guid ?? ''] : []),
1161
- ];
1162
- bobsEntity.acWrite = [alice.guid ?? '', bob.guid ?? ''];
1163
- bobsEntity.acFull = [bob.guid ?? ''];
1164
- expect(await bobsEntity.$save()).toEqual(true);
1165
-
1166
- expect(bobsEntity.guid).not.toBeNull();
1167
- expect(bob.$is(bobsEntity.user)).toEqual(true);
1168
-
1169
- const testEntityBob = await nymph.getEntity(
1170
- { class: TestModel },
1171
- { type: '&', guid: bobsEntity.guid || '' },
1172
- );
1173
-
1174
- expect(testEntityBob).not.toBeNull();
1175
- expect(testEntityBob?.guid).toEqual(bobsEntity.guid);
1176
-
1177
- tilmeld.clearSession();
1178
- await tilmeld.fillSession(alice);
1179
-
1180
- // Equals queries.
1181
-
1182
- let testEntityAlice = await nymph.getEntity(
1183
- { class: TestModel },
1184
- {
1185
- type: '&',
1186
- guid: bobsEntity.guid || '',
1187
- equal: ['user', bob.guid],
1188
- },
1189
- );
1190
-
1191
- expect(testEntityAlice).not.toBeNull();
1192
- expect(testEntityAlice?.guid).toEqual(bobsEntity.guid);
1193
-
1194
- testEntityAlice = await nymph.getEntity(
1195
- { class: TestModel },
1196
- {
1197
- type: '&',
1198
- guid: bobsEntity.guid || '',
1199
- equal: ['user', '000000000000000000000000'],
1200
- },
1201
- );
1202
-
1203
- expect(testEntityAlice).toBeNull();
1204
-
1205
- testEntityAlice = await nymph.getEntity(
1206
- { class: TestModel },
1207
- {
1208
- type: '&',
1209
- guid: bobsEntity.guid || '',
1210
- equal: ['group', bob.group?.guid],
1211
- },
1212
- );
1213
-
1214
- expect(testEntityAlice).not.toBeNull();
1215
- expect(testEntityAlice?.guid).toEqual(bobsEntity.guid);
1216
-
1217
- testEntityAlice = await nymph.getEntity(
1218
- { class: TestModel },
1219
- {
1220
- type: '&',
1221
- guid: bobsEntity.guid || '',
1222
- equal: ['group', '000000000000000000000000'],
1223
- },
1224
- );
1225
-
1226
- expect(testEntityAlice).toBeNull();
1227
-
1228
- // Contains queries.
1229
-
1230
- testEntityAlice = await nymph.getEntity(
1231
- { class: TestModel },
1232
- {
1233
- type: '&',
1234
- guid: bobsEntity.guid || '',
1235
- contain: ['user', bob.guid],
1236
- },
1237
- );
1238
-
1239
- expect(testEntityAlice).not.toBeNull();
1240
- expect(testEntityAlice?.guid).toEqual(bobsEntity.guid);
1241
-
1242
- testEntityAlice = await nymph.getEntity(
1243
- { class: TestModel },
1244
- {
1245
- type: '&',
1246
- guid: bobsEntity.guid || '',
1247
- contain: ['user', '000000000000000000000000'],
1248
- },
1249
- );
1250
-
1251
- expect(testEntityAlice).toBeNull();
1252
-
1253
- testEntityAlice = await nymph.getEntity(
1254
- { class: TestModel },
1255
- {
1256
- type: '&',
1257
- guid: bobsEntity.guid || '',
1258
- contain: ['group', bob.group?.guid],
1259
- },
1260
- );
1261
-
1262
- expect(testEntityAlice).not.toBeNull();
1263
- expect(testEntityAlice?.guid).toEqual(bobsEntity.guid);
1264
-
1265
- testEntityAlice = await nymph.getEntity(
1266
- { class: TestModel },
1267
- {
1268
- type: '&',
1269
- guid: bobsEntity.guid || '',
1270
- contain: ['group', '000000000000000000000000'],
1271
- },
1272
- );
1273
-
1274
- expect(testEntityAlice).toBeNull();
1275
-
1276
- testEntityAlice = await nymph.getEntity(
1277
- { class: TestModel },
1278
- {
1279
- type: '&',
1280
- guid: bobsEntity.guid || '',
1281
- contain: ['acRead', alice.guid],
1282
- },
1283
- );
1284
-
1285
- expect(testEntityAlice).not.toBeNull();
1286
- expect(testEntityAlice?.guid).toEqual(bobsEntity.guid);
1287
-
1288
- testEntityAlice = await nymph.getEntity(
1289
- { class: TestModel },
1290
- {
1291
- type: '&',
1292
- guid: bobsEntity.guid || '',
1293
- contain: ['acRead', '000000000000000000000000'],
1294
- },
1295
- );
1296
-
1297
- expect(testEntityAlice).toBeNull();
1298
-
1299
- testEntityAlice = await nymph.getEntity(
1300
- { class: TestModel },
1301
- {
1302
- type: '&',
1303
- guid: bobsEntity.guid || '',
1304
- contain: ['acWrite', bob.guid],
1305
- },
1306
- );
1307
-
1308
- expect(testEntityAlice).not.toBeNull();
1309
- expect(testEntityAlice?.guid).toEqual(bobsEntity.guid);
1310
-
1311
- testEntityAlice = await nymph.getEntity(
1312
- { class: TestModel },
1313
- {
1314
- type: '&',
1315
- guid: bobsEntity.guid || '',
1316
- contain: ['acWrite', '000000000000000000000000'],
1317
- },
1318
- );
1319
-
1320
- expect(testEntityAlice).toBeNull();
1321
-
1322
- testEntityAlice = await nymph.getEntity(
1323
- { class: TestModel },
1324
- {
1325
- type: '&',
1326
- guid: bobsEntity.guid || '',
1327
- contain: ['acFull', bob.guid],
1328
- },
1329
- );
1330
-
1331
- expect(testEntityAlice).not.toBeNull();
1332
- expect(testEntityAlice?.guid).toEqual(bobsEntity.guid);
1333
-
1334
- testEntityAlice = await nymph.getEntity(
1335
- { class: TestModel },
1336
- {
1337
- type: '&',
1338
- guid: bobsEntity.guid || '',
1339
- contain: ['acFull', '000000000000000000000000'],
1340
- },
1341
- );
1342
-
1343
- expect(testEntityAlice).toBeNull();
1344
-
1345
- // Ref queries.
1346
-
1347
- testEntityAlice = await nymph.getEntity(
1348
- { class: TestModel },
1349
- {
1350
- type: '&',
1351
- guid: bobsEntity.guid || '',
1352
- ref: ['user', bob],
1353
- },
1354
- );
1355
-
1356
- expect(testEntityAlice).not.toBeNull();
1357
- expect(testEntityAlice?.guid).toEqual(bobsEntity.guid);
1358
-
1359
- testEntityAlice = await nymph.getEntity(
1360
- { class: TestModel },
1361
- {
1362
- type: '&',
1363
- guid: bobsEntity.guid || '',
1364
- ref: ['user', '000000000000000000000000'],
1365
- },
1366
- );
1367
-
1368
- expect(testEntityAlice).toBeNull();
1369
-
1370
- testEntityAlice = await nymph.getEntity(
1371
- { class: TestModel },
1372
- {
1373
- type: '&',
1374
- guid: bobsEntity.guid || '',
1375
- ref: ['group', bob.group ?? ''],
1376
- },
1377
- );
1378
-
1379
- expect(testEntityAlice).not.toBeNull();
1380
- expect(testEntityAlice?.guid).toEqual(bobsEntity.guid);
1381
-
1382
- testEntityAlice = await nymph.getEntity(
1383
- { class: TestModel },
1384
- {
1385
- type: '&',
1386
- guid: bobsEntity.guid || '',
1387
- ref: ['group', '000000000000000000000000'],
1388
- },
1389
- );
1390
-
1391
- expect(testEntityAlice).toBeNull();
1392
-
1393
- testEntityAlice = await nymph.getEntity(
1394
- { class: TestModel },
1395
- {
1396
- type: '&',
1397
- guid: bobsEntity.guid || '',
1398
- ref: ['acRead', alice],
1399
- },
1400
- );
1401
-
1402
- expect(testEntityAlice).not.toBeNull();
1403
- expect(testEntityAlice?.guid).toEqual(bobsEntity.guid);
1404
-
1405
- testEntityAlice = await nymph.getEntity(
1406
- { class: TestModel },
1407
- {
1408
- type: '&',
1409
- guid: bobsEntity.guid || '',
1410
- ref: ['acRead', '000000000000000000000000'],
1411
- },
1412
- );
1413
-
1414
- expect(testEntityAlice).toBeNull();
1415
-
1416
- testEntityAlice = await nymph.getEntity(
1417
- { class: TestModel },
1418
- {
1419
- type: '&',
1420
- guid: bobsEntity.guid || '',
1421
- ref: ['acWrite', bob],
1422
- },
1423
- );
1424
-
1425
- expect(testEntityAlice).not.toBeNull();
1426
- expect(testEntityAlice?.guid).toEqual(bobsEntity.guid);
1427
-
1428
- testEntityAlice = await nymph.getEntity(
1429
- { class: TestModel },
1430
- {
1431
- type: '&',
1432
- guid: bobsEntity.guid || '',
1433
- ref: ['acWrite', '000000000000000000000000'],
1434
- },
1435
- );
1436
-
1437
- expect(testEntityAlice).toBeNull();
1438
-
1439
- testEntityAlice = await nymph.getEntity(
1440
- { class: TestModel },
1441
- {
1442
- type: '&',
1443
- guid: bobsEntity.guid || '',
1444
- ref: ['acFull', bob],
1445
- },
1446
- );
1447
-
1448
- expect(testEntityAlice).not.toBeNull();
1449
- expect(testEntityAlice?.guid).toEqual(bobsEntity.guid);
1450
-
1451
- testEntityAlice = await nymph.getEntity(
1452
- { class: TestModel },
1453
- {
1454
- type: '&',
1455
- guid: bobsEntity.guid || '',
1456
- ref: ['acFull', '000000000000000000000000'],
1457
- },
1458
- );
1459
-
1460
- expect(testEntityAlice).toBeNull();
1461
-
1462
- // QRef queries.
1463
-
1464
- testEntityAlice = await nymph.getEntity(
1465
- { class: TestModel },
1466
- {
1467
- type: '&',
1468
- guid: bobsEntity.guid || '',
1469
- qref: [
1470
- 'user',
1471
- [
1472
- { class: User },
1473
- { type: '&', equal: ['username', bob.username ?? ''] },
1159
+ it('entity can be retrieved by queries on ac properties', async () => {
1160
+ const { bob, alice } = await makeUsers();
1161
+
1162
+ await tilmeld.fillSession(bob);
1163
+
1164
+ const bobsEntity = await TestModel.factory();
1165
+ bobsEntity.name = "Bob's Entity";
1166
+ bobsEntity.acRead = [
1167
+ alice.guid ?? '',
1168
+ bob.guid ?? '',
1169
+ ...(bob.group ? [bob.group.guid ?? ''] : []),
1170
+ ];
1171
+ bobsEntity.acWrite = [alice.guid ?? '', bob.guid ?? ''];
1172
+ bobsEntity.acFull = [bob.guid ?? ''];
1173
+ expect(await bobsEntity.$save()).toEqual(true);
1174
+
1175
+ expect(bobsEntity.guid).not.toBeNull();
1176
+ expect(bob.$is(bobsEntity.user)).toEqual(true);
1177
+
1178
+ const testEntityBob = await nymph.getEntity(
1179
+ { class: TestModel },
1180
+ { type: '&', guid: bobsEntity.guid || '' },
1181
+ );
1182
+
1183
+ expect(testEntityBob).not.toBeNull();
1184
+ expect(testEntityBob?.guid).toEqual(bobsEntity.guid);
1185
+
1186
+ tilmeld.clearSession();
1187
+ await tilmeld.fillSession(alice);
1188
+
1189
+ // Equals queries.
1190
+
1191
+ let testEntityAlice = await nymph.getEntity(
1192
+ { class: TestModel },
1193
+ {
1194
+ type: '&',
1195
+ guid: bobsEntity.guid || '',
1196
+ equal: ['user', bob.guid],
1197
+ },
1198
+ );
1199
+
1200
+ expect(testEntityAlice).not.toBeNull();
1201
+ expect(testEntityAlice?.guid).toEqual(bobsEntity.guid);
1202
+
1203
+ testEntityAlice = await nymph.getEntity(
1204
+ { class: TestModel },
1205
+ {
1206
+ type: '&',
1207
+ guid: bobsEntity.guid || '',
1208
+ equal: ['user', '000000000000000000000000'],
1209
+ },
1210
+ );
1211
+
1212
+ expect(testEntityAlice).toBeNull();
1213
+
1214
+ testEntityAlice = await nymph.getEntity(
1215
+ { class: TestModel },
1216
+ {
1217
+ type: '&',
1218
+ guid: bobsEntity.guid || '',
1219
+ equal: ['group', bob.group?.guid],
1220
+ },
1221
+ );
1222
+
1223
+ expect(testEntityAlice).not.toBeNull();
1224
+ expect(testEntityAlice?.guid).toEqual(bobsEntity.guid);
1225
+
1226
+ testEntityAlice = await nymph.getEntity(
1227
+ { class: TestModel },
1228
+ {
1229
+ type: '&',
1230
+ guid: bobsEntity.guid || '',
1231
+ equal: ['group', '000000000000000000000000'],
1232
+ },
1233
+ );
1234
+
1235
+ expect(testEntityAlice).toBeNull();
1236
+
1237
+ // Contains queries.
1238
+
1239
+ testEntityAlice = await nymph.getEntity(
1240
+ { class: TestModel },
1241
+ {
1242
+ type: '&',
1243
+ guid: bobsEntity.guid || '',
1244
+ contain: ['user', bob.guid],
1245
+ },
1246
+ );
1247
+
1248
+ expect(testEntityAlice).not.toBeNull();
1249
+ expect(testEntityAlice?.guid).toEqual(bobsEntity.guid);
1250
+
1251
+ testEntityAlice = await nymph.getEntity(
1252
+ { class: TestModel },
1253
+ {
1254
+ type: '&',
1255
+ guid: bobsEntity.guid || '',
1256
+ contain: ['user', '000000000000000000000000'],
1257
+ },
1258
+ );
1259
+
1260
+ expect(testEntityAlice).toBeNull();
1261
+
1262
+ testEntityAlice = await nymph.getEntity(
1263
+ { class: TestModel },
1264
+ {
1265
+ type: '&',
1266
+ guid: bobsEntity.guid || '',
1267
+ contain: ['group', bob.group?.guid],
1268
+ },
1269
+ );
1270
+
1271
+ expect(testEntityAlice).not.toBeNull();
1272
+ expect(testEntityAlice?.guid).toEqual(bobsEntity.guid);
1273
+
1274
+ testEntityAlice = await nymph.getEntity(
1275
+ { class: TestModel },
1276
+ {
1277
+ type: '&',
1278
+ guid: bobsEntity.guid || '',
1279
+ contain: ['group', '000000000000000000000000'],
1280
+ },
1281
+ );
1282
+
1283
+ expect(testEntityAlice).toBeNull();
1284
+
1285
+ testEntityAlice = await nymph.getEntity(
1286
+ { class: TestModel },
1287
+ {
1288
+ type: '&',
1289
+ guid: bobsEntity.guid || '',
1290
+ contain: ['acRead', alice.guid],
1291
+ },
1292
+ );
1293
+
1294
+ expect(testEntityAlice).not.toBeNull();
1295
+ expect(testEntityAlice?.guid).toEqual(bobsEntity.guid);
1296
+
1297
+ testEntityAlice = await nymph.getEntity(
1298
+ { class: TestModel },
1299
+ {
1300
+ type: '&',
1301
+ guid: bobsEntity.guid || '',
1302
+ contain: ['acRead', '000000000000000000000000'],
1303
+ },
1304
+ );
1305
+
1306
+ expect(testEntityAlice).toBeNull();
1307
+
1308
+ testEntityAlice = await nymph.getEntity(
1309
+ { class: TestModel },
1310
+ {
1311
+ type: '&',
1312
+ guid: bobsEntity.guid || '',
1313
+ contain: ['acWrite', bob.guid],
1314
+ },
1315
+ );
1316
+
1317
+ expect(testEntityAlice).not.toBeNull();
1318
+ expect(testEntityAlice?.guid).toEqual(bobsEntity.guid);
1319
+
1320
+ testEntityAlice = await nymph.getEntity(
1321
+ { class: TestModel },
1322
+ {
1323
+ type: '&',
1324
+ guid: bobsEntity.guid || '',
1325
+ contain: ['acWrite', '000000000000000000000000'],
1326
+ },
1327
+ );
1328
+
1329
+ expect(testEntityAlice).toBeNull();
1330
+
1331
+ testEntityAlice = await nymph.getEntity(
1332
+ { class: TestModel },
1333
+ {
1334
+ type: '&',
1335
+ guid: bobsEntity.guid || '',
1336
+ contain: ['acFull', bob.guid],
1337
+ },
1338
+ );
1339
+
1340
+ expect(testEntityAlice).not.toBeNull();
1341
+ expect(testEntityAlice?.guid).toEqual(bobsEntity.guid);
1342
+
1343
+ testEntityAlice = await nymph.getEntity(
1344
+ { class: TestModel },
1345
+ {
1346
+ type: '&',
1347
+ guid: bobsEntity.guid || '',
1348
+ contain: ['acFull', '000000000000000000000000'],
1349
+ },
1350
+ );
1351
+
1352
+ expect(testEntityAlice).toBeNull();
1353
+
1354
+ // Ref queries.
1355
+
1356
+ testEntityAlice = await nymph.getEntity(
1357
+ { class: TestModel },
1358
+ {
1359
+ type: '&',
1360
+ guid: bobsEntity.guid || '',
1361
+ ref: ['user', bob],
1362
+ },
1363
+ );
1364
+
1365
+ expect(testEntityAlice).not.toBeNull();
1366
+ expect(testEntityAlice?.guid).toEqual(bobsEntity.guid);
1367
+
1368
+ testEntityAlice = await nymph.getEntity(
1369
+ { class: TestModel },
1370
+ {
1371
+ type: '&',
1372
+ guid: bobsEntity.guid || '',
1373
+ ref: ['user', '000000000000000000000000'],
1374
+ },
1375
+ );
1376
+
1377
+ expect(testEntityAlice).toBeNull();
1378
+
1379
+ testEntityAlice = await nymph.getEntity(
1380
+ { class: TestModel },
1381
+ {
1382
+ type: '&',
1383
+ guid: bobsEntity.guid || '',
1384
+ ref: ['group', bob.group ?? ''],
1385
+ },
1386
+ );
1387
+
1388
+ expect(testEntityAlice).not.toBeNull();
1389
+ expect(testEntityAlice?.guid).toEqual(bobsEntity.guid);
1390
+
1391
+ testEntityAlice = await nymph.getEntity(
1392
+ { class: TestModel },
1393
+ {
1394
+ type: '&',
1395
+ guid: bobsEntity.guid || '',
1396
+ ref: ['group', '000000000000000000000000'],
1397
+ },
1398
+ );
1399
+
1400
+ expect(testEntityAlice).toBeNull();
1401
+
1402
+ testEntityAlice = await nymph.getEntity(
1403
+ { class: TestModel },
1404
+ {
1405
+ type: '&',
1406
+ guid: bobsEntity.guid || '',
1407
+ ref: ['acRead', alice],
1408
+ },
1409
+ );
1410
+
1411
+ expect(testEntityAlice).not.toBeNull();
1412
+ expect(testEntityAlice?.guid).toEqual(bobsEntity.guid);
1413
+
1414
+ testEntityAlice = await nymph.getEntity(
1415
+ { class: TestModel },
1416
+ {
1417
+ type: '&',
1418
+ guid: bobsEntity.guid || '',
1419
+ ref: ['acRead', '000000000000000000000000'],
1420
+ },
1421
+ );
1422
+
1423
+ expect(testEntityAlice).toBeNull();
1424
+
1425
+ testEntityAlice = await nymph.getEntity(
1426
+ { class: TestModel },
1427
+ {
1428
+ type: '&',
1429
+ guid: bobsEntity.guid || '',
1430
+ ref: ['acWrite', bob],
1431
+ },
1432
+ );
1433
+
1434
+ expect(testEntityAlice).not.toBeNull();
1435
+ expect(testEntityAlice?.guid).toEqual(bobsEntity.guid);
1436
+
1437
+ testEntityAlice = await nymph.getEntity(
1438
+ { class: TestModel },
1439
+ {
1440
+ type: '&',
1441
+ guid: bobsEntity.guid || '',
1442
+ ref: ['acWrite', '000000000000000000000000'],
1443
+ },
1444
+ );
1445
+
1446
+ expect(testEntityAlice).toBeNull();
1447
+
1448
+ testEntityAlice = await nymph.getEntity(
1449
+ { class: TestModel },
1450
+ {
1451
+ type: '&',
1452
+ guid: bobsEntity.guid || '',
1453
+ ref: ['acFull', bob],
1454
+ },
1455
+ );
1456
+
1457
+ expect(testEntityAlice).not.toBeNull();
1458
+ expect(testEntityAlice?.guid).toEqual(bobsEntity.guid);
1459
+
1460
+ testEntityAlice = await nymph.getEntity(
1461
+ { class: TestModel },
1462
+ {
1463
+ type: '&',
1464
+ guid: bobsEntity.guid || '',
1465
+ ref: ['acFull', '000000000000000000000000'],
1466
+ },
1467
+ );
1468
+
1469
+ expect(testEntityAlice).toBeNull();
1470
+
1471
+ // QRef queries.
1472
+
1473
+ testEntityAlice = await nymph.getEntity(
1474
+ { class: TestModel },
1475
+ {
1476
+ type: '&',
1477
+ guid: bobsEntity.guid || '',
1478
+ qref: [
1479
+ 'user',
1480
+ [
1481
+ { class: User },
1482
+ { type: '&', equal: ['username', bob.username ?? ''] },
1483
+ ],
1474
1484
  ],
1475
- ],
1476
- },
1477
- );
1478
-
1479
- expect(testEntityAlice).not.toBeNull();
1480
- expect(testEntityAlice?.guid).toEqual(bobsEntity.guid);
1481
-
1482
- testEntityAlice = await nymph.getEntity(
1483
- { class: TestModel },
1484
- {
1485
- type: '&',
1486
- guid: bobsEntity.guid || '',
1487
- qref: [
1488
- 'user',
1489
- [{ class: User }, { type: '&', equal: ['username', 'pickle'] }],
1490
- ],
1491
- },
1492
- );
1493
-
1494
- expect(testEntityAlice).toBeNull();
1495
-
1496
- testEntityAlice = await nymph.getEntity(
1497
- { class: TestModel },
1498
- {
1499
- type: '&',
1500
- guid: bobsEntity.guid || '',
1501
- qref: [
1502
- 'acRead',
1503
- [
1504
- { class: User },
1505
- { type: '&', equal: ['username', alice.username ?? ''] },
1485
+ },
1486
+ );
1487
+
1488
+ expect(testEntityAlice).not.toBeNull();
1489
+ expect(testEntityAlice?.guid).toEqual(bobsEntity.guid);
1490
+
1491
+ testEntityAlice = await nymph.getEntity(
1492
+ { class: TestModel },
1493
+ {
1494
+ type: '&',
1495
+ guid: bobsEntity.guid || '',
1496
+ qref: [
1497
+ 'user',
1498
+ [{ class: User }, { type: '&', equal: ['username', 'pickle'] }],
1506
1499
  ],
1507
- ],
1508
- },
1509
- );
1510
-
1511
- expect(testEntityAlice).not.toBeNull();
1512
- expect(testEntityAlice?.guid).toEqual(bobsEntity.guid);
1513
-
1514
- testEntityAlice = await nymph.getEntity(
1515
- { class: TestModel },
1516
- {
1517
- type: '&',
1518
- guid: bobsEntity.guid || '',
1519
- qref: [
1520
- 'acRead',
1521
- [{ class: User }, { type: '&', equal: ['username', 'pickle'] }],
1522
- ],
1523
- },
1524
- );
1525
-
1526
- expect(testEntityAlice).toBeNull();
1527
- });
1500
+ },
1501
+ );
1502
+
1503
+ expect(testEntityAlice).toBeNull();
1504
+
1505
+ testEntityAlice = await nymph.getEntity(
1506
+ { class: TestModel },
1507
+ {
1508
+ type: '&',
1509
+ guid: bobsEntity.guid || '',
1510
+ qref: [
1511
+ 'acRead',
1512
+ [
1513
+ { class: User },
1514
+ { type: '&', equal: ['username', alice.username ?? ''] },
1515
+ ],
1516
+ ],
1517
+ },
1518
+ );
1519
+
1520
+ expect(testEntityAlice).not.toBeNull();
1521
+ expect(testEntityAlice?.guid).toEqual(bobsEntity.guid);
1522
+
1523
+ testEntityAlice = await nymph.getEntity(
1524
+ { class: TestModel },
1525
+ {
1526
+ type: '&',
1527
+ guid: bobsEntity.guid || '',
1528
+ qref: [
1529
+ 'acRead',
1530
+ [{ class: User }, { type: '&', equal: ['username', 'pickle'] }],
1531
+ ],
1532
+ },
1533
+ );
1528
1534
 
1529
- it('alice can access an entity with an access request', async () => {
1530
- const { bob, alice } = await makeUsers();
1535
+ expect(testEntityAlice).toBeNull();
1536
+ });
1531
1537
 
1532
- await tilmeld.fillSession(alice);
1538
+ it('alice can access an entity with an access request', async () => {
1539
+ const { bob, alice } = await makeUsers();
1533
1540
 
1534
- const alicesEntity = await TestModel.factory();
1535
- alicesEntity.name = "Alice's Entity";
1536
- expect(await alicesEntity.$save()).toEqual(true);
1541
+ await tilmeld.fillSession(alice);
1537
1542
 
1538
- expect(alicesEntity.guid).not.toBeNull();
1539
- expect(alice.$is(alicesEntity.user)).toEqual(true);
1543
+ const alicesEntity = await TestModel.factory();
1544
+ alicesEntity.name = "Alice's Entity";
1545
+ expect(await alicesEntity.$save()).toEqual(true);
1540
1546
 
1541
- const testEntityAlice = await nymph.getEntity(
1542
- { class: TestModel, acRequest: TilmeldAccessRequest.USER_OWNED },
1543
- { type: '&', guid: alicesEntity.guid || '' },
1544
- );
1547
+ expect(alicesEntity.guid).not.toBeNull();
1548
+ expect(alice.$is(alicesEntity.user)).toEqual(true);
1545
1549
 
1546
- expect(testEntityAlice).not.toBeNull();
1547
- expect(testEntityAlice?.guid).toEqual(alicesEntity.guid);
1550
+ const testEntityAlice = await nymph.getEntity(
1551
+ { class: TestModel, acRequest: TilmeldAccessRequest.USER_OWNED },
1552
+ { type: '&', guid: alicesEntity.guid || '' },
1553
+ );
1548
1554
 
1549
- tilmeld.clearSession();
1550
- });
1555
+ expect(testEntityAlice).not.toBeNull();
1556
+ expect(testEntityAlice?.guid).toEqual(alicesEntity.guid);
1551
1557
 
1552
- it("access request for user owned doesn't return group owned entity", async () => {
1553
- const { bob, alice } = await makeUsers();
1558
+ tilmeld.clearSession();
1559
+ });
1554
1560
 
1555
- await tilmeld.fillSession(bob);
1561
+ it("access request for user owned doesn't return group owned entity", async () => {
1562
+ const { bob, alice } = await makeUsers();
1556
1563
 
1557
- const bobsEntity = await TestModel.factory();
1558
- bobsEntity.name = "Bob's Entity";
1559
- bobsEntity.group = alice.group;
1560
- expect(await bobsEntity.$save()).toEqual(true);
1564
+ await tilmeld.fillSession(bob);
1561
1565
 
1562
- expect(bobsEntity.guid).not.toBeNull();
1563
- expect(bob.$is(bobsEntity.user)).toEqual(true);
1566
+ const bobsEntity = await TestModel.factory();
1567
+ bobsEntity.name = "Bob's Entity";
1568
+ bobsEntity.group = alice.group;
1569
+ expect(await bobsEntity.$save()).toEqual(true);
1564
1570
 
1565
- const testEntityBob = await nymph.getEntity(
1566
- { class: TestModel },
1567
- { type: '&', guid: bobsEntity.guid || '' },
1568
- );
1571
+ expect(bobsEntity.guid).not.toBeNull();
1572
+ expect(bob.$is(bobsEntity.user)).toEqual(true);
1569
1573
 
1570
- expect(testEntityBob).not.toBeNull();
1571
- expect(testEntityBob?.guid).toEqual(bobsEntity.guid);
1574
+ const testEntityBob = await nymph.getEntity(
1575
+ { class: TestModel },
1576
+ { type: '&', guid: bobsEntity.guid || '' },
1577
+ );
1572
1578
 
1573
- tilmeld.clearSession();
1574
- await tilmeld.fillSession(alice);
1579
+ expect(testEntityBob).not.toBeNull();
1580
+ expect(testEntityBob?.guid).toEqual(bobsEntity.guid);
1575
1581
 
1576
- const testEntityAlice = await nymph.getEntity(
1577
- { class: TestModel },
1578
- { type: '&', guid: bobsEntity.guid || '' },
1579
- );
1582
+ tilmeld.clearSession();
1583
+ await tilmeld.fillSession(alice);
1580
1584
 
1581
- expect(testEntityAlice).not.toBeNull();
1585
+ const testEntityAlice = await nymph.getEntity(
1586
+ { class: TestModel },
1587
+ { type: '&', guid: bobsEntity.guid || '' },
1588
+ );
1582
1589
 
1583
- const testFailureEntityAlice = await nymph.getEntity(
1584
- { class: TestModel, acRequest: TilmeldAccessRequest.USER_OWNED },
1585
- { type: '&', guid: bobsEntity.guid || '' },
1586
- );
1590
+ expect(testEntityAlice).not.toBeNull();
1587
1591
 
1588
- expect(testFailureEntityAlice).toBeNull();
1592
+ const testFailureEntityAlice = await nymph.getEntity(
1593
+ { class: TestModel, acRequest: TilmeldAccessRequest.USER_OWNED },
1594
+ { type: '&', guid: bobsEntity.guid || '' },
1595
+ );
1589
1596
 
1590
- const testSuccessEntityAlice = await nymph.getEntity(
1591
- { class: TestModel, acRequest: TilmeldAccessRequest.PRIMARY_GROUP_OWNED },
1592
- { type: '&', guid: bobsEntity.guid || '' },
1593
- );
1597
+ expect(testFailureEntityAlice).toBeNull();
1594
1598
 
1595
- expect(testSuccessEntityAlice).not.toBeNull();
1596
- });
1599
+ const testSuccessEntityAlice = await nymph.getEntity(
1600
+ {
1601
+ class: TestModel,
1602
+ acRequest: TilmeldAccessRequest.PRIMARY_GROUP_OWNED,
1603
+ },
1604
+ { type: '&', guid: bobsEntity.guid || '' },
1605
+ );
1597
1606
 
1598
- it("access request for user owned doesn't return acOther accessible entity", async () => {
1599
- const { bob, alice } = await makeUsers();
1607
+ expect(testSuccessEntityAlice).not.toBeNull();
1608
+ });
1600
1609
 
1601
- await tilmeld.fillSession(bob);
1610
+ it("access request for user owned doesn't return acOther accessible entity", async () => {
1611
+ const { bob, alice } = await makeUsers();
1602
1612
 
1603
- const bobsEntity = await TestModel.factory();
1604
- bobsEntity.name = "Bob's Entity";
1605
- bobsEntity.acOther = TilmeldAccessLevels.READ_ACCESS;
1606
- expect(await bobsEntity.$save()).toEqual(true);
1613
+ await tilmeld.fillSession(bob);
1607
1614
 
1608
- expect(bobsEntity.guid).not.toBeNull();
1609
- expect(bob.$is(bobsEntity.user)).toEqual(true);
1615
+ const bobsEntity = await TestModel.factory();
1616
+ bobsEntity.name = "Bob's Entity";
1617
+ bobsEntity.acOther = TilmeldAccessLevels.READ_ACCESS;
1618
+ expect(await bobsEntity.$save()).toEqual(true);
1610
1619
 
1611
- const testEntityBob = await nymph.getEntity(
1612
- { class: TestModel },
1613
- { type: '&', guid: bobsEntity.guid || '' },
1614
- );
1620
+ expect(bobsEntity.guid).not.toBeNull();
1621
+ expect(bob.$is(bobsEntity.user)).toEqual(true);
1615
1622
 
1616
- expect(testEntityBob).not.toBeNull();
1617
- expect(testEntityBob?.guid).toEqual(bobsEntity.guid);
1623
+ const testEntityBob = await nymph.getEntity(
1624
+ { class: TestModel },
1625
+ { type: '&', guid: bobsEntity.guid || '' },
1626
+ );
1618
1627
 
1619
- tilmeld.clearSession();
1620
- await tilmeld.fillSession(alice);
1628
+ expect(testEntityBob).not.toBeNull();
1629
+ expect(testEntityBob?.guid).toEqual(bobsEntity.guid);
1621
1630
 
1622
- const testEntityAlice = await nymph.getEntity(
1623
- { class: TestModel },
1624
- { type: '&', guid: bobsEntity.guid || '' },
1625
- );
1631
+ tilmeld.clearSession();
1632
+ await tilmeld.fillSession(alice);
1626
1633
 
1627
- expect(testEntityAlice).not.toBeNull();
1634
+ const testEntityAlice = await nymph.getEntity(
1635
+ { class: TestModel },
1636
+ { type: '&', guid: bobsEntity.guid || '' },
1637
+ );
1628
1638
 
1629
- const testFailureEntityAlice = await nymph.getEntity(
1630
- { class: TestModel, acRequest: TilmeldAccessRequest.USER_OWNED },
1631
- { type: '&', guid: bobsEntity.guid || '' },
1632
- );
1639
+ expect(testEntityAlice).not.toBeNull();
1633
1640
 
1634
- expect(testFailureEntityAlice).toBeNull();
1641
+ const testFailureEntityAlice = await nymph.getEntity(
1642
+ { class: TestModel, acRequest: TilmeldAccessRequest.USER_OWNED },
1643
+ { type: '&', guid: bobsEntity.guid || '' },
1644
+ );
1635
1645
 
1636
- const testSuccessEntityAlice = await nymph.getEntity(
1637
- { class: TestModel, acRequest: TilmeldAccessRequest.OTHER_ACCESSIBLE },
1638
- { type: '&', guid: bobsEntity.guid || '' },
1639
- );
1646
+ expect(testFailureEntityAlice).toBeNull();
1640
1647
 
1641
- expect(testSuccessEntityAlice).not.toBeNull();
1642
- });
1648
+ const testSuccessEntityAlice = await nymph.getEntity(
1649
+ { class: TestModel, acRequest: TilmeldAccessRequest.OTHER_ACCESSIBLE },
1650
+ { type: '&', guid: bobsEntity.guid || '' },
1651
+ );
1652
+
1653
+ expect(testSuccessEntityAlice).not.toBeNull();
1654
+ });
1643
1655
 
1644
- it("access request for user owned doesn't return user acRead accessible entity", async () => {
1645
- const { bob, alice } = await makeUsers();
1656
+ it("access request for user owned doesn't return user acRead accessible entity", async () => {
1657
+ const { bob, alice } = await makeUsers();
1646
1658
 
1647
- await tilmeld.fillSession(bob);
1659
+ await tilmeld.fillSession(bob);
1648
1660
 
1649
- const bobsEntity = await TestModel.factory();
1650
- bobsEntity.name = "Bob's Entity";
1651
- bobsEntity.acRead = [alice.guid ?? ''];
1652
- expect(await bobsEntity.$save()).toEqual(true);
1661
+ const bobsEntity = await TestModel.factory();
1662
+ bobsEntity.name = "Bob's Entity";
1663
+ bobsEntity.acRead = [alice.guid ?? ''];
1664
+ expect(await bobsEntity.$save()).toEqual(true);
1653
1665
 
1654
- expect(bobsEntity.guid).not.toBeNull();
1655
- expect(bob.$is(bobsEntity.user)).toEqual(true);
1666
+ expect(bobsEntity.guid).not.toBeNull();
1667
+ expect(bob.$is(bobsEntity.user)).toEqual(true);
1656
1668
 
1657
- const testEntityBob = await nymph.getEntity(
1658
- { class: TestModel },
1659
- { type: '&', guid: bobsEntity.guid || '' },
1660
- );
1669
+ const testEntityBob = await nymph.getEntity(
1670
+ { class: TestModel },
1671
+ { type: '&', guid: bobsEntity.guid || '' },
1672
+ );
1661
1673
 
1662
- expect(testEntityBob).not.toBeNull();
1663
- expect(testEntityBob?.guid).toEqual(bobsEntity.guid);
1674
+ expect(testEntityBob).not.toBeNull();
1675
+ expect(testEntityBob?.guid).toEqual(bobsEntity.guid);
1664
1676
 
1665
- tilmeld.clearSession();
1666
- await tilmeld.fillSession(alice);
1677
+ tilmeld.clearSession();
1678
+ await tilmeld.fillSession(alice);
1667
1679
 
1668
- const testEntityAlice = await nymph.getEntity(
1669
- { class: TestModel },
1670
- { type: '&', guid: bobsEntity.guid || '' },
1671
- );
1680
+ const testEntityAlice = await nymph.getEntity(
1681
+ { class: TestModel },
1682
+ { type: '&', guid: bobsEntity.guid || '' },
1683
+ );
1672
1684
 
1673
- expect(testEntityAlice).not.toBeNull();
1685
+ expect(testEntityAlice).not.toBeNull();
1674
1686
 
1675
- const testFailureEntityAlice = await nymph.getEntity(
1676
- { class: TestModel, acRequest: TilmeldAccessRequest.USER_OWNED },
1677
- { type: '&', guid: bobsEntity.guid || '' },
1678
- );
1687
+ const testFailureEntityAlice = await nymph.getEntity(
1688
+ { class: TestModel, acRequest: TilmeldAccessRequest.USER_OWNED },
1689
+ { type: '&', guid: bobsEntity.guid || '' },
1690
+ );
1679
1691
 
1680
- expect(testFailureEntityAlice).toBeNull();
1692
+ expect(testFailureEntityAlice).toBeNull();
1681
1693
 
1682
- const testSuccessEntityAlice = await nymph.getEntity(
1683
- { class: TestModel, acRequest: TilmeldAccessRequest.USER_ACCESSIBLE },
1684
- { type: '&', guid: bobsEntity.guid || '' },
1685
- );
1694
+ const testSuccessEntityAlice = await nymph.getEntity(
1695
+ { class: TestModel, acRequest: TilmeldAccessRequest.USER_ACCESSIBLE },
1696
+ { type: '&', guid: bobsEntity.guid || '' },
1697
+ );
1686
1698
 
1687
- expect(testSuccessEntityAlice).not.toBeNull();
1688
- });
1699
+ expect(testSuccessEntityAlice).not.toBeNull();
1700
+ });
1689
1701
 
1690
- it("access request for user owned doesn't return group acRead accessible entity", async () => {
1691
- const { bob, alice } = await makeUsers();
1702
+ it("access request for user owned doesn't return group acRead accessible entity", async () => {
1703
+ const { bob, alice } = await makeUsers();
1692
1704
 
1693
- await tilmeld.fillSession(bob);
1705
+ await tilmeld.fillSession(bob);
1694
1706
 
1695
- const bobsEntity = await TestModel.factory();
1696
- bobsEntity.name = "Bob's Entity";
1697
- bobsEntity.acWrite = [alice.group?.guid ?? ''];
1698
- expect(await bobsEntity.$save()).toEqual(true);
1707
+ const bobsEntity = await TestModel.factory();
1708
+ bobsEntity.name = "Bob's Entity";
1709
+ bobsEntity.acWrite = [alice.group?.guid ?? ''];
1710
+ expect(await bobsEntity.$save()).toEqual(true);
1699
1711
 
1700
- expect(bobsEntity.guid).not.toBeNull();
1701
- expect(bob.$is(bobsEntity.user)).toEqual(true);
1712
+ expect(bobsEntity.guid).not.toBeNull();
1713
+ expect(bob.$is(bobsEntity.user)).toEqual(true);
1702
1714
 
1703
- const testEntityBob = await nymph.getEntity(
1704
- { class: TestModel },
1705
- { type: '&', guid: bobsEntity.guid || '' },
1706
- );
1715
+ const testEntityBob = await nymph.getEntity(
1716
+ { class: TestModel },
1717
+ { type: '&', guid: bobsEntity.guid || '' },
1718
+ );
1707
1719
 
1708
- expect(testEntityBob).not.toBeNull();
1709
- expect(testEntityBob?.guid).toEqual(bobsEntity.guid);
1720
+ expect(testEntityBob).not.toBeNull();
1721
+ expect(testEntityBob?.guid).toEqual(bobsEntity.guid);
1710
1722
 
1711
- tilmeld.clearSession();
1712
- await tilmeld.fillSession(alice);
1723
+ tilmeld.clearSession();
1724
+ await tilmeld.fillSession(alice);
1713
1725
 
1714
- const testEntityAlice = await nymph.getEntity(
1715
- { class: TestModel },
1716
- { type: '&', guid: bobsEntity.guid || '' },
1717
- );
1726
+ const testEntityAlice = await nymph.getEntity(
1727
+ { class: TestModel },
1728
+ { type: '&', guid: bobsEntity.guid || '' },
1729
+ );
1718
1730
 
1719
- expect(testEntityAlice).not.toBeNull();
1731
+ expect(testEntityAlice).not.toBeNull();
1720
1732
 
1721
- const testFailureEntityAlice = await nymph.getEntity(
1722
- { class: TestModel, acRequest: TilmeldAccessRequest.USER_OWNED },
1723
- { type: '&', guid: bobsEntity.guid || '' },
1724
- );
1733
+ const testFailureEntityAlice = await nymph.getEntity(
1734
+ { class: TestModel, acRequest: TilmeldAccessRequest.USER_OWNED },
1735
+ { type: '&', guid: bobsEntity.guid || '' },
1736
+ );
1725
1737
 
1726
- expect(testFailureEntityAlice).toBeNull();
1738
+ expect(testFailureEntityAlice).toBeNull();
1727
1739
 
1728
- const testSuccessEntityAlice = await nymph.getEntity(
1729
- {
1730
- class: TestModel,
1731
- acRequest: TilmeldAccessRequest.PRIMARY_GROUP_ACCESSIBLE,
1732
- },
1733
- { type: '&', guid: bobsEntity.guid || '' },
1734
- );
1740
+ const testSuccessEntityAlice = await nymph.getEntity(
1741
+ {
1742
+ class: TestModel,
1743
+ acRequest: TilmeldAccessRequest.PRIMARY_GROUP_ACCESSIBLE,
1744
+ },
1745
+ { type: '&', guid: bobsEntity.guid || '' },
1746
+ );
1735
1747
 
1736
- expect(testSuccessEntityAlice).not.toBeNull();
1737
- });
1748
+ expect(testSuccessEntityAlice).not.toBeNull();
1749
+ });
1738
1750
 
1739
- it("access request for user owned doesn't return secondary group owned entity", async () => {
1740
- const { bob, alice, abgroup } = await makeUsers();
1751
+ it("access request for user owned doesn't return secondary group owned entity", async () => {
1752
+ const { bob, alice, abgroup } = await makeUsers();
1741
1753
 
1742
- await tilmeld.fillSession(bob);
1754
+ await tilmeld.fillSession(bob);
1743
1755
 
1744
- const bobsEntity = await TestModel.factory();
1745
- bobsEntity.name = "Bob's Entity";
1746
- bobsEntity.group = abgroup;
1747
- expect(await bobsEntity.$save()).toEqual(true);
1756
+ const bobsEntity = await TestModel.factory();
1757
+ bobsEntity.name = "Bob's Entity";
1758
+ bobsEntity.group = abgroup;
1759
+ expect(await bobsEntity.$save()).toEqual(true);
1748
1760
 
1749
- expect(bobsEntity.guid).not.toBeNull();
1750
- expect(bob.$is(bobsEntity.user)).toEqual(true);
1761
+ expect(bobsEntity.guid).not.toBeNull();
1762
+ expect(bob.$is(bobsEntity.user)).toEqual(true);
1751
1763
 
1752
- const testEntityBob = await nymph.getEntity(
1753
- { class: TestModel },
1754
- { type: '&', guid: bobsEntity.guid || '' },
1755
- );
1764
+ const testEntityBob = await nymph.getEntity(
1765
+ { class: TestModel },
1766
+ { type: '&', guid: bobsEntity.guid || '' },
1767
+ );
1756
1768
 
1757
- expect(testEntityBob).not.toBeNull();
1758
- expect(testEntityBob?.guid).toEqual(bobsEntity.guid);
1769
+ expect(testEntityBob).not.toBeNull();
1770
+ expect(testEntityBob?.guid).toEqual(bobsEntity.guid);
1759
1771
 
1760
- tilmeld.clearSession();
1761
- await tilmeld.fillSession(alice);
1772
+ tilmeld.clearSession();
1773
+ await tilmeld.fillSession(alice);
1762
1774
 
1763
- const testEntityAlice = await nymph.getEntity(
1764
- { class: TestModel },
1765
- { type: '&', guid: bobsEntity.guid || '' },
1766
- );
1775
+ const testEntityAlice = await nymph.getEntity(
1776
+ { class: TestModel },
1777
+ { type: '&', guid: bobsEntity.guid || '' },
1778
+ );
1767
1779
 
1768
- expect(testEntityAlice).not.toBeNull();
1780
+ expect(testEntityAlice).not.toBeNull();
1769
1781
 
1770
- const testFailureEntityAlice = await nymph.getEntity(
1771
- { class: TestModel, acRequest: TilmeldAccessRequest.USER_OWNED },
1772
- { type: '&', guid: bobsEntity.guid || '' },
1773
- );
1782
+ const testFailureEntityAlice = await nymph.getEntity(
1783
+ { class: TestModel, acRequest: TilmeldAccessRequest.USER_OWNED },
1784
+ { type: '&', guid: bobsEntity.guid || '' },
1785
+ );
1774
1786
 
1775
- expect(testFailureEntityAlice).toBeNull();
1787
+ expect(testFailureEntityAlice).toBeNull();
1776
1788
 
1777
- const testSuccessEntityAlice = await nymph.getEntity(
1778
- {
1779
- class: TestModel,
1780
- acRequest: TilmeldAccessRequest.SECONDARY_GROUP_OWNED,
1781
- },
1782
- { type: '&', guid: bobsEntity.guid || '' },
1783
- );
1789
+ const testSuccessEntityAlice = await nymph.getEntity(
1790
+ {
1791
+ class: TestModel,
1792
+ acRequest: TilmeldAccessRequest.SECONDARY_GROUP_OWNED,
1793
+ },
1794
+ { type: '&', guid: bobsEntity.guid || '' },
1795
+ );
1784
1796
 
1785
- expect(testSuccessEntityAlice).not.toBeNull();
1786
- });
1797
+ expect(testSuccessEntityAlice).not.toBeNull();
1798
+ });
1787
1799
 
1788
- it("access request for user owned doesn't return secondary group accessible entity", async () => {
1789
- const { bob, alice, abgroup } = await makeUsers();
1800
+ it("access request for user owned doesn't return secondary group accessible entity", async () => {
1801
+ const { bob, alice, abgroup } = await makeUsers();
1790
1802
 
1791
- await tilmeld.fillSession(bob);
1803
+ await tilmeld.fillSession(bob);
1792
1804
 
1793
- const bobsEntity = await TestModel.factory();
1794
- bobsEntity.name = "Bob's Entity";
1795
- bobsEntity.acFull = [abgroup.guid ?? ''];
1796
- expect(await bobsEntity.$save()).toEqual(true);
1805
+ const bobsEntity = await TestModel.factory();
1806
+ bobsEntity.name = "Bob's Entity";
1807
+ bobsEntity.acFull = [abgroup.guid ?? ''];
1808
+ expect(await bobsEntity.$save()).toEqual(true);
1797
1809
 
1798
- expect(bobsEntity.guid).not.toBeNull();
1799
- expect(bob.$is(bobsEntity.user)).toEqual(true);
1810
+ expect(bobsEntity.guid).not.toBeNull();
1811
+ expect(bob.$is(bobsEntity.user)).toEqual(true);
1800
1812
 
1801
- const testEntityBob = await nymph.getEntity(
1802
- { class: TestModel },
1803
- { type: '&', guid: bobsEntity.guid || '' },
1804
- );
1813
+ const testEntityBob = await nymph.getEntity(
1814
+ { class: TestModel },
1815
+ { type: '&', guid: bobsEntity.guid || '' },
1816
+ );
1805
1817
 
1806
- expect(testEntityBob).not.toBeNull();
1807
- expect(testEntityBob?.guid).toEqual(bobsEntity.guid);
1818
+ expect(testEntityBob).not.toBeNull();
1819
+ expect(testEntityBob?.guid).toEqual(bobsEntity.guid);
1808
1820
 
1809
- tilmeld.clearSession();
1810
- await tilmeld.fillSession(alice);
1821
+ tilmeld.clearSession();
1822
+ await tilmeld.fillSession(alice);
1811
1823
 
1812
- const testEntityAlice = await nymph.getEntity(
1813
- { class: TestModel },
1814
- { type: '&', guid: bobsEntity.guid || '' },
1815
- );
1824
+ const testEntityAlice = await nymph.getEntity(
1825
+ { class: TestModel },
1826
+ { type: '&', guid: bobsEntity.guid || '' },
1827
+ );
1816
1828
 
1817
- expect(testEntityAlice).not.toBeNull();
1829
+ expect(testEntityAlice).not.toBeNull();
1818
1830
 
1819
- const testFailureEntityAlice = await nymph.getEntity(
1820
- { class: TestModel, acRequest: TilmeldAccessRequest.USER_OWNED },
1821
- { type: '&', guid: bobsEntity.guid || '' },
1822
- );
1831
+ const testFailureEntityAlice = await nymph.getEntity(
1832
+ { class: TestModel, acRequest: TilmeldAccessRequest.USER_OWNED },
1833
+ { type: '&', guid: bobsEntity.guid || '' },
1834
+ );
1823
1835
 
1824
- expect(testFailureEntityAlice).toBeNull();
1836
+ expect(testFailureEntityAlice).toBeNull();
1825
1837
 
1826
- const testSuccessEntityAlice = await nymph.getEntity(
1827
- {
1828
- class: TestModel,
1829
- acRequest: TilmeldAccessRequest.SECONDARY_GROUP_ACCESSIBLE,
1830
- },
1831
- { type: '&', guid: bobsEntity.guid || '' },
1832
- );
1838
+ const testSuccessEntityAlice = await nymph.getEntity(
1839
+ {
1840
+ class: TestModel,
1841
+ acRequest: TilmeldAccessRequest.SECONDARY_GROUP_ACCESSIBLE,
1842
+ },
1843
+ { type: '&', guid: bobsEntity.guid || '' },
1844
+ );
1833
1845
 
1834
- expect(testSuccessEntityAlice).not.toBeNull();
1846
+ expect(testSuccessEntityAlice).not.toBeNull();
1835
1847
 
1836
- // Test or-ing two levels together.
1837
- const testSuccessEntityAlice2 = await nymph.getEntity(
1838
- {
1839
- class: TestModel,
1840
- acRequest:
1841
- TilmeldAccessRequest.SECONDARY_GROUP_ACCESSIBLE |
1842
- TilmeldAccessRequest.PRIMARY_GROUP_ACCESSIBLE,
1843
- },
1844
- { type: '&', guid: bobsEntity.guid || '' },
1845
- );
1848
+ // Test or-ing two levels together.
1849
+ const testSuccessEntityAlice2 = await nymph.getEntity(
1850
+ {
1851
+ class: TestModel,
1852
+ acRequest:
1853
+ TilmeldAccessRequest.SECONDARY_GROUP_ACCESSIBLE |
1854
+ TilmeldAccessRequest.PRIMARY_GROUP_ACCESSIBLE,
1855
+ },
1856
+ { type: '&', guid: bobsEntity.guid || '' },
1857
+ );
1846
1858
 
1847
- expect(testSuccessEntityAlice2).not.toBeNull();
1848
- });
1859
+ expect(testSuccessEntityAlice2).not.toBeNull();
1860
+ });
1849
1861
 
1850
- it('access request for entity still works when filtering user owned entities manually', async () => {
1851
- const { bob, alice } = await makeUsers();
1862
+ it('access request for entity still works when filtering user owned entities manually', async () => {
1863
+ const { bob, alice } = await makeUsers();
1852
1864
 
1853
- await tilmeld.fillSession(bob);
1865
+ await tilmeld.fillSession(bob);
1854
1866
 
1855
- const bobsEntity = await TestModel.factory();
1856
- bobsEntity.name = "Bob's Entity";
1857
- bobsEntity.acFull = [alice.guid ?? ''];
1858
- expect(await bobsEntity.$save()).toEqual(true);
1867
+ const bobsEntity = await TestModel.factory();
1868
+ bobsEntity.name = "Bob's Entity";
1869
+ bobsEntity.acFull = [alice.guid ?? ''];
1870
+ expect(await bobsEntity.$save()).toEqual(true);
1859
1871
 
1860
- expect(bobsEntity.guid).not.toBeNull();
1861
- expect(bob.$is(bobsEntity.user)).toEqual(true);
1872
+ expect(bobsEntity.guid).not.toBeNull();
1873
+ expect(bob.$is(bobsEntity.user)).toEqual(true);
1862
1874
 
1863
- const testEntityBob = await nymph.getEntity(
1864
- { class: TestModel },
1865
- { type: '&', guid: bobsEntity.guid || '' },
1866
- );
1875
+ const testEntityBob = await nymph.getEntity(
1876
+ { class: TestModel },
1877
+ { type: '&', guid: bobsEntity.guid || '' },
1878
+ );
1867
1879
 
1868
- expect(testEntityBob).not.toBeNull();
1869
- expect(testEntityBob?.guid).toEqual(bobsEntity.guid);
1880
+ expect(testEntityBob).not.toBeNull();
1881
+ expect(testEntityBob?.guid).toEqual(bobsEntity.guid);
1870
1882
 
1871
- tilmeld.clearSession();
1872
- await tilmeld.fillSession(alice);
1883
+ tilmeld.clearSession();
1884
+ await tilmeld.fillSession(alice);
1873
1885
 
1874
- const alicesEntity = await TestModel.factory();
1875
- alicesEntity.name = "Alice's Entity";
1876
- expect(await alicesEntity.$save()).toEqual(true);
1886
+ const alicesEntity = await TestModel.factory();
1887
+ alicesEntity.name = "Alice's Entity";
1888
+ expect(await alicesEntity.$save()).toEqual(true);
1877
1889
 
1878
- expect(alicesEntity.guid).not.toBeNull();
1879
- expect(alice.$is(alicesEntity.user)).toEqual(true);
1890
+ expect(alicesEntity.guid).not.toBeNull();
1891
+ expect(alice.$is(alicesEntity.user)).toEqual(true);
1880
1892
 
1881
- const testEntityAlice = await nymph.getEntity(
1882
- { class: TestModel },
1883
- { type: '&', guid: bobsEntity.guid || '' },
1884
- );
1893
+ const testEntityAlice = await nymph.getEntity(
1894
+ { class: TestModel },
1895
+ { type: '&', guid: bobsEntity.guid || '' },
1896
+ );
1885
1897
 
1886
- expect(testEntityAlice).not.toBeNull();
1898
+ expect(testEntityAlice).not.toBeNull();
1887
1899
 
1888
- const testWithoutFiltering = await nymph.getEntities(
1889
- { class: TestModel, acRequest: TilmeldAccessRequest.USER_OWNED },
1890
- { type: '|', guid: [alicesEntity.guid || '', bobsEntity.guid || ''] },
1891
- );
1900
+ const testWithoutFiltering = await nymph.getEntities(
1901
+ { class: TestModel, acRequest: TilmeldAccessRequest.USER_OWNED },
1902
+ { type: '|', guid: [alicesEntity.guid || '', bobsEntity.guid || ''] },
1903
+ );
1892
1904
 
1893
- expect(testWithoutFiltering.length).toEqual(1);
1894
- expect(testWithoutFiltering[0].guid).toEqual(alicesEntity?.guid || '');
1905
+ expect(testWithoutFiltering.length).toEqual(1);
1906
+ expect(testWithoutFiltering[0].guid).toEqual(alicesEntity?.guid || '');
1895
1907
 
1896
- const testWithFiltering = await nymph.getEntities(
1897
- {
1898
- class: TestModel,
1899
- acRequest: TilmeldAccessRequest.USER_OWNED,
1900
- },
1901
- { type: '|', guid: [alicesEntity.guid || '', bobsEntity.guid || ''] },
1902
- { type: '!&', ref: ['user', alice] },
1903
- );
1908
+ const testWithFiltering = await nymph.getEntities(
1909
+ {
1910
+ class: TestModel,
1911
+ acRequest: TilmeldAccessRequest.USER_OWNED,
1912
+ },
1913
+ { type: '|', guid: [alicesEntity.guid || '', bobsEntity.guid || ''] },
1914
+ { type: '!&', ref: ['user', alice] },
1915
+ );
1904
1916
 
1905
- expect(testWithFiltering.length).toEqual(0);
1917
+ expect(testWithFiltering.length).toEqual(0);
1906
1918
 
1907
- const testInclusive = await nymph.getEntities({ class: TestModel });
1919
+ const testInclusive = await nymph.getEntities({ class: TestModel });
1908
1920
 
1909
- const testInclusiveWithFiltering = await nymph.getEntities(
1910
- { class: TestModel },
1911
- { type: '!&', ref: ['user', alice] },
1912
- );
1921
+ const testInclusiveWithFiltering = await nymph.getEntities(
1922
+ { class: TestModel },
1923
+ { type: '!&', ref: ['user', alice] },
1924
+ );
1913
1925
 
1914
- expect(testInclusiveWithFiltering.length).toBeGreaterThanOrEqual(1);
1915
- const guids = testInclusiveWithFiltering.map((entity) => entity.guid);
1916
- expect(guids).not.toContain(alicesEntity?.guid || '');
1917
- expect(guids).toContain(bobsEntity?.guid || '');
1926
+ expect(testInclusiveWithFiltering.length).toBeGreaterThanOrEqual(1);
1927
+ const guids = testInclusiveWithFiltering.map((entity) => entity.guid);
1928
+ expect(guids).not.toContain(alicesEntity?.guid || '');
1929
+ expect(guids).toContain(bobsEntity?.guid || '');
1918
1930
 
1919
- const allDefaultGuids = testInclusive.map((entity) => entity.guid);
1920
- for (let guid of guids) {
1921
- expect(allDefaultGuids).toContain(guid);
1922
- }
1923
- });
1931
+ const allDefaultGuids = testInclusive.map((entity) => entity.guid);
1932
+ for (let guid of guids) {
1933
+ expect(allDefaultGuids).toContain(guid);
1934
+ }
1935
+ });
1924
1936
 
1925
- it("access request for invalid access control doesn't return any inaccessible entities", async () => {
1926
- const { bob, alice, abgroup } = await makeUsers();
1937
+ it("access request for invalid access control doesn't return any inaccessible entities", async () => {
1938
+ const { bob, alice, abgroup } = await makeUsers();
1927
1939
 
1928
- await tilmeld.fillSession(bob);
1940
+ await tilmeld.fillSession(bob);
1929
1941
 
1930
- const bobsEntity = await TestModel.factory();
1931
- bobsEntity.name = "Bob's Entity";
1932
- expect(await bobsEntity.$save()).toEqual(true);
1942
+ const bobsEntity = await TestModel.factory();
1943
+ bobsEntity.name = "Bob's Entity";
1944
+ expect(await bobsEntity.$save()).toEqual(true);
1933
1945
 
1934
- expect(bobsEntity.guid).not.toBeNull();
1935
- expect(bob.$is(bobsEntity.user)).toEqual(true);
1946
+ expect(bobsEntity.guid).not.toBeNull();
1947
+ expect(bob.$is(bobsEntity.user)).toEqual(true);
1936
1948
 
1937
- const testEntityBob = await nymph.getEntity(
1938
- { class: TestModel },
1939
- { type: '&', guid: bobsEntity.guid || '' },
1940
- );
1949
+ const testEntityBob = await nymph.getEntity(
1950
+ { class: TestModel },
1951
+ { type: '&', guid: bobsEntity.guid || '' },
1952
+ );
1941
1953
 
1942
- expect(testEntityBob).not.toBeNull();
1943
- expect(testEntityBob?.guid).toEqual(bobsEntity.guid);
1954
+ expect(testEntityBob).not.toBeNull();
1955
+ expect(testEntityBob?.guid).toEqual(bobsEntity.guid);
1944
1956
 
1945
- tilmeld.clearSession();
1946
- await tilmeld.fillSession(alice);
1957
+ tilmeld.clearSession();
1958
+ await tilmeld.fillSession(alice);
1947
1959
 
1948
- const testEntityAlice = await nymph.getEntity(
1949
- { class: TestModel },
1950
- { type: '&', guid: bobsEntity.guid || '' },
1951
- );
1960
+ const testEntityAlice = await nymph.getEntity(
1961
+ { class: TestModel },
1962
+ { type: '&', guid: bobsEntity.guid || '' },
1963
+ );
1952
1964
 
1953
- expect(testEntityAlice).toBeNull();
1965
+ expect(testEntityAlice).toBeNull();
1954
1966
 
1955
- const testFailureEntityAlice = await nymph.getEntity(
1956
- { class: TestModel, acRequest: TilmeldAccessRequest.UNOWNED * 2 },
1957
- { type: '&', guid: bobsEntity.guid || '' },
1958
- );
1967
+ const testFailureEntityAlice = await nymph.getEntity(
1968
+ { class: TestModel, acRequest: TilmeldAccessRequest.UNOWNED * 2 },
1969
+ { type: '&', guid: bobsEntity.guid || '' },
1970
+ );
1959
1971
 
1960
- expect(testFailureEntityAlice).toBeNull();
1961
- });
1972
+ expect(testFailureEntityAlice).toBeNull();
1973
+ });
1962
1974
 
1963
- it('delete test data again', async () => {
1964
- await deleteTestData();
1975
+ it('delete test data again', async () => {
1976
+ await deleteTestData();
1977
+ });
1965
1978
  });
1966
1979
  }