@nymphjs/tilmeld 1.0.0-beta.121 → 1.0.0-beta.122
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/README.md +6 -3
- package/dist/Group.d.ts +5 -6
- package/dist/Group.js +83 -50
- package/dist/Group.js.map +1 -1
- package/dist/Group.testArtifacts.js +3 -3
- package/dist/Group.testArtifacts.js.map +1 -1
- package/dist/User.d.ts +5 -6
- package/dist/User.js +86 -84
- package/dist/User.js.map +1 -1
- package/dist/User.testArtifacts.js +7 -7
- package/dist/User.testArtifacts.js.map +1 -1
- package/dist/decorators/index.d.ts +2 -0
- package/dist/decorators/index.js +3 -0
- package/dist/decorators/index.js.map +1 -0
- package/dist/decorators/requireAbility.d.ts +10 -0
- package/dist/decorators/requireAbility.js +21 -0
- package/dist/decorators/requireAbility.js.map +1 -0
- package/dist/decorators/requireAuthentication.d.ts +8 -0
- package/dist/decorators/requireAuthentication.js +16 -0
- package/dist/decorators/requireAuthentication.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/testArtifacts.d.ts +5 -1
- package/dist/testArtifacts.js +211 -67
- package/dist/testArtifacts.js.map +1 -1
- package/package.json +13 -7
- package/src/Group.testArtifacts.ts +3 -3
- package/src/Group.ts +93 -68
- package/src/User.testArtifacts.ts +7 -7
- package/src/User.ts +97 -95
- package/src/decorators/index.ts +2 -0
- package/src/decorators/requireAbility.ts +26 -0
- package/src/decorators/requireAuthentication.ts +19 -0
- package/src/index.ts +1 -0
- package/src/testArtifacts.ts +165 -46
package/src/testArtifacts.ts
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Entity,
|
|
3
3
|
Nymph,
|
|
4
|
+
HttpError,
|
|
4
5
|
TilmeldAccessLevels,
|
|
5
6
|
TilmeldAccessRequest,
|
|
6
7
|
} from '@nymphjs/nymph';
|
|
7
8
|
|
|
8
9
|
import Tilmeld from './Tilmeld.js';
|
|
10
|
+
import { requireAbility, requireAuthentication } from './decorators/index.js';
|
|
9
11
|
import { AccessControlError } from './errors/index.js';
|
|
10
12
|
import type { AccessControlData } from './Tilmeld.types.js';
|
|
11
13
|
import type UserClass from './User.js';
|
|
@@ -28,6 +30,26 @@ export class TestModel extends Entity<TestModelData> {
|
|
|
28
30
|
*/
|
|
29
31
|
private $skipAcWhenDeleting = false;
|
|
30
32
|
|
|
33
|
+
@requireAuthentication
|
|
34
|
+
public $testRequireAuthenticationDecorator() {
|
|
35
|
+
return true;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
@requireAuthentication
|
|
39
|
+
public async $testRequireAuthenticationDecoratorAsync() {
|
|
40
|
+
return true;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
@requireAbility('test-ability')
|
|
44
|
+
public $testRequireAbilityDecorator() {
|
|
45
|
+
return true;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
@requireAbility('test-ability')
|
|
49
|
+
public async $testRequireAbilityDecoratorAsync() {
|
|
50
|
+
return true;
|
|
51
|
+
}
|
|
52
|
+
|
|
31
53
|
/*
|
|
32
54
|
* This should *never* be accessible on the client.
|
|
33
55
|
*/
|
|
@@ -86,7 +108,7 @@ export function TilmeldTest(
|
|
|
86
108
|
);
|
|
87
109
|
expect(Array.isArray(all)).toEqual(true);
|
|
88
110
|
for (const cur of all) {
|
|
89
|
-
|
|
111
|
+
await cur.$deleteSkipAC();
|
|
90
112
|
}
|
|
91
113
|
|
|
92
114
|
all = await nymph.getEntities({ class: TestModel });
|
|
@@ -95,7 +117,7 @@ export function TilmeldTest(
|
|
|
95
117
|
all = await nymph.getEntities({ class: User });
|
|
96
118
|
expect(Array.isArray(all)).toEqual(true);
|
|
97
119
|
for (const cur of all) {
|
|
98
|
-
|
|
120
|
+
await cur.$deleteSkipAC();
|
|
99
121
|
}
|
|
100
122
|
|
|
101
123
|
all = await nymph.getEntities({ class: User });
|
|
@@ -104,7 +126,7 @@ export function TilmeldTest(
|
|
|
104
126
|
all = await nymph.getEntities({ class: Group });
|
|
105
127
|
expect(Array.isArray(all)).toEqual(true);
|
|
106
128
|
for (const cur of all) {
|
|
107
|
-
|
|
129
|
+
await cur.$deleteSkipAC();
|
|
108
130
|
}
|
|
109
131
|
|
|
110
132
|
all = await nymph.getEntities({ class: Group });
|
|
@@ -219,7 +241,7 @@ export function TilmeldTest(
|
|
|
219
241
|
|
|
220
242
|
const bobsEntity = await TestModel.factory();
|
|
221
243
|
bobsEntity.name = "Bob's Entity";
|
|
222
|
-
|
|
244
|
+
await bobsEntity.$save();
|
|
223
245
|
|
|
224
246
|
expect(bobsEntity.guid).not.toBeNull();
|
|
225
247
|
expect(bob.$is(bobsEntity.user)).toEqual(true);
|
|
@@ -241,6 +263,103 @@ export function TilmeldTest(
|
|
|
241
263
|
expect(testEntityBob?.acFull).toEqual([]);
|
|
242
264
|
});
|
|
243
265
|
|
|
266
|
+
it('require authentication decorator', async () => {
|
|
267
|
+
const { bob } = await makeUsers();
|
|
268
|
+
|
|
269
|
+
await tilmeld.fillSession(bob);
|
|
270
|
+
|
|
271
|
+
const bobsEntity = await TestModel.factory();
|
|
272
|
+
bobsEntity.name = "Bob's Entity";
|
|
273
|
+
await bobsEntity.$save();
|
|
274
|
+
|
|
275
|
+
expect(bobsEntity.$testRequireAuthenticationDecorator()).toEqual(true);
|
|
276
|
+
expect(
|
|
277
|
+
await bobsEntity.$testRequireAuthenticationDecoratorAsync(),
|
|
278
|
+
).toEqual(true);
|
|
279
|
+
|
|
280
|
+
tilmeld.clearSession();
|
|
281
|
+
|
|
282
|
+
try {
|
|
283
|
+
bobsEntity.$testRequireAuthenticationDecorator();
|
|
284
|
+
|
|
285
|
+
throw new Error('Should have thrown.');
|
|
286
|
+
} catch (e: any) {
|
|
287
|
+
expect(e).toBeInstanceOf(HttpError);
|
|
288
|
+
expect(e.status).toEqual(403);
|
|
289
|
+
expect(e.message).toEqual('Forbidden');
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
try {
|
|
293
|
+
await bobsEntity.$testRequireAuthenticationDecoratorAsync();
|
|
294
|
+
|
|
295
|
+
throw new Error('Should have thrown.');
|
|
296
|
+
} catch (e: any) {
|
|
297
|
+
expect(e).toBeInstanceOf(HttpError);
|
|
298
|
+
expect(e.status).toEqual(403);
|
|
299
|
+
expect(e.message).toEqual('Forbidden');
|
|
300
|
+
}
|
|
301
|
+
});
|
|
302
|
+
|
|
303
|
+
it('require ability decorator', async () => {
|
|
304
|
+
const { bob } = await makeUsers();
|
|
305
|
+
|
|
306
|
+
await tilmeld.fillSession(bob);
|
|
307
|
+
|
|
308
|
+
const bobsEntity = await TestModel.factory();
|
|
309
|
+
bobsEntity.name = "Bob's Entity";
|
|
310
|
+
await bobsEntity.$save();
|
|
311
|
+
|
|
312
|
+
try {
|
|
313
|
+
bobsEntity.$testRequireAbilityDecorator();
|
|
314
|
+
|
|
315
|
+
throw new Error('Should have thrown.');
|
|
316
|
+
} catch (e: any) {
|
|
317
|
+
expect(e).toBeInstanceOf(HttpError);
|
|
318
|
+
expect(e.status).toEqual(403);
|
|
319
|
+
expect(e.message).toEqual('Forbidden');
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
try {
|
|
323
|
+
await bobsEntity.$testRequireAbilityDecoratorAsync();
|
|
324
|
+
|
|
325
|
+
throw new Error('Should have thrown.');
|
|
326
|
+
} catch (e: any) {
|
|
327
|
+
expect(e).toBeInstanceOf(HttpError);
|
|
328
|
+
expect(e.status).toEqual(403);
|
|
329
|
+
expect(e.message).toEqual('Forbidden');
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
tilmeld.clearSession();
|
|
333
|
+
|
|
334
|
+
try {
|
|
335
|
+
bobsEntity.$testRequireAbilityDecorator();
|
|
336
|
+
|
|
337
|
+
throw new Error('Should have thrown.');
|
|
338
|
+
} catch (e: any) {
|
|
339
|
+
expect(e).toBeInstanceOf(HttpError);
|
|
340
|
+
expect(e.status).toEqual(403);
|
|
341
|
+
expect(e.message).toEqual('Forbidden');
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
try {
|
|
345
|
+
await bobsEntity.$testRequireAbilityDecoratorAsync();
|
|
346
|
+
|
|
347
|
+
throw new Error('Should have thrown.');
|
|
348
|
+
} catch (e: any) {
|
|
349
|
+
expect(e).toBeInstanceOf(HttpError);
|
|
350
|
+
expect(e.status).toEqual(403);
|
|
351
|
+
expect(e.message).toEqual('Forbidden');
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
bob.$grant('test-ability');
|
|
355
|
+
await tilmeld.fillSession(bob);
|
|
356
|
+
|
|
357
|
+
expect(bobsEntity.$testRequireAbilityDecorator()).toEqual(true);
|
|
358
|
+
expect(await bobsEntity.$testRequireAbilityDecoratorAsync()).toEqual(
|
|
359
|
+
true,
|
|
360
|
+
);
|
|
361
|
+
});
|
|
362
|
+
|
|
244
363
|
it("alice can't access an entity owned by bob", async () => {
|
|
245
364
|
const { bob, alice } = await makeUsers();
|
|
246
365
|
|
|
@@ -248,7 +367,7 @@ export function TilmeldTest(
|
|
|
248
367
|
|
|
249
368
|
const bobsEntity = await TestModel.factory();
|
|
250
369
|
bobsEntity.name = "Bob's Entity";
|
|
251
|
-
|
|
370
|
+
await bobsEntity.$save();
|
|
252
371
|
|
|
253
372
|
expect(bobsEntity.guid).not.toBeNull();
|
|
254
373
|
expect(bob.$is(bobsEntity.user)).toEqual(true);
|
|
@@ -280,7 +399,7 @@ export function TilmeldTest(
|
|
|
280
399
|
const bobsEntity = await TestModel.factory();
|
|
281
400
|
bobsEntity.name = "Bob's Entity";
|
|
282
401
|
bobsEntity.acRead = [alice.guid ?? ''];
|
|
283
|
-
|
|
402
|
+
await bobsEntity.$save();
|
|
284
403
|
|
|
285
404
|
expect(bobsEntity.guid).not.toBeNull();
|
|
286
405
|
expect(bob.$is(bobsEntity.user)).toEqual(true);
|
|
@@ -328,7 +447,7 @@ export function TilmeldTest(
|
|
|
328
447
|
const bobsEntity = await TestModel.factory();
|
|
329
448
|
bobsEntity.name = "Bob's Entity";
|
|
330
449
|
bobsEntity.acWrite = [alice.guid ?? ''];
|
|
331
|
-
|
|
450
|
+
await bobsEntity.$save();
|
|
332
451
|
|
|
333
452
|
expect(bobsEntity.guid).not.toBeNull();
|
|
334
453
|
expect(bob.$is(bobsEntity.user)).toEqual(true);
|
|
@@ -357,7 +476,7 @@ export function TilmeldTest(
|
|
|
357
476
|
}
|
|
358
477
|
|
|
359
478
|
testEntityAlice.name = "Haha! It's mine now!";
|
|
360
|
-
|
|
479
|
+
await testEntityAlice.$save();
|
|
361
480
|
|
|
362
481
|
expect(await testEntityAlice.$refresh()).toEqual(true);
|
|
363
482
|
expect(testEntityAlice.name).toEqual("Haha! It's mine now!");
|
|
@@ -371,7 +490,7 @@ export function TilmeldTest(
|
|
|
371
490
|
const bobsEntity = await TestModel.factory();
|
|
372
491
|
bobsEntity.name = "Bob's Entity";
|
|
373
492
|
bobsEntity.acWrite = [alice.guid ?? ''];
|
|
374
|
-
|
|
493
|
+
await bobsEntity.$save();
|
|
375
494
|
|
|
376
495
|
expect(bobsEntity.guid).not.toBeNull();
|
|
377
496
|
expect(bob.$is(bobsEntity.user)).toEqual(true);
|
|
@@ -418,7 +537,7 @@ export function TilmeldTest(
|
|
|
418
537
|
const bobsEntity = await TestModel.factory();
|
|
419
538
|
bobsEntity.name = "Bob's Entity";
|
|
420
539
|
bobsEntity.acFull = [alice.guid ?? ''];
|
|
421
|
-
|
|
540
|
+
await bobsEntity.$save();
|
|
422
541
|
|
|
423
542
|
expect(bobsEntity.guid).not.toBeNull();
|
|
424
543
|
expect(bob.$is(bobsEntity.user)).toEqual(true);
|
|
@@ -446,7 +565,7 @@ export function TilmeldTest(
|
|
|
446
565
|
throw new Error();
|
|
447
566
|
}
|
|
448
567
|
|
|
449
|
-
|
|
568
|
+
await testEntityAlice.$delete();
|
|
450
569
|
const verifyEntityAlice = await nymph.getEntity(
|
|
451
570
|
{ class: TestModel },
|
|
452
571
|
{ type: '&', guid: bobsEntity.guid || '' },
|
|
@@ -462,7 +581,7 @@ export function TilmeldTest(
|
|
|
462
581
|
const bobsEntity = await TestModel.factory();
|
|
463
582
|
bobsEntity.name = "Bob's Entity";
|
|
464
583
|
bobsEntity.acRead = [abgroup.guid ?? ''];
|
|
465
|
-
|
|
584
|
+
await bobsEntity.$save();
|
|
466
585
|
|
|
467
586
|
expect(bobsEntity.guid).not.toBeNull();
|
|
468
587
|
expect(bob.$is(bobsEntity.user)).toEqual(true);
|
|
@@ -495,7 +614,7 @@ export function TilmeldTest(
|
|
|
495
614
|
const bobsEntity = await TestModel.factory();
|
|
496
615
|
bobsEntity.name = "Bob's Entity";
|
|
497
616
|
bobsEntity.acRead = [abgroup.guid ?? ''];
|
|
498
|
-
|
|
617
|
+
await bobsEntity.$save();
|
|
499
618
|
|
|
500
619
|
expect(bobsEntity.guid).not.toBeNull();
|
|
501
620
|
expect(bob.$is(bobsEntity.user)).toEqual(true);
|
|
@@ -543,7 +662,7 @@ export function TilmeldTest(
|
|
|
543
662
|
const bobsEntity = await TestModel.factory();
|
|
544
663
|
bobsEntity.name = "Bob's Entity";
|
|
545
664
|
bobsEntity.acWrite = [abgroup.guid ?? ''];
|
|
546
|
-
|
|
665
|
+
await bobsEntity.$save();
|
|
547
666
|
|
|
548
667
|
expect(bobsEntity.guid).not.toBeNull();
|
|
549
668
|
expect(bob.$is(bobsEntity.user)).toEqual(true);
|
|
@@ -572,7 +691,7 @@ export function TilmeldTest(
|
|
|
572
691
|
}
|
|
573
692
|
|
|
574
693
|
testEntityAlice.name = "Haha! It's mine now!";
|
|
575
|
-
|
|
694
|
+
await testEntityAlice.$save();
|
|
576
695
|
|
|
577
696
|
expect(await testEntityAlice.$refresh()).toEqual(true);
|
|
578
697
|
expect(testEntityAlice.name).toEqual("Haha! It's mine now!");
|
|
@@ -586,7 +705,7 @@ export function TilmeldTest(
|
|
|
586
705
|
const bobsEntity = await TestModel.factory();
|
|
587
706
|
bobsEntity.name = "Bob's Entity";
|
|
588
707
|
bobsEntity.acWrite = [abgroup.guid ?? ''];
|
|
589
|
-
|
|
708
|
+
await bobsEntity.$save();
|
|
590
709
|
|
|
591
710
|
expect(bobsEntity.guid).not.toBeNull();
|
|
592
711
|
expect(bob.$is(bobsEntity.user)).toEqual(true);
|
|
@@ -633,7 +752,7 @@ export function TilmeldTest(
|
|
|
633
752
|
const bobsEntity = await TestModel.factory();
|
|
634
753
|
bobsEntity.name = "Bob's Entity";
|
|
635
754
|
bobsEntity.acFull = [abgroup.guid ?? ''];
|
|
636
|
-
|
|
755
|
+
await bobsEntity.$save();
|
|
637
756
|
|
|
638
757
|
expect(bobsEntity.guid).not.toBeNull();
|
|
639
758
|
expect(bob.$is(bobsEntity.user)).toEqual(true);
|
|
@@ -661,7 +780,7 @@ export function TilmeldTest(
|
|
|
661
780
|
throw new Error();
|
|
662
781
|
}
|
|
663
782
|
|
|
664
|
-
|
|
783
|
+
await testEntityAlice.$delete();
|
|
665
784
|
const verifyEntityAlice = await nymph.getEntity(
|
|
666
785
|
{ class: TestModel },
|
|
667
786
|
{ type: '&', guid: bobsEntity.guid || '' },
|
|
@@ -677,7 +796,7 @@ export function TilmeldTest(
|
|
|
677
796
|
const bobsEntity = await TestModel.factory();
|
|
678
797
|
bobsEntity.name = "Bob's Entity";
|
|
679
798
|
bobsEntity.group = alice.group;
|
|
680
|
-
|
|
799
|
+
await bobsEntity.$save();
|
|
681
800
|
|
|
682
801
|
expect(bobsEntity.guid).not.toBeNull();
|
|
683
802
|
expect(bob.$is(bobsEntity.user)).toEqual(true);
|
|
@@ -710,7 +829,7 @@ export function TilmeldTest(
|
|
|
710
829
|
const bobsEntity = await TestModel.factory();
|
|
711
830
|
bobsEntity.name = "Bob's Entity";
|
|
712
831
|
bobsEntity.group = alice.group;
|
|
713
|
-
|
|
832
|
+
await bobsEntity.$save();
|
|
714
833
|
|
|
715
834
|
expect(bobsEntity.guid).not.toBeNull();
|
|
716
835
|
expect(bob.$is(bobsEntity.user)).toEqual(true);
|
|
@@ -759,7 +878,7 @@ export function TilmeldTest(
|
|
|
759
878
|
bobsEntity.name = "Bob's Entity";
|
|
760
879
|
bobsEntity.group = alice.group;
|
|
761
880
|
bobsEntity.acGroup = TilmeldAccessLevels.WRITE_ACCESS;
|
|
762
|
-
|
|
881
|
+
await bobsEntity.$save();
|
|
763
882
|
|
|
764
883
|
expect(bobsEntity.guid).not.toBeNull();
|
|
765
884
|
expect(bob.$is(bobsEntity.user)).toEqual(true);
|
|
@@ -788,7 +907,7 @@ export function TilmeldTest(
|
|
|
788
907
|
}
|
|
789
908
|
|
|
790
909
|
testEntityAlice.name = "Haha! It's mine now!";
|
|
791
|
-
|
|
910
|
+
await testEntityAlice.$save();
|
|
792
911
|
|
|
793
912
|
expect(await testEntityAlice.$refresh()).toEqual(true);
|
|
794
913
|
expect(testEntityAlice.name).toEqual("Haha! It's mine now!");
|
|
@@ -803,7 +922,7 @@ export function TilmeldTest(
|
|
|
803
922
|
bobsEntity.name = "Bob's Entity";
|
|
804
923
|
bobsEntity.group = alice.group;
|
|
805
924
|
bobsEntity.acGroup = TilmeldAccessLevels.WRITE_ACCESS;
|
|
806
|
-
|
|
925
|
+
await bobsEntity.$save();
|
|
807
926
|
|
|
808
927
|
expect(bobsEntity.guid).not.toBeNull();
|
|
809
928
|
expect(bob.$is(bobsEntity.user)).toEqual(true);
|
|
@@ -851,7 +970,7 @@ export function TilmeldTest(
|
|
|
851
970
|
bobsEntity.name = "Bob's Entity";
|
|
852
971
|
bobsEntity.group = alice.group;
|
|
853
972
|
bobsEntity.acGroup = TilmeldAccessLevels.FULL_ACCESS;
|
|
854
|
-
|
|
973
|
+
await bobsEntity.$save();
|
|
855
974
|
|
|
856
975
|
expect(bobsEntity.guid).not.toBeNull();
|
|
857
976
|
expect(bob.$is(bobsEntity.user)).toEqual(true);
|
|
@@ -879,7 +998,7 @@ export function TilmeldTest(
|
|
|
879
998
|
throw new Error();
|
|
880
999
|
}
|
|
881
1000
|
|
|
882
|
-
|
|
1001
|
+
await testEntityAlice.$delete();
|
|
883
1002
|
const verifyEntityAlice = await nymph.getEntity(
|
|
884
1003
|
{ class: TestModel },
|
|
885
1004
|
{ type: '&', guid: bobsEntity.guid || '' },
|
|
@@ -895,7 +1014,7 @@ export function TilmeldTest(
|
|
|
895
1014
|
const bobsEntity = await TestModel.factory();
|
|
896
1015
|
bobsEntity.name = "Bob's Entity";
|
|
897
1016
|
bobsEntity.acOther = TilmeldAccessLevels.READ_ACCESS;
|
|
898
|
-
|
|
1017
|
+
await bobsEntity.$save();
|
|
899
1018
|
|
|
900
1019
|
expect(bobsEntity.guid).not.toBeNull();
|
|
901
1020
|
expect(bob.$is(bobsEntity.user)).toEqual(true);
|
|
@@ -928,7 +1047,7 @@ export function TilmeldTest(
|
|
|
928
1047
|
const bobsEntity = await TestModel.factory();
|
|
929
1048
|
bobsEntity.name = "Bob's Entity";
|
|
930
1049
|
bobsEntity.acOther = TilmeldAccessLevels.READ_ACCESS;
|
|
931
|
-
|
|
1050
|
+
await bobsEntity.$save();
|
|
932
1051
|
|
|
933
1052
|
expect(bobsEntity.guid).not.toBeNull();
|
|
934
1053
|
expect(bob.$is(bobsEntity.user)).toEqual(true);
|
|
@@ -976,7 +1095,7 @@ export function TilmeldTest(
|
|
|
976
1095
|
const bobsEntity = await TestModel.factory();
|
|
977
1096
|
bobsEntity.name = "Bob's Entity";
|
|
978
1097
|
bobsEntity.acOther = TilmeldAccessLevels.WRITE_ACCESS;
|
|
979
|
-
|
|
1098
|
+
await bobsEntity.$save();
|
|
980
1099
|
|
|
981
1100
|
expect(bobsEntity.guid).not.toBeNull();
|
|
982
1101
|
expect(bob.$is(bobsEntity.user)).toEqual(true);
|
|
@@ -1005,7 +1124,7 @@ export function TilmeldTest(
|
|
|
1005
1124
|
}
|
|
1006
1125
|
|
|
1007
1126
|
testEntityAlice.name = "Haha! It's mine now!";
|
|
1008
|
-
|
|
1127
|
+
await testEntityAlice.$save();
|
|
1009
1128
|
|
|
1010
1129
|
expect(await testEntityAlice.$refresh()).toEqual(true);
|
|
1011
1130
|
expect(testEntityAlice.name).toEqual("Haha! It's mine now!");
|
|
@@ -1019,7 +1138,7 @@ export function TilmeldTest(
|
|
|
1019
1138
|
const bobsEntity = await TestModel.factory();
|
|
1020
1139
|
bobsEntity.name = "Bob's Entity";
|
|
1021
1140
|
bobsEntity.acOther = TilmeldAccessLevels.WRITE_ACCESS;
|
|
1022
|
-
|
|
1141
|
+
await bobsEntity.$save();
|
|
1023
1142
|
|
|
1024
1143
|
expect(bobsEntity.guid).not.toBeNull();
|
|
1025
1144
|
expect(bob.$is(bobsEntity.user)).toEqual(true);
|
|
@@ -1066,7 +1185,7 @@ export function TilmeldTest(
|
|
|
1066
1185
|
const bobsEntity = await TestModel.factory();
|
|
1067
1186
|
bobsEntity.name = "Bob's Entity";
|
|
1068
1187
|
bobsEntity.acOther = TilmeldAccessLevels.FULL_ACCESS;
|
|
1069
|
-
|
|
1188
|
+
await bobsEntity.$save();
|
|
1070
1189
|
|
|
1071
1190
|
expect(bobsEntity.guid).not.toBeNull();
|
|
1072
1191
|
expect(bob.$is(bobsEntity.user)).toEqual(true);
|
|
@@ -1094,7 +1213,7 @@ export function TilmeldTest(
|
|
|
1094
1213
|
throw new Error();
|
|
1095
1214
|
}
|
|
1096
1215
|
|
|
1097
|
-
|
|
1216
|
+
await testEntityAlice.$delete();
|
|
1098
1217
|
const verifyEntityAlice = await nymph.getEntity(
|
|
1099
1218
|
{ class: TestModel },
|
|
1100
1219
|
{ type: '&', guid: bobsEntity.guid || '' },
|
|
@@ -1110,7 +1229,7 @@ export function TilmeldTest(
|
|
|
1110
1229
|
const bobsEntity = await TestModel.factory();
|
|
1111
1230
|
bobsEntity.name = "Bob's Entity";
|
|
1112
1231
|
bobsEntity.acOther = TilmeldAccessLevels.FULL_ACCESS;
|
|
1113
|
-
|
|
1232
|
+
await bobsEntity.$save();
|
|
1114
1233
|
|
|
1115
1234
|
expect(bobsEntity.guid).not.toBeNull();
|
|
1116
1235
|
expect(bob.$is(bobsEntity.user)).toEqual(true);
|
|
@@ -1137,7 +1256,7 @@ export function TilmeldTest(
|
|
|
1137
1256
|
throw new Error();
|
|
1138
1257
|
}
|
|
1139
1258
|
|
|
1140
|
-
|
|
1259
|
+
await testEntityNobody.$delete();
|
|
1141
1260
|
const verifyEntityNobody = await nymph.getEntity(
|
|
1142
1261
|
{ class: TestModel },
|
|
1143
1262
|
{ type: '&', guid: bobsEntity.guid || '' },
|
|
@@ -1152,7 +1271,7 @@ export function TilmeldTest(
|
|
|
1152
1271
|
...(await nymph.getEntities({ class: Group, skipAc: true })),
|
|
1153
1272
|
];
|
|
1154
1273
|
for (let entity of allEntities) {
|
|
1155
|
-
|
|
1274
|
+
await entity.$deleteSkipAC();
|
|
1156
1275
|
}
|
|
1157
1276
|
});
|
|
1158
1277
|
|
|
@@ -1170,7 +1289,7 @@ export function TilmeldTest(
|
|
|
1170
1289
|
];
|
|
1171
1290
|
bobsEntity.acWrite = [alice.guid ?? '', bob.guid ?? ''];
|
|
1172
1291
|
bobsEntity.acFull = [bob.guid ?? ''];
|
|
1173
|
-
|
|
1292
|
+
await bobsEntity.$save();
|
|
1174
1293
|
|
|
1175
1294
|
expect(bobsEntity.guid).not.toBeNull();
|
|
1176
1295
|
expect(bob.$is(bobsEntity.user)).toEqual(true);
|
|
@@ -1542,7 +1661,7 @@ export function TilmeldTest(
|
|
|
1542
1661
|
|
|
1543
1662
|
const alicesEntity = await TestModel.factory();
|
|
1544
1663
|
alicesEntity.name = "Alice's Entity";
|
|
1545
|
-
|
|
1664
|
+
await alicesEntity.$save();
|
|
1546
1665
|
|
|
1547
1666
|
expect(alicesEntity.guid).not.toBeNull();
|
|
1548
1667
|
expect(alice.$is(alicesEntity.user)).toEqual(true);
|
|
@@ -1566,7 +1685,7 @@ export function TilmeldTest(
|
|
|
1566
1685
|
const bobsEntity = await TestModel.factory();
|
|
1567
1686
|
bobsEntity.name = "Bob's Entity";
|
|
1568
1687
|
bobsEntity.group = alice.group;
|
|
1569
|
-
|
|
1688
|
+
await bobsEntity.$save();
|
|
1570
1689
|
|
|
1571
1690
|
expect(bobsEntity.guid).not.toBeNull();
|
|
1572
1691
|
expect(bob.$is(bobsEntity.user)).toEqual(true);
|
|
@@ -1615,7 +1734,7 @@ export function TilmeldTest(
|
|
|
1615
1734
|
const bobsEntity = await TestModel.factory();
|
|
1616
1735
|
bobsEntity.name = "Bob's Entity";
|
|
1617
1736
|
bobsEntity.acOther = TilmeldAccessLevels.READ_ACCESS;
|
|
1618
|
-
|
|
1737
|
+
await bobsEntity.$save();
|
|
1619
1738
|
|
|
1620
1739
|
expect(bobsEntity.guid).not.toBeNull();
|
|
1621
1740
|
expect(bob.$is(bobsEntity.user)).toEqual(true);
|
|
@@ -1661,7 +1780,7 @@ export function TilmeldTest(
|
|
|
1661
1780
|
const bobsEntity = await TestModel.factory();
|
|
1662
1781
|
bobsEntity.name = "Bob's Entity";
|
|
1663
1782
|
bobsEntity.acRead = [alice.guid ?? ''];
|
|
1664
|
-
|
|
1783
|
+
await bobsEntity.$save();
|
|
1665
1784
|
|
|
1666
1785
|
expect(bobsEntity.guid).not.toBeNull();
|
|
1667
1786
|
expect(bob.$is(bobsEntity.user)).toEqual(true);
|
|
@@ -1707,7 +1826,7 @@ export function TilmeldTest(
|
|
|
1707
1826
|
const bobsEntity = await TestModel.factory();
|
|
1708
1827
|
bobsEntity.name = "Bob's Entity";
|
|
1709
1828
|
bobsEntity.acWrite = [alice.group?.guid ?? ''];
|
|
1710
|
-
|
|
1829
|
+
await bobsEntity.$save();
|
|
1711
1830
|
|
|
1712
1831
|
expect(bobsEntity.guid).not.toBeNull();
|
|
1713
1832
|
expect(bob.$is(bobsEntity.user)).toEqual(true);
|
|
@@ -1756,7 +1875,7 @@ export function TilmeldTest(
|
|
|
1756
1875
|
const bobsEntity = await TestModel.factory();
|
|
1757
1876
|
bobsEntity.name = "Bob's Entity";
|
|
1758
1877
|
bobsEntity.group = abgroup;
|
|
1759
|
-
|
|
1878
|
+
await bobsEntity.$save();
|
|
1760
1879
|
|
|
1761
1880
|
expect(bobsEntity.guid).not.toBeNull();
|
|
1762
1881
|
expect(bob.$is(bobsEntity.user)).toEqual(true);
|
|
@@ -1805,7 +1924,7 @@ export function TilmeldTest(
|
|
|
1805
1924
|
const bobsEntity = await TestModel.factory();
|
|
1806
1925
|
bobsEntity.name = "Bob's Entity";
|
|
1807
1926
|
bobsEntity.acFull = [abgroup.guid ?? ''];
|
|
1808
|
-
|
|
1927
|
+
await bobsEntity.$save();
|
|
1809
1928
|
|
|
1810
1929
|
expect(bobsEntity.guid).not.toBeNull();
|
|
1811
1930
|
expect(bob.$is(bobsEntity.user)).toEqual(true);
|
|
@@ -1867,7 +1986,7 @@ export function TilmeldTest(
|
|
|
1867
1986
|
const bobsEntity = await TestModel.factory();
|
|
1868
1987
|
bobsEntity.name = "Bob's Entity";
|
|
1869
1988
|
bobsEntity.acFull = [alice.guid ?? ''];
|
|
1870
|
-
|
|
1989
|
+
await bobsEntity.$save();
|
|
1871
1990
|
|
|
1872
1991
|
expect(bobsEntity.guid).not.toBeNull();
|
|
1873
1992
|
expect(bob.$is(bobsEntity.user)).toEqual(true);
|
|
@@ -1885,7 +2004,7 @@ export function TilmeldTest(
|
|
|
1885
2004
|
|
|
1886
2005
|
const alicesEntity = await TestModel.factory();
|
|
1887
2006
|
alicesEntity.name = "Alice's Entity";
|
|
1888
|
-
|
|
2007
|
+
await alicesEntity.$save();
|
|
1889
2008
|
|
|
1890
2009
|
expect(alicesEntity.guid).not.toBeNull();
|
|
1891
2010
|
expect(alice.$is(alicesEntity.user)).toEqual(true);
|
|
@@ -1941,7 +2060,7 @@ export function TilmeldTest(
|
|
|
1941
2060
|
|
|
1942
2061
|
const bobsEntity = await TestModel.factory();
|
|
1943
2062
|
bobsEntity.name = "Bob's Entity";
|
|
1944
|
-
|
|
2063
|
+
await bobsEntity.$save();
|
|
1945
2064
|
|
|
1946
2065
|
expect(bobsEntity.guid).not.toBeNull();
|
|
1947
2066
|
expect(bob.$is(bobsEntity.user)).toEqual(true);
|