@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/dist/testArtifacts.js
CHANGED
|
@@ -1,33 +1,101 @@
|
|
|
1
|
-
|
|
1
|
+
var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
|
|
2
|
+
var useValue = arguments.length > 2;
|
|
3
|
+
for (var i = 0; i < initializers.length; i++) {
|
|
4
|
+
value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
|
|
5
|
+
}
|
|
6
|
+
return useValue ? value : void 0;
|
|
7
|
+
};
|
|
8
|
+
var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
|
|
9
|
+
function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
|
|
10
|
+
var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
|
|
11
|
+
var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
|
|
12
|
+
var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
|
|
13
|
+
var _, done = false;
|
|
14
|
+
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
15
|
+
var context = {};
|
|
16
|
+
for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
|
|
17
|
+
for (var p in contextIn.access) context.access[p] = contextIn.access[p];
|
|
18
|
+
context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
|
|
19
|
+
var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
|
|
20
|
+
if (kind === "accessor") {
|
|
21
|
+
if (result === void 0) continue;
|
|
22
|
+
if (result === null || typeof result !== "object") throw new TypeError("Object expected");
|
|
23
|
+
if (_ = accept(result.get)) descriptor.get = _;
|
|
24
|
+
if (_ = accept(result.set)) descriptor.set = _;
|
|
25
|
+
if (_ = accept(result.init)) initializers.unshift(_);
|
|
26
|
+
}
|
|
27
|
+
else if (_ = accept(result)) {
|
|
28
|
+
if (kind === "field") initializers.unshift(_);
|
|
29
|
+
else descriptor[key] = _;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
if (target) Object.defineProperty(target, contextIn.name, descriptor);
|
|
33
|
+
done = true;
|
|
34
|
+
};
|
|
35
|
+
import { Entity, Nymph, HttpError, TilmeldAccessLevels, TilmeldAccessRequest, } from '@nymphjs/nymph';
|
|
2
36
|
import Tilmeld from './Tilmeld.js';
|
|
37
|
+
import { requireAbility, requireAuthentication } from './decorators/index.js';
|
|
3
38
|
import { AccessControlError } from './errors/index.js';
|
|
4
39
|
import { UserTest } from './User.testArtifacts.js';
|
|
5
40
|
import { GroupTest } from './Group.testArtifacts.js';
|
|
6
41
|
/**
|
|
7
42
|
* This class is a test class that extends the Entity class.
|
|
8
43
|
*/
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
$
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
this.$
|
|
44
|
+
let TestModel = (() => {
|
|
45
|
+
let _classSuper = Entity;
|
|
46
|
+
let _instanceExtraInitializers = [];
|
|
47
|
+
let _$testRequireAuthenticationDecorator_decorators;
|
|
48
|
+
let _$testRequireAuthenticationDecoratorAsync_decorators;
|
|
49
|
+
let _$testRequireAbilityDecorator_decorators;
|
|
50
|
+
let _$testRequireAbilityDecoratorAsync_decorators;
|
|
51
|
+
return class TestModel extends _classSuper {
|
|
52
|
+
static {
|
|
53
|
+
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
|
|
54
|
+
_$testRequireAuthenticationDecorator_decorators = [requireAuthentication];
|
|
55
|
+
_$testRequireAuthenticationDecoratorAsync_decorators = [requireAuthentication];
|
|
56
|
+
_$testRequireAbilityDecorator_decorators = [requireAbility('test-ability')];
|
|
57
|
+
_$testRequireAbilityDecoratorAsync_decorators = [requireAbility('test-ability')];
|
|
58
|
+
__esDecorate(this, null, _$testRequireAuthenticationDecorator_decorators, { kind: "method", name: "$testRequireAuthenticationDecorator", static: false, private: false, access: { has: obj => "$testRequireAuthenticationDecorator" in obj, get: obj => obj.$testRequireAuthenticationDecorator }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
59
|
+
__esDecorate(this, null, _$testRequireAuthenticationDecoratorAsync_decorators, { kind: "method", name: "$testRequireAuthenticationDecoratorAsync", static: false, private: false, access: { has: obj => "$testRequireAuthenticationDecoratorAsync" in obj, get: obj => obj.$testRequireAuthenticationDecoratorAsync }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
60
|
+
__esDecorate(this, null, _$testRequireAbilityDecorator_decorators, { kind: "method", name: "$testRequireAbilityDecorator", static: false, private: false, access: { has: obj => "$testRequireAbilityDecorator" in obj, get: obj => obj.$testRequireAbilityDecorator }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
61
|
+
__esDecorate(this, null, _$testRequireAbilityDecoratorAsync_decorators, { kind: "method", name: "$testRequireAbilityDecoratorAsync", static: false, private: false, access: { has: obj => "$testRequireAbilityDecoratorAsync" in obj, get: obj => obj.$testRequireAbilityDecoratorAsync }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
62
|
+
if (_metadata) Object.defineProperty(this, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
63
|
+
}
|
|
64
|
+
static ETYPE = 'tilmeld_test_model';
|
|
65
|
+
static class = 'TestModel';
|
|
66
|
+
/**
|
|
67
|
+
* This should only be used by the backend.
|
|
68
|
+
*/
|
|
69
|
+
$skipAcWhenDeleting = (__runInitializers(this, _instanceExtraInitializers), false);
|
|
70
|
+
$testRequireAuthenticationDecorator() {
|
|
26
71
|
return true;
|
|
27
72
|
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
}
|
|
73
|
+
async $testRequireAuthenticationDecoratorAsync() {
|
|
74
|
+
return true;
|
|
75
|
+
}
|
|
76
|
+
$testRequireAbilityDecorator() {
|
|
77
|
+
return true;
|
|
78
|
+
}
|
|
79
|
+
async $testRequireAbilityDecoratorAsync() {
|
|
80
|
+
return true;
|
|
81
|
+
}
|
|
82
|
+
/*
|
|
83
|
+
* This should *never* be accessible on the client.
|
|
84
|
+
*/
|
|
85
|
+
async $deleteSkipAC() {
|
|
86
|
+
this.$skipAcWhenDeleting = true;
|
|
87
|
+
return await this.$delete();
|
|
88
|
+
}
|
|
89
|
+
$tilmeldDeleteSkipAC() {
|
|
90
|
+
if (this.$skipAcWhenDeleting) {
|
|
91
|
+
this.$skipAcWhenDeleting = false;
|
|
92
|
+
return true;
|
|
93
|
+
}
|
|
94
|
+
return false;
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
})();
|
|
98
|
+
export { TestModel };
|
|
31
99
|
const TestModelClass = TestModel;
|
|
32
100
|
export function TilmeldTest(nymphBase, describe, it) {
|
|
33
101
|
const tilmeld = new Tilmeld({
|
|
@@ -59,21 +127,21 @@ export function TilmeldTest(nymphBase, describe, it) {
|
|
|
59
127
|
});
|
|
60
128
|
expect(Array.isArray(all)).toEqual(true);
|
|
61
129
|
for (const cur of all) {
|
|
62
|
-
|
|
130
|
+
await cur.$deleteSkipAC();
|
|
63
131
|
}
|
|
64
132
|
all = await nymph.getEntities({ class: TestModel });
|
|
65
133
|
expect(all.length).toEqual(0);
|
|
66
134
|
all = await nymph.getEntities({ class: User });
|
|
67
135
|
expect(Array.isArray(all)).toEqual(true);
|
|
68
136
|
for (const cur of all) {
|
|
69
|
-
|
|
137
|
+
await cur.$deleteSkipAC();
|
|
70
138
|
}
|
|
71
139
|
all = await nymph.getEntities({ class: User });
|
|
72
140
|
expect(all.length).toEqual(0);
|
|
73
141
|
all = await nymph.getEntities({ class: Group });
|
|
74
142
|
expect(Array.isArray(all)).toEqual(true);
|
|
75
143
|
for (const cur of all) {
|
|
76
|
-
|
|
144
|
+
await cur.$deleteSkipAC();
|
|
77
145
|
}
|
|
78
146
|
all = await nymph.getEntities({ class: Group });
|
|
79
147
|
expect(all.length).toEqual(0);
|
|
@@ -163,7 +231,7 @@ export function TilmeldTest(nymphBase, describe, it) {
|
|
|
163
231
|
await tilmeld.fillSession(bob);
|
|
164
232
|
const bobsEntity = await TestModel.factory();
|
|
165
233
|
bobsEntity.name = "Bob's Entity";
|
|
166
|
-
|
|
234
|
+
await bobsEntity.$save();
|
|
167
235
|
expect(bobsEntity.guid).not.toBeNull();
|
|
168
236
|
expect(bob.$is(bobsEntity.user)).toEqual(true);
|
|
169
237
|
const testEntityBob = await nymph.getEntity({ class: TestModel }, { type: '&', guid: bobsEntity.guid || '' });
|
|
@@ -178,12 +246,88 @@ export function TilmeldTest(nymphBase, describe, it) {
|
|
|
178
246
|
expect(testEntityBob?.acWrite).toEqual([]);
|
|
179
247
|
expect(testEntityBob?.acFull).toEqual([]);
|
|
180
248
|
});
|
|
249
|
+
it('require authentication decorator', async () => {
|
|
250
|
+
const { bob } = await makeUsers();
|
|
251
|
+
await tilmeld.fillSession(bob);
|
|
252
|
+
const bobsEntity = await TestModel.factory();
|
|
253
|
+
bobsEntity.name = "Bob's Entity";
|
|
254
|
+
await bobsEntity.$save();
|
|
255
|
+
expect(bobsEntity.$testRequireAuthenticationDecorator()).toEqual(true);
|
|
256
|
+
expect(await bobsEntity.$testRequireAuthenticationDecoratorAsync()).toEqual(true);
|
|
257
|
+
tilmeld.clearSession();
|
|
258
|
+
try {
|
|
259
|
+
bobsEntity.$testRequireAuthenticationDecorator();
|
|
260
|
+
throw new Error('Should have thrown.');
|
|
261
|
+
}
|
|
262
|
+
catch (e) {
|
|
263
|
+
expect(e).toBeInstanceOf(HttpError);
|
|
264
|
+
expect(e.status).toEqual(403);
|
|
265
|
+
expect(e.message).toEqual('Forbidden');
|
|
266
|
+
}
|
|
267
|
+
try {
|
|
268
|
+
await bobsEntity.$testRequireAuthenticationDecoratorAsync();
|
|
269
|
+
throw new Error('Should have thrown.');
|
|
270
|
+
}
|
|
271
|
+
catch (e) {
|
|
272
|
+
expect(e).toBeInstanceOf(HttpError);
|
|
273
|
+
expect(e.status).toEqual(403);
|
|
274
|
+
expect(e.message).toEqual('Forbidden');
|
|
275
|
+
}
|
|
276
|
+
});
|
|
277
|
+
it('require ability decorator', async () => {
|
|
278
|
+
const { bob } = await makeUsers();
|
|
279
|
+
await tilmeld.fillSession(bob);
|
|
280
|
+
const bobsEntity = await TestModel.factory();
|
|
281
|
+
bobsEntity.name = "Bob's Entity";
|
|
282
|
+
await bobsEntity.$save();
|
|
283
|
+
try {
|
|
284
|
+
bobsEntity.$testRequireAbilityDecorator();
|
|
285
|
+
throw new Error('Should have thrown.');
|
|
286
|
+
}
|
|
287
|
+
catch (e) {
|
|
288
|
+
expect(e).toBeInstanceOf(HttpError);
|
|
289
|
+
expect(e.status).toEqual(403);
|
|
290
|
+
expect(e.message).toEqual('Forbidden');
|
|
291
|
+
}
|
|
292
|
+
try {
|
|
293
|
+
await bobsEntity.$testRequireAbilityDecoratorAsync();
|
|
294
|
+
throw new Error('Should have thrown.');
|
|
295
|
+
}
|
|
296
|
+
catch (e) {
|
|
297
|
+
expect(e).toBeInstanceOf(HttpError);
|
|
298
|
+
expect(e.status).toEqual(403);
|
|
299
|
+
expect(e.message).toEqual('Forbidden');
|
|
300
|
+
}
|
|
301
|
+
tilmeld.clearSession();
|
|
302
|
+
try {
|
|
303
|
+
bobsEntity.$testRequireAbilityDecorator();
|
|
304
|
+
throw new Error('Should have thrown.');
|
|
305
|
+
}
|
|
306
|
+
catch (e) {
|
|
307
|
+
expect(e).toBeInstanceOf(HttpError);
|
|
308
|
+
expect(e.status).toEqual(403);
|
|
309
|
+
expect(e.message).toEqual('Forbidden');
|
|
310
|
+
}
|
|
311
|
+
try {
|
|
312
|
+
await bobsEntity.$testRequireAbilityDecoratorAsync();
|
|
313
|
+
throw new Error('Should have thrown.');
|
|
314
|
+
}
|
|
315
|
+
catch (e) {
|
|
316
|
+
expect(e).toBeInstanceOf(HttpError);
|
|
317
|
+
expect(e.status).toEqual(403);
|
|
318
|
+
expect(e.message).toEqual('Forbidden');
|
|
319
|
+
}
|
|
320
|
+
bob.$grant('test-ability');
|
|
321
|
+
await tilmeld.fillSession(bob);
|
|
322
|
+
expect(bobsEntity.$testRequireAbilityDecorator()).toEqual(true);
|
|
323
|
+
expect(await bobsEntity.$testRequireAbilityDecoratorAsync()).toEqual(true);
|
|
324
|
+
});
|
|
181
325
|
it("alice can't access an entity owned by bob", async () => {
|
|
182
326
|
const { bob, alice } = await makeUsers();
|
|
183
327
|
await tilmeld.fillSession(bob);
|
|
184
328
|
const bobsEntity = await TestModel.factory();
|
|
185
329
|
bobsEntity.name = "Bob's Entity";
|
|
186
|
-
|
|
330
|
+
await bobsEntity.$save();
|
|
187
331
|
expect(bobsEntity.guid).not.toBeNull();
|
|
188
332
|
expect(bob.$is(bobsEntity.user)).toEqual(true);
|
|
189
333
|
const testEntityBob = await nymph.getEntity({ class: TestModel }, { type: '&', guid: bobsEntity.guid || '' });
|
|
@@ -200,7 +344,7 @@ export function TilmeldTest(nymphBase, describe, it) {
|
|
|
200
344
|
const bobsEntity = await TestModel.factory();
|
|
201
345
|
bobsEntity.name = "Bob's Entity";
|
|
202
346
|
bobsEntity.acRead = [alice.guid ?? ''];
|
|
203
|
-
|
|
347
|
+
await bobsEntity.$save();
|
|
204
348
|
expect(bobsEntity.guid).not.toBeNull();
|
|
205
349
|
expect(bob.$is(bobsEntity.user)).toEqual(true);
|
|
206
350
|
const testEntityBob = await nymph.getEntity({ class: TestModel }, { type: '&', guid: bobsEntity.guid || '' });
|
|
@@ -231,7 +375,7 @@ export function TilmeldTest(nymphBase, describe, it) {
|
|
|
231
375
|
const bobsEntity = await TestModel.factory();
|
|
232
376
|
bobsEntity.name = "Bob's Entity";
|
|
233
377
|
bobsEntity.acWrite = [alice.guid ?? ''];
|
|
234
|
-
|
|
378
|
+
await bobsEntity.$save();
|
|
235
379
|
expect(bobsEntity.guid).not.toBeNull();
|
|
236
380
|
expect(bob.$is(bobsEntity.user)).toEqual(true);
|
|
237
381
|
const testEntityBob = await nymph.getEntity({ class: TestModel }, { type: '&', guid: bobsEntity.guid || '' });
|
|
@@ -246,7 +390,7 @@ export function TilmeldTest(nymphBase, describe, it) {
|
|
|
246
390
|
throw new Error();
|
|
247
391
|
}
|
|
248
392
|
testEntityAlice.name = "Haha! It's mine now!";
|
|
249
|
-
|
|
393
|
+
await testEntityAlice.$save();
|
|
250
394
|
expect(await testEntityAlice.$refresh()).toEqual(true);
|
|
251
395
|
expect(testEntityAlice.name).toEqual("Haha! It's mine now!");
|
|
252
396
|
});
|
|
@@ -256,7 +400,7 @@ export function TilmeldTest(nymphBase, describe, it) {
|
|
|
256
400
|
const bobsEntity = await TestModel.factory();
|
|
257
401
|
bobsEntity.name = "Bob's Entity";
|
|
258
402
|
bobsEntity.acWrite = [alice.guid ?? ''];
|
|
259
|
-
|
|
403
|
+
await bobsEntity.$save();
|
|
260
404
|
expect(bobsEntity.guid).not.toBeNull();
|
|
261
405
|
expect(bob.$is(bobsEntity.user)).toEqual(true);
|
|
262
406
|
const testEntityBob = await nymph.getEntity({ class: TestModel }, { type: '&', guid: bobsEntity.guid || '' });
|
|
@@ -286,7 +430,7 @@ export function TilmeldTest(nymphBase, describe, it) {
|
|
|
286
430
|
const bobsEntity = await TestModel.factory();
|
|
287
431
|
bobsEntity.name = "Bob's Entity";
|
|
288
432
|
bobsEntity.acFull = [alice.guid ?? ''];
|
|
289
|
-
|
|
433
|
+
await bobsEntity.$save();
|
|
290
434
|
expect(bobsEntity.guid).not.toBeNull();
|
|
291
435
|
expect(bob.$is(bobsEntity.user)).toEqual(true);
|
|
292
436
|
const testEntityBob = await nymph.getEntity({ class: TestModel }, { type: '&', guid: bobsEntity.guid || '' });
|
|
@@ -300,7 +444,7 @@ export function TilmeldTest(nymphBase, describe, it) {
|
|
|
300
444
|
if (testEntityAlice == null) {
|
|
301
445
|
throw new Error();
|
|
302
446
|
}
|
|
303
|
-
|
|
447
|
+
await testEntityAlice.$delete();
|
|
304
448
|
const verifyEntityAlice = await nymph.getEntity({ class: TestModel }, { type: '&', guid: bobsEntity.guid || '' });
|
|
305
449
|
expect(verifyEntityAlice).toBeNull();
|
|
306
450
|
});
|
|
@@ -310,7 +454,7 @@ export function TilmeldTest(nymphBase, describe, it) {
|
|
|
310
454
|
const bobsEntity = await TestModel.factory();
|
|
311
455
|
bobsEntity.name = "Bob's Entity";
|
|
312
456
|
bobsEntity.acRead = [abgroup.guid ?? ''];
|
|
313
|
-
|
|
457
|
+
await bobsEntity.$save();
|
|
314
458
|
expect(bobsEntity.guid).not.toBeNull();
|
|
315
459
|
expect(bob.$is(bobsEntity.user)).toEqual(true);
|
|
316
460
|
const testEntityBob = await nymph.getEntity({ class: TestModel }, { type: '&', guid: bobsEntity.guid || '' });
|
|
@@ -328,7 +472,7 @@ export function TilmeldTest(nymphBase, describe, it) {
|
|
|
328
472
|
const bobsEntity = await TestModel.factory();
|
|
329
473
|
bobsEntity.name = "Bob's Entity";
|
|
330
474
|
bobsEntity.acRead = [abgroup.guid ?? ''];
|
|
331
|
-
|
|
475
|
+
await bobsEntity.$save();
|
|
332
476
|
expect(bobsEntity.guid).not.toBeNull();
|
|
333
477
|
expect(bob.$is(bobsEntity.user)).toEqual(true);
|
|
334
478
|
const testEntityBob = await nymph.getEntity({ class: TestModel }, { type: '&', guid: bobsEntity.guid || '' });
|
|
@@ -359,7 +503,7 @@ export function TilmeldTest(nymphBase, describe, it) {
|
|
|
359
503
|
const bobsEntity = await TestModel.factory();
|
|
360
504
|
bobsEntity.name = "Bob's Entity";
|
|
361
505
|
bobsEntity.acWrite = [abgroup.guid ?? ''];
|
|
362
|
-
|
|
506
|
+
await bobsEntity.$save();
|
|
363
507
|
expect(bobsEntity.guid).not.toBeNull();
|
|
364
508
|
expect(bob.$is(bobsEntity.user)).toEqual(true);
|
|
365
509
|
const testEntityBob = await nymph.getEntity({ class: TestModel }, { type: '&', guid: bobsEntity.guid || '' });
|
|
@@ -374,7 +518,7 @@ export function TilmeldTest(nymphBase, describe, it) {
|
|
|
374
518
|
throw new Error();
|
|
375
519
|
}
|
|
376
520
|
testEntityAlice.name = "Haha! It's mine now!";
|
|
377
|
-
|
|
521
|
+
await testEntityAlice.$save();
|
|
378
522
|
expect(await testEntityAlice.$refresh()).toEqual(true);
|
|
379
523
|
expect(testEntityAlice.name).toEqual("Haha! It's mine now!");
|
|
380
524
|
});
|
|
@@ -384,7 +528,7 @@ export function TilmeldTest(nymphBase, describe, it) {
|
|
|
384
528
|
const bobsEntity = await TestModel.factory();
|
|
385
529
|
bobsEntity.name = "Bob's Entity";
|
|
386
530
|
bobsEntity.acWrite = [abgroup.guid ?? ''];
|
|
387
|
-
|
|
531
|
+
await bobsEntity.$save();
|
|
388
532
|
expect(bobsEntity.guid).not.toBeNull();
|
|
389
533
|
expect(bob.$is(bobsEntity.user)).toEqual(true);
|
|
390
534
|
const testEntityBob = await nymph.getEntity({ class: TestModel }, { type: '&', guid: bobsEntity.guid || '' });
|
|
@@ -414,7 +558,7 @@ export function TilmeldTest(nymphBase, describe, it) {
|
|
|
414
558
|
const bobsEntity = await TestModel.factory();
|
|
415
559
|
bobsEntity.name = "Bob's Entity";
|
|
416
560
|
bobsEntity.acFull = [abgroup.guid ?? ''];
|
|
417
|
-
|
|
561
|
+
await bobsEntity.$save();
|
|
418
562
|
expect(bobsEntity.guid).not.toBeNull();
|
|
419
563
|
expect(bob.$is(bobsEntity.user)).toEqual(true);
|
|
420
564
|
const testEntityBob = await nymph.getEntity({ class: TestModel }, { type: '&', guid: bobsEntity.guid || '' });
|
|
@@ -428,7 +572,7 @@ export function TilmeldTest(nymphBase, describe, it) {
|
|
|
428
572
|
if (testEntityAlice == null) {
|
|
429
573
|
throw new Error();
|
|
430
574
|
}
|
|
431
|
-
|
|
575
|
+
await testEntityAlice.$delete();
|
|
432
576
|
const verifyEntityAlice = await nymph.getEntity({ class: TestModel }, { type: '&', guid: bobsEntity.guid || '' });
|
|
433
577
|
expect(verifyEntityAlice).toBeNull();
|
|
434
578
|
});
|
|
@@ -438,7 +582,7 @@ export function TilmeldTest(nymphBase, describe, it) {
|
|
|
438
582
|
const bobsEntity = await TestModel.factory();
|
|
439
583
|
bobsEntity.name = "Bob's Entity";
|
|
440
584
|
bobsEntity.group = alice.group;
|
|
441
|
-
|
|
585
|
+
await bobsEntity.$save();
|
|
442
586
|
expect(bobsEntity.guid).not.toBeNull();
|
|
443
587
|
expect(bob.$is(bobsEntity.user)).toEqual(true);
|
|
444
588
|
const testEntityBob = await nymph.getEntity({ class: TestModel }, { type: '&', guid: bobsEntity.guid || '' });
|
|
@@ -456,7 +600,7 @@ export function TilmeldTest(nymphBase, describe, it) {
|
|
|
456
600
|
const bobsEntity = await TestModel.factory();
|
|
457
601
|
bobsEntity.name = "Bob's Entity";
|
|
458
602
|
bobsEntity.group = alice.group;
|
|
459
|
-
|
|
603
|
+
await bobsEntity.$save();
|
|
460
604
|
expect(bobsEntity.guid).not.toBeNull();
|
|
461
605
|
expect(bob.$is(bobsEntity.user)).toEqual(true);
|
|
462
606
|
const testEntityBob = await nymph.getEntity({ class: TestModel }, { type: '&', guid: bobsEntity.guid || '' });
|
|
@@ -488,7 +632,7 @@ export function TilmeldTest(nymphBase, describe, it) {
|
|
|
488
632
|
bobsEntity.name = "Bob's Entity";
|
|
489
633
|
bobsEntity.group = alice.group;
|
|
490
634
|
bobsEntity.acGroup = TilmeldAccessLevels.WRITE_ACCESS;
|
|
491
|
-
|
|
635
|
+
await bobsEntity.$save();
|
|
492
636
|
expect(bobsEntity.guid).not.toBeNull();
|
|
493
637
|
expect(bob.$is(bobsEntity.user)).toEqual(true);
|
|
494
638
|
const testEntityBob = await nymph.getEntity({ class: TestModel }, { type: '&', guid: bobsEntity.guid || '' });
|
|
@@ -503,7 +647,7 @@ export function TilmeldTest(nymphBase, describe, it) {
|
|
|
503
647
|
throw new Error();
|
|
504
648
|
}
|
|
505
649
|
testEntityAlice.name = "Haha! It's mine now!";
|
|
506
|
-
|
|
650
|
+
await testEntityAlice.$save();
|
|
507
651
|
expect(await testEntityAlice.$refresh()).toEqual(true);
|
|
508
652
|
expect(testEntityAlice.name).toEqual("Haha! It's mine now!");
|
|
509
653
|
});
|
|
@@ -514,7 +658,7 @@ export function TilmeldTest(nymphBase, describe, it) {
|
|
|
514
658
|
bobsEntity.name = "Bob's Entity";
|
|
515
659
|
bobsEntity.group = alice.group;
|
|
516
660
|
bobsEntity.acGroup = TilmeldAccessLevels.WRITE_ACCESS;
|
|
517
|
-
|
|
661
|
+
await bobsEntity.$save();
|
|
518
662
|
expect(bobsEntity.guid).not.toBeNull();
|
|
519
663
|
expect(bob.$is(bobsEntity.user)).toEqual(true);
|
|
520
664
|
const testEntityBob = await nymph.getEntity({ class: TestModel }, { type: '&', guid: bobsEntity.guid || '' });
|
|
@@ -545,7 +689,7 @@ export function TilmeldTest(nymphBase, describe, it) {
|
|
|
545
689
|
bobsEntity.name = "Bob's Entity";
|
|
546
690
|
bobsEntity.group = alice.group;
|
|
547
691
|
bobsEntity.acGroup = TilmeldAccessLevels.FULL_ACCESS;
|
|
548
|
-
|
|
692
|
+
await bobsEntity.$save();
|
|
549
693
|
expect(bobsEntity.guid).not.toBeNull();
|
|
550
694
|
expect(bob.$is(bobsEntity.user)).toEqual(true);
|
|
551
695
|
const testEntityBob = await nymph.getEntity({ class: TestModel }, { type: '&', guid: bobsEntity.guid || '' });
|
|
@@ -559,7 +703,7 @@ export function TilmeldTest(nymphBase, describe, it) {
|
|
|
559
703
|
if (testEntityAlice == null) {
|
|
560
704
|
throw new Error();
|
|
561
705
|
}
|
|
562
|
-
|
|
706
|
+
await testEntityAlice.$delete();
|
|
563
707
|
const verifyEntityAlice = await nymph.getEntity({ class: TestModel }, { type: '&', guid: bobsEntity.guid || '' });
|
|
564
708
|
expect(verifyEntityAlice).toBeNull();
|
|
565
709
|
});
|
|
@@ -569,7 +713,7 @@ export function TilmeldTest(nymphBase, describe, it) {
|
|
|
569
713
|
const bobsEntity = await TestModel.factory();
|
|
570
714
|
bobsEntity.name = "Bob's Entity";
|
|
571
715
|
bobsEntity.acOther = TilmeldAccessLevels.READ_ACCESS;
|
|
572
|
-
|
|
716
|
+
await bobsEntity.$save();
|
|
573
717
|
expect(bobsEntity.guid).not.toBeNull();
|
|
574
718
|
expect(bob.$is(bobsEntity.user)).toEqual(true);
|
|
575
719
|
const testEntityBob = await nymph.getEntity({ class: TestModel }, { type: '&', guid: bobsEntity.guid || '' });
|
|
@@ -587,7 +731,7 @@ export function TilmeldTest(nymphBase, describe, it) {
|
|
|
587
731
|
const bobsEntity = await TestModel.factory();
|
|
588
732
|
bobsEntity.name = "Bob's Entity";
|
|
589
733
|
bobsEntity.acOther = TilmeldAccessLevels.READ_ACCESS;
|
|
590
|
-
|
|
734
|
+
await bobsEntity.$save();
|
|
591
735
|
expect(bobsEntity.guid).not.toBeNull();
|
|
592
736
|
expect(bob.$is(bobsEntity.user)).toEqual(true);
|
|
593
737
|
const testEntityBob = await nymph.getEntity({ class: TestModel }, { type: '&', guid: bobsEntity.guid || '' });
|
|
@@ -618,7 +762,7 @@ export function TilmeldTest(nymphBase, describe, it) {
|
|
|
618
762
|
const bobsEntity = await TestModel.factory();
|
|
619
763
|
bobsEntity.name = "Bob's Entity";
|
|
620
764
|
bobsEntity.acOther = TilmeldAccessLevels.WRITE_ACCESS;
|
|
621
|
-
|
|
765
|
+
await bobsEntity.$save();
|
|
622
766
|
expect(bobsEntity.guid).not.toBeNull();
|
|
623
767
|
expect(bob.$is(bobsEntity.user)).toEqual(true);
|
|
624
768
|
const testEntityBob = await nymph.getEntity({ class: TestModel }, { type: '&', guid: bobsEntity.guid || '' });
|
|
@@ -633,7 +777,7 @@ export function TilmeldTest(nymphBase, describe, it) {
|
|
|
633
777
|
throw new Error();
|
|
634
778
|
}
|
|
635
779
|
testEntityAlice.name = "Haha! It's mine now!";
|
|
636
|
-
|
|
780
|
+
await testEntityAlice.$save();
|
|
637
781
|
expect(await testEntityAlice.$refresh()).toEqual(true);
|
|
638
782
|
expect(testEntityAlice.name).toEqual("Haha! It's mine now!");
|
|
639
783
|
});
|
|
@@ -643,7 +787,7 @@ export function TilmeldTest(nymphBase, describe, it) {
|
|
|
643
787
|
const bobsEntity = await TestModel.factory();
|
|
644
788
|
bobsEntity.name = "Bob's Entity";
|
|
645
789
|
bobsEntity.acOther = TilmeldAccessLevels.WRITE_ACCESS;
|
|
646
|
-
|
|
790
|
+
await bobsEntity.$save();
|
|
647
791
|
expect(bobsEntity.guid).not.toBeNull();
|
|
648
792
|
expect(bob.$is(bobsEntity.user)).toEqual(true);
|
|
649
793
|
const testEntityBob = await nymph.getEntity({ class: TestModel }, { type: '&', guid: bobsEntity.guid || '' });
|
|
@@ -673,7 +817,7 @@ export function TilmeldTest(nymphBase, describe, it) {
|
|
|
673
817
|
const bobsEntity = await TestModel.factory();
|
|
674
818
|
bobsEntity.name = "Bob's Entity";
|
|
675
819
|
bobsEntity.acOther = TilmeldAccessLevels.FULL_ACCESS;
|
|
676
|
-
|
|
820
|
+
await bobsEntity.$save();
|
|
677
821
|
expect(bobsEntity.guid).not.toBeNull();
|
|
678
822
|
expect(bob.$is(bobsEntity.user)).toEqual(true);
|
|
679
823
|
const testEntityBob = await nymph.getEntity({ class: TestModel }, { type: '&', guid: bobsEntity.guid || '' });
|
|
@@ -687,7 +831,7 @@ export function TilmeldTest(nymphBase, describe, it) {
|
|
|
687
831
|
if (testEntityAlice == null) {
|
|
688
832
|
throw new Error();
|
|
689
833
|
}
|
|
690
|
-
|
|
834
|
+
await testEntityAlice.$delete();
|
|
691
835
|
const verifyEntityAlice = await nymph.getEntity({ class: TestModel }, { type: '&', guid: bobsEntity.guid || '' });
|
|
692
836
|
expect(verifyEntityAlice).toBeNull();
|
|
693
837
|
});
|
|
@@ -697,7 +841,7 @@ export function TilmeldTest(nymphBase, describe, it) {
|
|
|
697
841
|
const bobsEntity = await TestModel.factory();
|
|
698
842
|
bobsEntity.name = "Bob's Entity";
|
|
699
843
|
bobsEntity.acOther = TilmeldAccessLevels.FULL_ACCESS;
|
|
700
|
-
|
|
844
|
+
await bobsEntity.$save();
|
|
701
845
|
expect(bobsEntity.guid).not.toBeNull();
|
|
702
846
|
expect(bob.$is(bobsEntity.user)).toEqual(true);
|
|
703
847
|
const testEntityBob = await nymph.getEntity({ class: TestModel }, { type: '&', guid: bobsEntity.guid || '' });
|
|
@@ -710,7 +854,7 @@ export function TilmeldTest(nymphBase, describe, it) {
|
|
|
710
854
|
if (testEntityNobody == null) {
|
|
711
855
|
throw new Error();
|
|
712
856
|
}
|
|
713
|
-
|
|
857
|
+
await testEntityNobody.$delete();
|
|
714
858
|
const verifyEntityNobody = await nymph.getEntity({ class: TestModel }, { type: '&', guid: bobsEntity.guid || '' });
|
|
715
859
|
expect(verifyEntityNobody).toBeNull();
|
|
716
860
|
});
|
|
@@ -721,7 +865,7 @@ export function TilmeldTest(nymphBase, describe, it) {
|
|
|
721
865
|
...(await nymph.getEntities({ class: Group, skipAc: true })),
|
|
722
866
|
];
|
|
723
867
|
for (let entity of allEntities) {
|
|
724
|
-
|
|
868
|
+
await entity.$deleteSkipAC();
|
|
725
869
|
}
|
|
726
870
|
});
|
|
727
871
|
it('entity can be retrieved by queries on ac properties', async () => {
|
|
@@ -736,7 +880,7 @@ export function TilmeldTest(nymphBase, describe, it) {
|
|
|
736
880
|
];
|
|
737
881
|
bobsEntity.acWrite = [alice.guid ?? '', bob.guid ?? ''];
|
|
738
882
|
bobsEntity.acFull = [bob.guid ?? ''];
|
|
739
|
-
|
|
883
|
+
await bobsEntity.$save();
|
|
740
884
|
expect(bobsEntity.guid).not.toBeNull();
|
|
741
885
|
expect(bob.$is(bobsEntity.user)).toEqual(true);
|
|
742
886
|
const testEntityBob = await nymph.getEntity({ class: TestModel }, { type: '&', guid: bobsEntity.guid || '' });
|
|
@@ -954,7 +1098,7 @@ export function TilmeldTest(nymphBase, describe, it) {
|
|
|
954
1098
|
await tilmeld.fillSession(alice);
|
|
955
1099
|
const alicesEntity = await TestModel.factory();
|
|
956
1100
|
alicesEntity.name = "Alice's Entity";
|
|
957
|
-
|
|
1101
|
+
await alicesEntity.$save();
|
|
958
1102
|
expect(alicesEntity.guid).not.toBeNull();
|
|
959
1103
|
expect(alice.$is(alicesEntity.user)).toEqual(true);
|
|
960
1104
|
const testEntityAlice = await nymph.getEntity({ class: TestModel, acRequest: TilmeldAccessRequest.USER_OWNED }, { type: '&', guid: alicesEntity.guid || '' });
|
|
@@ -968,7 +1112,7 @@ export function TilmeldTest(nymphBase, describe, it) {
|
|
|
968
1112
|
const bobsEntity = await TestModel.factory();
|
|
969
1113
|
bobsEntity.name = "Bob's Entity";
|
|
970
1114
|
bobsEntity.group = alice.group;
|
|
971
|
-
|
|
1115
|
+
await bobsEntity.$save();
|
|
972
1116
|
expect(bobsEntity.guid).not.toBeNull();
|
|
973
1117
|
expect(bob.$is(bobsEntity.user)).toEqual(true);
|
|
974
1118
|
const testEntityBob = await nymph.getEntity({ class: TestModel }, { type: '&', guid: bobsEntity.guid || '' });
|
|
@@ -992,7 +1136,7 @@ export function TilmeldTest(nymphBase, describe, it) {
|
|
|
992
1136
|
const bobsEntity = await TestModel.factory();
|
|
993
1137
|
bobsEntity.name = "Bob's Entity";
|
|
994
1138
|
bobsEntity.acOther = TilmeldAccessLevels.READ_ACCESS;
|
|
995
|
-
|
|
1139
|
+
await bobsEntity.$save();
|
|
996
1140
|
expect(bobsEntity.guid).not.toBeNull();
|
|
997
1141
|
expect(bob.$is(bobsEntity.user)).toEqual(true);
|
|
998
1142
|
const testEntityBob = await nymph.getEntity({ class: TestModel }, { type: '&', guid: bobsEntity.guid || '' });
|
|
@@ -1013,7 +1157,7 @@ export function TilmeldTest(nymphBase, describe, it) {
|
|
|
1013
1157
|
const bobsEntity = await TestModel.factory();
|
|
1014
1158
|
bobsEntity.name = "Bob's Entity";
|
|
1015
1159
|
bobsEntity.acRead = [alice.guid ?? ''];
|
|
1016
|
-
|
|
1160
|
+
await bobsEntity.$save();
|
|
1017
1161
|
expect(bobsEntity.guid).not.toBeNull();
|
|
1018
1162
|
expect(bob.$is(bobsEntity.user)).toEqual(true);
|
|
1019
1163
|
const testEntityBob = await nymph.getEntity({ class: TestModel }, { type: '&', guid: bobsEntity.guid || '' });
|
|
@@ -1034,7 +1178,7 @@ export function TilmeldTest(nymphBase, describe, it) {
|
|
|
1034
1178
|
const bobsEntity = await TestModel.factory();
|
|
1035
1179
|
bobsEntity.name = "Bob's Entity";
|
|
1036
1180
|
bobsEntity.acWrite = [alice.group?.guid ?? ''];
|
|
1037
|
-
|
|
1181
|
+
await bobsEntity.$save();
|
|
1038
1182
|
expect(bobsEntity.guid).not.toBeNull();
|
|
1039
1183
|
expect(bob.$is(bobsEntity.user)).toEqual(true);
|
|
1040
1184
|
const testEntityBob = await nymph.getEntity({ class: TestModel }, { type: '&', guid: bobsEntity.guid || '' });
|
|
@@ -1058,7 +1202,7 @@ export function TilmeldTest(nymphBase, describe, it) {
|
|
|
1058
1202
|
const bobsEntity = await TestModel.factory();
|
|
1059
1203
|
bobsEntity.name = "Bob's Entity";
|
|
1060
1204
|
bobsEntity.group = abgroup;
|
|
1061
|
-
|
|
1205
|
+
await bobsEntity.$save();
|
|
1062
1206
|
expect(bobsEntity.guid).not.toBeNull();
|
|
1063
1207
|
expect(bob.$is(bobsEntity.user)).toEqual(true);
|
|
1064
1208
|
const testEntityBob = await nymph.getEntity({ class: TestModel }, { type: '&', guid: bobsEntity.guid || '' });
|
|
@@ -1082,7 +1226,7 @@ export function TilmeldTest(nymphBase, describe, it) {
|
|
|
1082
1226
|
const bobsEntity = await TestModel.factory();
|
|
1083
1227
|
bobsEntity.name = "Bob's Entity";
|
|
1084
1228
|
bobsEntity.acFull = [abgroup.guid ?? ''];
|
|
1085
|
-
|
|
1229
|
+
await bobsEntity.$save();
|
|
1086
1230
|
expect(bobsEntity.guid).not.toBeNull();
|
|
1087
1231
|
expect(bob.$is(bobsEntity.user)).toEqual(true);
|
|
1088
1232
|
const testEntityBob = await nymph.getEntity({ class: TestModel }, { type: '&', guid: bobsEntity.guid || '' });
|
|
@@ -1113,7 +1257,7 @@ export function TilmeldTest(nymphBase, describe, it) {
|
|
|
1113
1257
|
const bobsEntity = await TestModel.factory();
|
|
1114
1258
|
bobsEntity.name = "Bob's Entity";
|
|
1115
1259
|
bobsEntity.acFull = [alice.guid ?? ''];
|
|
1116
|
-
|
|
1260
|
+
await bobsEntity.$save();
|
|
1117
1261
|
expect(bobsEntity.guid).not.toBeNull();
|
|
1118
1262
|
expect(bob.$is(bobsEntity.user)).toEqual(true);
|
|
1119
1263
|
const testEntityBob = await nymph.getEntity({ class: TestModel }, { type: '&', guid: bobsEntity.guid || '' });
|
|
@@ -1123,7 +1267,7 @@ export function TilmeldTest(nymphBase, describe, it) {
|
|
|
1123
1267
|
await tilmeld.fillSession(alice);
|
|
1124
1268
|
const alicesEntity = await TestModel.factory();
|
|
1125
1269
|
alicesEntity.name = "Alice's Entity";
|
|
1126
|
-
|
|
1270
|
+
await alicesEntity.$save();
|
|
1127
1271
|
expect(alicesEntity.guid).not.toBeNull();
|
|
1128
1272
|
expect(alice.$is(alicesEntity.user)).toEqual(true);
|
|
1129
1273
|
const testEntityAlice = await nymph.getEntity({ class: TestModel }, { type: '&', guid: bobsEntity.guid || '' });
|
|
@@ -1152,7 +1296,7 @@ export function TilmeldTest(nymphBase, describe, it) {
|
|
|
1152
1296
|
await tilmeld.fillSession(bob);
|
|
1153
1297
|
const bobsEntity = await TestModel.factory();
|
|
1154
1298
|
bobsEntity.name = "Bob's Entity";
|
|
1155
|
-
|
|
1299
|
+
await bobsEntity.$save();
|
|
1156
1300
|
expect(bobsEntity.guid).not.toBeNull();
|
|
1157
1301
|
expect(bob.$is(bobsEntity.user)).toEqual(true);
|
|
1158
1302
|
const testEntityBob = await nymph.getEntity({ class: TestModel }, { type: '&', guid: bobsEntity.guid || '' });
|