@nymphjs/tilmeld 1.0.0-beta.106 → 1.0.0-beta.108
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 +11 -0
- package/dist/Group.test.js +3 -0
- package/dist/Group.test.js.map +1 -1
- package/dist/User.test.js +3 -0
- package/dist/User.test.js.map +1 -1
- package/dist/errors/AccessControlError.d.ts +1 -1
- package/dist/errors/AccessControlError.js +1 -1
- package/dist/errors/AccessControlError.js.map +1 -1
- package/dist/errors/BadDataError.d.ts +1 -1
- package/dist/errors/BadDataError.js +1 -1
- package/dist/errors/BadDataError.js.map +1 -1
- package/dist/errors/BadEmailError.d.ts +1 -1
- package/dist/errors/BadEmailError.js +1 -1
- package/dist/errors/BadEmailError.js.map +1 -1
- package/dist/errors/BadUsernameError.d.ts +1 -1
- package/dist/errors/BadUsernameError.js +1 -1
- package/dist/errors/BadUsernameError.js.map +1 -1
- 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 +19 -0
- package/dist/testArtifacts.js +695 -0
- package/dist/testArtifacts.js.map +1 -0
- package/package.json +19 -21
- package/src/Group.test.ts +3 -0
- package/src/User.test.ts +3 -0
- package/src/errors/AccessControlError.ts +1 -1
- package/src/errors/BadDataError.ts +1 -1
- package/src/errors/BadEmailError.ts +1 -1
- package/src/errors/BadUsernameError.ts +1 -1
- package/src/index.ts +2 -0
- package/src/testArtifacts.ts +1106 -0
|
@@ -0,0 +1,695 @@
|
|
|
1
|
+
import { Entity, Nymph, TilmeldAccessLevels } from '@nymphjs/nymph';
|
|
2
|
+
import Tilmeld from './Tilmeld.js';
|
|
3
|
+
import { AccessControlError } from './errors/index.js';
|
|
4
|
+
import { TestModel as TestModelClass } from './testArtifacts.js';
|
|
5
|
+
/**
|
|
6
|
+
* This class is a test class that extends the Entity class.
|
|
7
|
+
*/
|
|
8
|
+
export class TestModel extends Entity {
|
|
9
|
+
static ETYPE = 'tilmeld_test_model';
|
|
10
|
+
static class = 'TestModel';
|
|
11
|
+
/**
|
|
12
|
+
* This should only be used by the backend.
|
|
13
|
+
*/
|
|
14
|
+
$skipAcWhenDeleting = false;
|
|
15
|
+
/*
|
|
16
|
+
* This should *never* be accessible on the client.
|
|
17
|
+
*/
|
|
18
|
+
async $deleteSkipAC() {
|
|
19
|
+
this.$skipAcWhenDeleting = true;
|
|
20
|
+
return await this.$delete();
|
|
21
|
+
}
|
|
22
|
+
$tilmeldDeleteSkipAC() {
|
|
23
|
+
if (this.$skipAcWhenDeleting) {
|
|
24
|
+
this.$skipAcWhenDeleting = false;
|
|
25
|
+
return true;
|
|
26
|
+
}
|
|
27
|
+
return false;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
export function TilmeldTest(nymphBase, it) {
|
|
31
|
+
const tilmeld = new Tilmeld({
|
|
32
|
+
appName: 'My App',
|
|
33
|
+
appUrl: 'http://localhost:8080',
|
|
34
|
+
cookieDomain: 'localhost',
|
|
35
|
+
cookiePath: '/',
|
|
36
|
+
setupPath: '/user',
|
|
37
|
+
emailUsernames: false,
|
|
38
|
+
domainSupport: true,
|
|
39
|
+
verifyRedirect: 'http://localhost:8080',
|
|
40
|
+
verifyChangeRedirect: 'http://localhost:8080',
|
|
41
|
+
cancelChangeRedirect: 'http://localhost:8080',
|
|
42
|
+
jwtSecret: 'shhhhh',
|
|
43
|
+
sendEmail: async (_tilmeld, _options, _user) => {
|
|
44
|
+
return true;
|
|
45
|
+
},
|
|
46
|
+
});
|
|
47
|
+
const nymph = new Nymph(nymphBase.config, nymphBase.driver, tilmeld);
|
|
48
|
+
const User = tilmeld.User;
|
|
49
|
+
const Group = tilmeld.Group;
|
|
50
|
+
const TestModel = nymph.addEntityClass(TestModelClass);
|
|
51
|
+
async function makeUsers() {
|
|
52
|
+
const admin = await User.factoryUsername('admin');
|
|
53
|
+
const bob = await User.factoryUsername('bob');
|
|
54
|
+
const alice = await User.factoryUsername('alice');
|
|
55
|
+
const abgroup = await Group.factoryGroupname('abgroup');
|
|
56
|
+
if (admin.guid == null) {
|
|
57
|
+
admin.username = 'admin';
|
|
58
|
+
admin.email = 'admin@localhost';
|
|
59
|
+
admin.nameFirst = 'Admin';
|
|
60
|
+
admin.nameLast = 'User';
|
|
61
|
+
admin.name = 'Admin User';
|
|
62
|
+
admin.$password('password');
|
|
63
|
+
admin.$grant('system/admin');
|
|
64
|
+
await admin.$saveSkipAC();
|
|
65
|
+
}
|
|
66
|
+
if (abgroup.guid == null) {
|
|
67
|
+
abgroup.groupname = 'abgroup';
|
|
68
|
+
abgroup.email = 'abgroup@localhost';
|
|
69
|
+
abgroup.name = 'AB Group';
|
|
70
|
+
await abgroup.$saveSkipAC();
|
|
71
|
+
}
|
|
72
|
+
if (bob.guid == null) {
|
|
73
|
+
bob.username = 'bob';
|
|
74
|
+
bob.email = 'bob@localhost';
|
|
75
|
+
bob.nameFirst = 'Bob';
|
|
76
|
+
bob.nameLast = 'User';
|
|
77
|
+
bob.name = 'Bob User';
|
|
78
|
+
bob.$password('password');
|
|
79
|
+
bob.$addGroup(abgroup);
|
|
80
|
+
await bob.$saveSkipAC();
|
|
81
|
+
}
|
|
82
|
+
if (alice.guid == null) {
|
|
83
|
+
alice.username = 'alice';
|
|
84
|
+
alice.email = 'alice@localhost';
|
|
85
|
+
alice.nameFirst = 'Alice';
|
|
86
|
+
alice.nameLast = 'User';
|
|
87
|
+
alice.name = 'Alice User';
|
|
88
|
+
alice.$password('password');
|
|
89
|
+
alice.$addGroup(abgroup);
|
|
90
|
+
await alice.$saveSkipAC();
|
|
91
|
+
}
|
|
92
|
+
return { admin, bob, alice, abgroup };
|
|
93
|
+
}
|
|
94
|
+
it('users can log in', async () => {
|
|
95
|
+
const { admin, bob, alice } = await makeUsers();
|
|
96
|
+
let result = await admin.$login({
|
|
97
|
+
username: 'admin',
|
|
98
|
+
password: 'password',
|
|
99
|
+
});
|
|
100
|
+
expect(result.result).toEqual(true);
|
|
101
|
+
expect(admin.$is(User.current())).toEqual(true);
|
|
102
|
+
result = await admin.$logout();
|
|
103
|
+
expect(result.result).toEqual(true);
|
|
104
|
+
expect(User.current()).toBeNull();
|
|
105
|
+
result = await bob.$login({
|
|
106
|
+
username: 'bob',
|
|
107
|
+
password: 'password',
|
|
108
|
+
});
|
|
109
|
+
expect(result.result).toEqual(true);
|
|
110
|
+
expect(bob.$is(User.current())).toEqual(true);
|
|
111
|
+
result = await bob.$logout();
|
|
112
|
+
expect(result.result).toEqual(true);
|
|
113
|
+
expect(User.current()).toBeNull();
|
|
114
|
+
result = await alice.$login({
|
|
115
|
+
username: 'alice',
|
|
116
|
+
password: 'password',
|
|
117
|
+
});
|
|
118
|
+
expect(result.result).toEqual(true);
|
|
119
|
+
expect(alice.$is(User.current())).toEqual(true);
|
|
120
|
+
result = await alice.$logout();
|
|
121
|
+
expect(result.result).toEqual(true);
|
|
122
|
+
expect(User.current()).toBeNull();
|
|
123
|
+
});
|
|
124
|
+
it('creates tables for test model', async () => {
|
|
125
|
+
const testEntity = await nymph.getEntity({ class: TestModel });
|
|
126
|
+
expect(testEntity).toBeNull();
|
|
127
|
+
});
|
|
128
|
+
it('user ownership, group ownership, and access controls are added on entities', async () => {
|
|
129
|
+
const { bob } = await makeUsers();
|
|
130
|
+
await tilmeld.fillSession(bob);
|
|
131
|
+
const bobsEntity = await TestModel.factory();
|
|
132
|
+
bobsEntity.name = "Bob's Entity";
|
|
133
|
+
expect(await bobsEntity.$save()).toEqual(true);
|
|
134
|
+
expect(bobsEntity.guid).not.toBeNull();
|
|
135
|
+
expect(bob.$is(bobsEntity.user)).toEqual(true);
|
|
136
|
+
const testEntityBob = await nymph.getEntity({ class: TestModel }, { type: '&', guid: bobsEntity.guid || '' });
|
|
137
|
+
expect(testEntityBob).not.toBeNull();
|
|
138
|
+
expect(testEntityBob?.guid).toEqual(bobsEntity.guid);
|
|
139
|
+
expect(testEntityBob?.user?.$is(bob)).toEqual(true);
|
|
140
|
+
expect(testEntityBob?.group?.$is(bob.group)).toEqual(true);
|
|
141
|
+
expect(testEntityBob?.acUser).toEqual(TilmeldAccessLevels.FULL_ACCESS);
|
|
142
|
+
expect(testEntityBob?.acGroup).toEqual(TilmeldAccessLevels.READ_ACCESS);
|
|
143
|
+
expect(testEntityBob?.acOther).toEqual(TilmeldAccessLevels.NO_ACCESS);
|
|
144
|
+
expect(testEntityBob?.acRead).toEqual([]);
|
|
145
|
+
expect(testEntityBob?.acWrite).toEqual([]);
|
|
146
|
+
expect(testEntityBob?.acFull).toEqual([]);
|
|
147
|
+
});
|
|
148
|
+
it("alice can't access an entity owned by bob", async () => {
|
|
149
|
+
const { bob, alice } = await makeUsers();
|
|
150
|
+
await tilmeld.fillSession(bob);
|
|
151
|
+
const bobsEntity = await TestModel.factory();
|
|
152
|
+
bobsEntity.name = "Bob's Entity";
|
|
153
|
+
expect(await bobsEntity.$save()).toEqual(true);
|
|
154
|
+
expect(bobsEntity.guid).not.toBeNull();
|
|
155
|
+
expect(bob.$is(bobsEntity.user)).toEqual(true);
|
|
156
|
+
const testEntityBob = await nymph.getEntity({ class: TestModel }, { type: '&', guid: bobsEntity.guid || '' });
|
|
157
|
+
expect(testEntityBob).not.toBeNull();
|
|
158
|
+
expect(testEntityBob?.guid).toEqual(bobsEntity.guid);
|
|
159
|
+
tilmeld.clearSession();
|
|
160
|
+
await tilmeld.fillSession(alice);
|
|
161
|
+
const testEntityAlice = await nymph.getEntity({ class: TestModel }, { type: '&', guid: bobsEntity.guid || '' });
|
|
162
|
+
expect(testEntityAlice).toBeNull();
|
|
163
|
+
});
|
|
164
|
+
it("alice can't write to an entity she doesn't have write permission for", async () => {
|
|
165
|
+
const { bob, alice } = await makeUsers();
|
|
166
|
+
await tilmeld.fillSession(bob);
|
|
167
|
+
const bobsEntity = await TestModel.factory();
|
|
168
|
+
bobsEntity.name = "Bob's Entity";
|
|
169
|
+
bobsEntity.acRead = [alice];
|
|
170
|
+
expect(await bobsEntity.$save()).toEqual(true);
|
|
171
|
+
expect(bobsEntity.guid).not.toBeNull();
|
|
172
|
+
expect(bob.$is(bobsEntity.user)).toEqual(true);
|
|
173
|
+
const testEntityBob = await nymph.getEntity({ class: TestModel }, { type: '&', guid: bobsEntity.guid || '' });
|
|
174
|
+
expect(testEntityBob).not.toBeNull();
|
|
175
|
+
expect(testEntityBob?.guid).toEqual(bobsEntity.guid);
|
|
176
|
+
tilmeld.clearSession();
|
|
177
|
+
await tilmeld.fillSession(alice);
|
|
178
|
+
const testEntityAlice = await nymph.getEntity({ class: TestModel }, { type: '&', guid: bobsEntity.guid || '' });
|
|
179
|
+
expect(testEntityAlice).not.toBeNull();
|
|
180
|
+
expect(testEntityAlice?.guid).toEqual(bobsEntity.guid);
|
|
181
|
+
if (testEntityAlice == null) {
|
|
182
|
+
throw new Error();
|
|
183
|
+
}
|
|
184
|
+
testEntityAlice.name = "Haha! It's mine now!";
|
|
185
|
+
try {
|
|
186
|
+
await testEntityAlice.$save();
|
|
187
|
+
throw new Error('It should have thrown AccessControlError.');
|
|
188
|
+
}
|
|
189
|
+
catch (e) {
|
|
190
|
+
expect(e).toBeInstanceOf(AccessControlError);
|
|
191
|
+
}
|
|
192
|
+
expect(await testEntityAlice.$refresh()).toEqual(true);
|
|
193
|
+
expect(testEntityAlice.name).toEqual("Bob's Entity");
|
|
194
|
+
});
|
|
195
|
+
it('alice can write to an entity she has write permission for', async () => {
|
|
196
|
+
const { bob, alice } = await makeUsers();
|
|
197
|
+
await tilmeld.fillSession(bob);
|
|
198
|
+
const bobsEntity = await TestModel.factory();
|
|
199
|
+
bobsEntity.name = "Bob's Entity";
|
|
200
|
+
bobsEntity.acWrite = [alice];
|
|
201
|
+
expect(await bobsEntity.$save()).toEqual(true);
|
|
202
|
+
expect(bobsEntity.guid).not.toBeNull();
|
|
203
|
+
expect(bob.$is(bobsEntity.user)).toEqual(true);
|
|
204
|
+
const testEntityBob = await nymph.getEntity({ class: TestModel }, { type: '&', guid: bobsEntity.guid || '' });
|
|
205
|
+
expect(testEntityBob).not.toBeNull();
|
|
206
|
+
expect(testEntityBob?.guid).toEqual(bobsEntity.guid);
|
|
207
|
+
tilmeld.clearSession();
|
|
208
|
+
await tilmeld.fillSession(alice);
|
|
209
|
+
const testEntityAlice = await nymph.getEntity({ class: TestModel }, { type: '&', guid: bobsEntity.guid || '' });
|
|
210
|
+
expect(testEntityAlice).not.toBeNull();
|
|
211
|
+
expect(testEntityAlice?.guid).toEqual(bobsEntity.guid);
|
|
212
|
+
if (testEntityAlice == null) {
|
|
213
|
+
throw new Error();
|
|
214
|
+
}
|
|
215
|
+
testEntityAlice.name = "Haha! It's mine now!";
|
|
216
|
+
expect(await testEntityAlice.$save()).toEqual(true);
|
|
217
|
+
expect(await testEntityAlice.$refresh()).toEqual(true);
|
|
218
|
+
expect(testEntityAlice.name).toEqual("Haha! It's mine now!");
|
|
219
|
+
});
|
|
220
|
+
it("alice can't delete an entity she doesn't have full permission for", async () => {
|
|
221
|
+
const { bob, alice } = await makeUsers();
|
|
222
|
+
await tilmeld.fillSession(bob);
|
|
223
|
+
const bobsEntity = await TestModel.factory();
|
|
224
|
+
bobsEntity.name = "Bob's Entity";
|
|
225
|
+
bobsEntity.acWrite = [alice];
|
|
226
|
+
expect(await bobsEntity.$save()).toEqual(true);
|
|
227
|
+
expect(bobsEntity.guid).not.toBeNull();
|
|
228
|
+
expect(bob.$is(bobsEntity.user)).toEqual(true);
|
|
229
|
+
const testEntityBob = await nymph.getEntity({ class: TestModel }, { type: '&', guid: bobsEntity.guid || '' });
|
|
230
|
+
expect(testEntityBob).not.toBeNull();
|
|
231
|
+
expect(testEntityBob?.guid).toEqual(bobsEntity.guid);
|
|
232
|
+
tilmeld.clearSession();
|
|
233
|
+
await tilmeld.fillSession(alice);
|
|
234
|
+
const testEntityAlice = await nymph.getEntity({ class: TestModel }, { type: '&', guid: bobsEntity.guid || '' });
|
|
235
|
+
expect(testEntityAlice).not.toBeNull();
|
|
236
|
+
expect(testEntityAlice?.guid).toEqual(bobsEntity.guid);
|
|
237
|
+
if (testEntityAlice == null) {
|
|
238
|
+
throw new Error();
|
|
239
|
+
}
|
|
240
|
+
try {
|
|
241
|
+
await testEntityAlice.$delete();
|
|
242
|
+
throw new Error('It should have thrown AccessControlError.');
|
|
243
|
+
}
|
|
244
|
+
catch (e) {
|
|
245
|
+
expect(e).toBeInstanceOf(AccessControlError);
|
|
246
|
+
}
|
|
247
|
+
expect(await testEntityAlice.$refresh()).toEqual(true);
|
|
248
|
+
expect(testEntityAlice.guid).toEqual(bobsEntity.guid);
|
|
249
|
+
});
|
|
250
|
+
it('alice can delete an entity she has full permission for', async () => {
|
|
251
|
+
const { bob, alice } = await makeUsers();
|
|
252
|
+
await tilmeld.fillSession(bob);
|
|
253
|
+
const bobsEntity = await TestModel.factory();
|
|
254
|
+
bobsEntity.name = "Bob's Entity";
|
|
255
|
+
bobsEntity.acFull = [alice];
|
|
256
|
+
expect(await bobsEntity.$save()).toEqual(true);
|
|
257
|
+
expect(bobsEntity.guid).not.toBeNull();
|
|
258
|
+
expect(bob.$is(bobsEntity.user)).toEqual(true);
|
|
259
|
+
const testEntityBob = await nymph.getEntity({ class: TestModel }, { type: '&', guid: bobsEntity.guid || '' });
|
|
260
|
+
expect(testEntityBob).not.toBeNull();
|
|
261
|
+
expect(testEntityBob?.guid).toEqual(bobsEntity.guid);
|
|
262
|
+
tilmeld.clearSession();
|
|
263
|
+
await tilmeld.fillSession(alice);
|
|
264
|
+
const testEntityAlice = await nymph.getEntity({ class: TestModel }, { type: '&', guid: bobsEntity.guid || '' });
|
|
265
|
+
expect(testEntityAlice).not.toBeNull();
|
|
266
|
+
expect(testEntityAlice?.guid).toEqual(bobsEntity.guid);
|
|
267
|
+
if (testEntityAlice == null) {
|
|
268
|
+
throw new Error();
|
|
269
|
+
}
|
|
270
|
+
expect(await testEntityAlice.$delete()).toEqual(true);
|
|
271
|
+
const verifyEntityAlice = await nymph.getEntity({ class: TestModel }, { type: '&', guid: bobsEntity.guid || '' });
|
|
272
|
+
expect(verifyEntityAlice).toBeNull();
|
|
273
|
+
});
|
|
274
|
+
it('alice can access an entity her group has permission for', async () => {
|
|
275
|
+
const { bob, alice, abgroup } = await makeUsers();
|
|
276
|
+
await tilmeld.fillSession(bob);
|
|
277
|
+
const bobsEntity = await TestModel.factory();
|
|
278
|
+
bobsEntity.name = "Bob's Entity";
|
|
279
|
+
bobsEntity.acRead = [abgroup];
|
|
280
|
+
expect(await bobsEntity.$save()).toEqual(true);
|
|
281
|
+
expect(bobsEntity.guid).not.toBeNull();
|
|
282
|
+
expect(bob.$is(bobsEntity.user)).toEqual(true);
|
|
283
|
+
const testEntityBob = await nymph.getEntity({ class: TestModel }, { type: '&', guid: bobsEntity.guid || '' });
|
|
284
|
+
expect(testEntityBob).not.toBeNull();
|
|
285
|
+
expect(testEntityBob?.guid).toEqual(bobsEntity.guid);
|
|
286
|
+
tilmeld.clearSession();
|
|
287
|
+
await tilmeld.fillSession(alice);
|
|
288
|
+
const testEntityAlice = await nymph.getEntity({ class: TestModel }, { type: '&', guid: bobsEntity.guid || '' });
|
|
289
|
+
expect(testEntityAlice).not.toBeNull();
|
|
290
|
+
expect(testEntityAlice?.guid).toEqual(bobsEntity.guid);
|
|
291
|
+
});
|
|
292
|
+
it("alice can't write to an entity her group doesn't have write permission for", async () => {
|
|
293
|
+
const { bob, alice, abgroup } = await makeUsers();
|
|
294
|
+
await tilmeld.fillSession(bob);
|
|
295
|
+
const bobsEntity = await TestModel.factory();
|
|
296
|
+
bobsEntity.name = "Bob's Entity";
|
|
297
|
+
bobsEntity.acRead = [abgroup];
|
|
298
|
+
expect(await bobsEntity.$save()).toEqual(true);
|
|
299
|
+
expect(bobsEntity.guid).not.toBeNull();
|
|
300
|
+
expect(bob.$is(bobsEntity.user)).toEqual(true);
|
|
301
|
+
const testEntityBob = await nymph.getEntity({ class: TestModel }, { type: '&', guid: bobsEntity.guid || '' });
|
|
302
|
+
expect(testEntityBob).not.toBeNull();
|
|
303
|
+
expect(testEntityBob?.guid).toEqual(bobsEntity.guid);
|
|
304
|
+
tilmeld.clearSession();
|
|
305
|
+
await tilmeld.fillSession(alice);
|
|
306
|
+
const testEntityAlice = await nymph.getEntity({ class: TestModel }, { type: '&', guid: bobsEntity.guid || '' });
|
|
307
|
+
expect(testEntityAlice).not.toBeNull();
|
|
308
|
+
expect(testEntityAlice?.guid).toEqual(bobsEntity.guid);
|
|
309
|
+
if (testEntityAlice == null) {
|
|
310
|
+
throw new Error();
|
|
311
|
+
}
|
|
312
|
+
testEntityAlice.name = "Haha! It's mine now!";
|
|
313
|
+
try {
|
|
314
|
+
await testEntityAlice.$save();
|
|
315
|
+
throw new Error('It should have thrown AccessControlError.');
|
|
316
|
+
}
|
|
317
|
+
catch (e) {
|
|
318
|
+
expect(e).toBeInstanceOf(AccessControlError);
|
|
319
|
+
}
|
|
320
|
+
expect(await testEntityAlice.$refresh()).toEqual(true);
|
|
321
|
+
expect(testEntityAlice.name).toEqual("Bob's Entity");
|
|
322
|
+
});
|
|
323
|
+
it('alice can write to an entity her group has write permission for', async () => {
|
|
324
|
+
const { bob, alice, abgroup } = await makeUsers();
|
|
325
|
+
await tilmeld.fillSession(bob);
|
|
326
|
+
const bobsEntity = await TestModel.factory();
|
|
327
|
+
bobsEntity.name = "Bob's Entity";
|
|
328
|
+
bobsEntity.acWrite = [abgroup];
|
|
329
|
+
expect(await bobsEntity.$save()).toEqual(true);
|
|
330
|
+
expect(bobsEntity.guid).not.toBeNull();
|
|
331
|
+
expect(bob.$is(bobsEntity.user)).toEqual(true);
|
|
332
|
+
const testEntityBob = await nymph.getEntity({ class: TestModel }, { type: '&', guid: bobsEntity.guid || '' });
|
|
333
|
+
expect(testEntityBob).not.toBeNull();
|
|
334
|
+
expect(testEntityBob?.guid).toEqual(bobsEntity.guid);
|
|
335
|
+
tilmeld.clearSession();
|
|
336
|
+
await tilmeld.fillSession(alice);
|
|
337
|
+
const testEntityAlice = await nymph.getEntity({ class: TestModel }, { type: '&', guid: bobsEntity.guid || '' });
|
|
338
|
+
expect(testEntityAlice).not.toBeNull();
|
|
339
|
+
expect(testEntityAlice?.guid).toEqual(bobsEntity.guid);
|
|
340
|
+
if (testEntityAlice == null) {
|
|
341
|
+
throw new Error();
|
|
342
|
+
}
|
|
343
|
+
testEntityAlice.name = "Haha! It's mine now!";
|
|
344
|
+
expect(await testEntityAlice.$save()).toEqual(true);
|
|
345
|
+
expect(await testEntityAlice.$refresh()).toEqual(true);
|
|
346
|
+
expect(testEntityAlice.name).toEqual("Haha! It's mine now!");
|
|
347
|
+
});
|
|
348
|
+
it("alice can't delete an entity her group doesn't have full permission for", async () => {
|
|
349
|
+
const { bob, alice, abgroup } = await makeUsers();
|
|
350
|
+
await tilmeld.fillSession(bob);
|
|
351
|
+
const bobsEntity = await TestModel.factory();
|
|
352
|
+
bobsEntity.name = "Bob's Entity";
|
|
353
|
+
bobsEntity.acWrite = [abgroup];
|
|
354
|
+
expect(await bobsEntity.$save()).toEqual(true);
|
|
355
|
+
expect(bobsEntity.guid).not.toBeNull();
|
|
356
|
+
expect(bob.$is(bobsEntity.user)).toEqual(true);
|
|
357
|
+
const testEntityBob = await nymph.getEntity({ class: TestModel }, { type: '&', guid: bobsEntity.guid || '' });
|
|
358
|
+
expect(testEntityBob).not.toBeNull();
|
|
359
|
+
expect(testEntityBob?.guid).toEqual(bobsEntity.guid);
|
|
360
|
+
tilmeld.clearSession();
|
|
361
|
+
await tilmeld.fillSession(alice);
|
|
362
|
+
const testEntityAlice = await nymph.getEntity({ class: TestModel }, { type: '&', guid: bobsEntity.guid || '' });
|
|
363
|
+
expect(testEntityAlice).not.toBeNull();
|
|
364
|
+
expect(testEntityAlice?.guid).toEqual(bobsEntity.guid);
|
|
365
|
+
if (testEntityAlice == null) {
|
|
366
|
+
throw new Error();
|
|
367
|
+
}
|
|
368
|
+
try {
|
|
369
|
+
await testEntityAlice.$delete();
|
|
370
|
+
throw new Error('It should have thrown AccessControlError.');
|
|
371
|
+
}
|
|
372
|
+
catch (e) {
|
|
373
|
+
expect(e).toBeInstanceOf(AccessControlError);
|
|
374
|
+
}
|
|
375
|
+
expect(await testEntityAlice.$refresh()).toEqual(true);
|
|
376
|
+
expect(testEntityAlice.guid).toEqual(bobsEntity.guid);
|
|
377
|
+
});
|
|
378
|
+
it('alice can delete an entity her group has full permission for', async () => {
|
|
379
|
+
const { bob, alice, abgroup } = await makeUsers();
|
|
380
|
+
await tilmeld.fillSession(bob);
|
|
381
|
+
const bobsEntity = await TestModel.factory();
|
|
382
|
+
bobsEntity.name = "Bob's Entity";
|
|
383
|
+
bobsEntity.acFull = [abgroup];
|
|
384
|
+
expect(await bobsEntity.$save()).toEqual(true);
|
|
385
|
+
expect(bobsEntity.guid).not.toBeNull();
|
|
386
|
+
expect(bob.$is(bobsEntity.user)).toEqual(true);
|
|
387
|
+
const testEntityBob = await nymph.getEntity({ class: TestModel }, { type: '&', guid: bobsEntity.guid || '' });
|
|
388
|
+
expect(testEntityBob).not.toBeNull();
|
|
389
|
+
expect(testEntityBob?.guid).toEqual(bobsEntity.guid);
|
|
390
|
+
tilmeld.clearSession();
|
|
391
|
+
await tilmeld.fillSession(alice);
|
|
392
|
+
const testEntityAlice = await nymph.getEntity({ class: TestModel }, { type: '&', guid: bobsEntity.guid || '' });
|
|
393
|
+
expect(testEntityAlice).not.toBeNull();
|
|
394
|
+
expect(testEntityAlice?.guid).toEqual(bobsEntity.guid);
|
|
395
|
+
if (testEntityAlice == null) {
|
|
396
|
+
throw new Error();
|
|
397
|
+
}
|
|
398
|
+
expect(await testEntityAlice.$delete()).toEqual(true);
|
|
399
|
+
const verifyEntityAlice = await nymph.getEntity({ class: TestModel }, { type: '&', guid: bobsEntity.guid || '' });
|
|
400
|
+
expect(verifyEntityAlice).toBeNull();
|
|
401
|
+
});
|
|
402
|
+
it('alice can access an entity her primary group has permission for', async () => {
|
|
403
|
+
const { bob, alice } = await makeUsers();
|
|
404
|
+
await tilmeld.fillSession(bob);
|
|
405
|
+
const bobsEntity = await TestModel.factory();
|
|
406
|
+
bobsEntity.name = "Bob's Entity";
|
|
407
|
+
bobsEntity.group = alice.group;
|
|
408
|
+
expect(await bobsEntity.$save()).toEqual(true);
|
|
409
|
+
expect(bobsEntity.guid).not.toBeNull();
|
|
410
|
+
expect(bob.$is(bobsEntity.user)).toEqual(true);
|
|
411
|
+
const testEntityBob = await nymph.getEntity({ class: TestModel }, { type: '&', guid: bobsEntity.guid || '' });
|
|
412
|
+
expect(testEntityBob).not.toBeNull();
|
|
413
|
+
expect(testEntityBob?.guid).toEqual(bobsEntity.guid);
|
|
414
|
+
tilmeld.clearSession();
|
|
415
|
+
await tilmeld.fillSession(alice);
|
|
416
|
+
const testEntityAlice = await nymph.getEntity({ class: TestModel }, { type: '&', guid: bobsEntity.guid || '' });
|
|
417
|
+
expect(testEntityAlice).not.toBeNull();
|
|
418
|
+
expect(testEntityAlice?.guid).toEqual(bobsEntity.guid);
|
|
419
|
+
});
|
|
420
|
+
it("alice can't write to an entity her primary group doesn't have write permission for", async () => {
|
|
421
|
+
const { bob, alice } = await makeUsers();
|
|
422
|
+
await tilmeld.fillSession(bob);
|
|
423
|
+
const bobsEntity = await TestModel.factory();
|
|
424
|
+
bobsEntity.name = "Bob's Entity";
|
|
425
|
+
bobsEntity.group = alice.group;
|
|
426
|
+
expect(await bobsEntity.$save()).toEqual(true);
|
|
427
|
+
expect(bobsEntity.guid).not.toBeNull();
|
|
428
|
+
expect(bob.$is(bobsEntity.user)).toEqual(true);
|
|
429
|
+
const testEntityBob = await nymph.getEntity({ class: TestModel }, { type: '&', guid: bobsEntity.guid || '' });
|
|
430
|
+
expect(testEntityBob).not.toBeNull();
|
|
431
|
+
expect(testEntityBob?.guid).toEqual(bobsEntity.guid);
|
|
432
|
+
tilmeld.clearSession();
|
|
433
|
+
await tilmeld.fillSession(alice);
|
|
434
|
+
const testEntityAlice = await nymph.getEntity({ class: TestModel }, { type: '&', guid: bobsEntity.guid || '' });
|
|
435
|
+
expect(testEntityAlice).not.toBeNull();
|
|
436
|
+
expect(testEntityAlice?.guid).toEqual(bobsEntity.guid);
|
|
437
|
+
if (testEntityAlice == null) {
|
|
438
|
+
throw new Error();
|
|
439
|
+
}
|
|
440
|
+
testEntityAlice.name = "Haha! It's mine now!";
|
|
441
|
+
try {
|
|
442
|
+
await testEntityAlice.$save();
|
|
443
|
+
throw new Error('It should have thrown AccessControlError.');
|
|
444
|
+
}
|
|
445
|
+
catch (e) {
|
|
446
|
+
expect(e).toBeInstanceOf(AccessControlError);
|
|
447
|
+
}
|
|
448
|
+
expect(await testEntityAlice.$refresh()).toEqual(true);
|
|
449
|
+
expect(testEntityAlice.name).toEqual("Bob's Entity");
|
|
450
|
+
});
|
|
451
|
+
it('alice can write to an entity her primary group has write permission for', async () => {
|
|
452
|
+
const { bob, alice } = await makeUsers();
|
|
453
|
+
await tilmeld.fillSession(bob);
|
|
454
|
+
const bobsEntity = await TestModel.factory();
|
|
455
|
+
bobsEntity.name = "Bob's Entity";
|
|
456
|
+
bobsEntity.group = alice.group;
|
|
457
|
+
bobsEntity.acGroup = TilmeldAccessLevels.WRITE_ACCESS;
|
|
458
|
+
expect(await bobsEntity.$save()).toEqual(true);
|
|
459
|
+
expect(bobsEntity.guid).not.toBeNull();
|
|
460
|
+
expect(bob.$is(bobsEntity.user)).toEqual(true);
|
|
461
|
+
const testEntityBob = await nymph.getEntity({ class: TestModel }, { type: '&', guid: bobsEntity.guid || '' });
|
|
462
|
+
expect(testEntityBob).not.toBeNull();
|
|
463
|
+
expect(testEntityBob?.guid).toEqual(bobsEntity.guid);
|
|
464
|
+
tilmeld.clearSession();
|
|
465
|
+
await tilmeld.fillSession(alice);
|
|
466
|
+
const testEntityAlice = await nymph.getEntity({ class: TestModel }, { type: '&', guid: bobsEntity.guid || '' });
|
|
467
|
+
expect(testEntityAlice).not.toBeNull();
|
|
468
|
+
expect(testEntityAlice?.guid).toEqual(bobsEntity.guid);
|
|
469
|
+
if (testEntityAlice == null) {
|
|
470
|
+
throw new Error();
|
|
471
|
+
}
|
|
472
|
+
testEntityAlice.name = "Haha! It's mine now!";
|
|
473
|
+
expect(await testEntityAlice.$save()).toEqual(true);
|
|
474
|
+
expect(await testEntityAlice.$refresh()).toEqual(true);
|
|
475
|
+
expect(testEntityAlice.name).toEqual("Haha! It's mine now!");
|
|
476
|
+
});
|
|
477
|
+
it("alice can't delete an entity her primary group doesn't have full permission for", async () => {
|
|
478
|
+
const { bob, alice } = await makeUsers();
|
|
479
|
+
await tilmeld.fillSession(bob);
|
|
480
|
+
const bobsEntity = await TestModel.factory();
|
|
481
|
+
bobsEntity.name = "Bob's Entity";
|
|
482
|
+
bobsEntity.group = alice.group;
|
|
483
|
+
bobsEntity.acGroup = TilmeldAccessLevels.WRITE_ACCESS;
|
|
484
|
+
expect(await bobsEntity.$save()).toEqual(true);
|
|
485
|
+
expect(bobsEntity.guid).not.toBeNull();
|
|
486
|
+
expect(bob.$is(bobsEntity.user)).toEqual(true);
|
|
487
|
+
const testEntityBob = await nymph.getEntity({ class: TestModel }, { type: '&', guid: bobsEntity.guid || '' });
|
|
488
|
+
expect(testEntityBob).not.toBeNull();
|
|
489
|
+
expect(testEntityBob?.guid).toEqual(bobsEntity.guid);
|
|
490
|
+
tilmeld.clearSession();
|
|
491
|
+
await tilmeld.fillSession(alice);
|
|
492
|
+
const testEntityAlice = await nymph.getEntity({ class: TestModel }, { type: '&', guid: bobsEntity.guid || '' });
|
|
493
|
+
expect(testEntityAlice).not.toBeNull();
|
|
494
|
+
expect(testEntityAlice?.guid).toEqual(bobsEntity.guid);
|
|
495
|
+
if (testEntityAlice == null) {
|
|
496
|
+
throw new Error();
|
|
497
|
+
}
|
|
498
|
+
try {
|
|
499
|
+
await testEntityAlice.$delete();
|
|
500
|
+
throw new Error('It should have thrown AccessControlError.');
|
|
501
|
+
}
|
|
502
|
+
catch (e) {
|
|
503
|
+
expect(e).toBeInstanceOf(AccessControlError);
|
|
504
|
+
}
|
|
505
|
+
expect(await testEntityAlice.$refresh()).toEqual(true);
|
|
506
|
+
expect(testEntityAlice.guid).toEqual(bobsEntity.guid);
|
|
507
|
+
});
|
|
508
|
+
it('alice can delete an entity her primary group has full permission for', async () => {
|
|
509
|
+
const { bob, alice } = await makeUsers();
|
|
510
|
+
await tilmeld.fillSession(bob);
|
|
511
|
+
const bobsEntity = await TestModel.factory();
|
|
512
|
+
bobsEntity.name = "Bob's Entity";
|
|
513
|
+
bobsEntity.group = alice.group;
|
|
514
|
+
bobsEntity.acGroup = TilmeldAccessLevels.FULL_ACCESS;
|
|
515
|
+
expect(await bobsEntity.$save()).toEqual(true);
|
|
516
|
+
expect(bobsEntity.guid).not.toBeNull();
|
|
517
|
+
expect(bob.$is(bobsEntity.user)).toEqual(true);
|
|
518
|
+
const testEntityBob = await nymph.getEntity({ class: TestModel }, { type: '&', guid: bobsEntity.guid || '' });
|
|
519
|
+
expect(testEntityBob).not.toBeNull();
|
|
520
|
+
expect(testEntityBob?.guid).toEqual(bobsEntity.guid);
|
|
521
|
+
tilmeld.clearSession();
|
|
522
|
+
await tilmeld.fillSession(alice);
|
|
523
|
+
const testEntityAlice = await nymph.getEntity({ class: TestModel }, { type: '&', guid: bobsEntity.guid || '' });
|
|
524
|
+
expect(testEntityAlice).not.toBeNull();
|
|
525
|
+
expect(testEntityAlice?.guid).toEqual(bobsEntity.guid);
|
|
526
|
+
if (testEntityAlice == null) {
|
|
527
|
+
throw new Error();
|
|
528
|
+
}
|
|
529
|
+
expect(await testEntityAlice.$delete()).toEqual(true);
|
|
530
|
+
const verifyEntityAlice = await nymph.getEntity({ class: TestModel }, { type: '&', guid: bobsEntity.guid || '' });
|
|
531
|
+
expect(verifyEntityAlice).toBeNull();
|
|
532
|
+
});
|
|
533
|
+
it('alice can access an entity everyone has permission for', async () => {
|
|
534
|
+
const { bob, alice } = await makeUsers();
|
|
535
|
+
await tilmeld.fillSession(bob);
|
|
536
|
+
const bobsEntity = await TestModel.factory();
|
|
537
|
+
bobsEntity.name = "Bob's Entity";
|
|
538
|
+
bobsEntity.acOther = TilmeldAccessLevels.READ_ACCESS;
|
|
539
|
+
expect(await bobsEntity.$save()).toEqual(true);
|
|
540
|
+
expect(bobsEntity.guid).not.toBeNull();
|
|
541
|
+
expect(bob.$is(bobsEntity.user)).toEqual(true);
|
|
542
|
+
const testEntityBob = await nymph.getEntity({ class: TestModel }, { type: '&', guid: bobsEntity.guid || '' });
|
|
543
|
+
expect(testEntityBob).not.toBeNull();
|
|
544
|
+
expect(testEntityBob?.guid).toEqual(bobsEntity.guid);
|
|
545
|
+
tilmeld.clearSession();
|
|
546
|
+
await tilmeld.fillSession(alice);
|
|
547
|
+
const testEntityAlice = await nymph.getEntity({ class: TestModel }, { type: '&', guid: bobsEntity.guid || '' });
|
|
548
|
+
expect(testEntityAlice).not.toBeNull();
|
|
549
|
+
expect(testEntityAlice?.guid).toEqual(bobsEntity.guid);
|
|
550
|
+
});
|
|
551
|
+
it("alice can't write to an entity everyone doesn't have write permission for", async () => {
|
|
552
|
+
const { bob, alice } = await makeUsers();
|
|
553
|
+
await tilmeld.fillSession(bob);
|
|
554
|
+
const bobsEntity = await TestModel.factory();
|
|
555
|
+
bobsEntity.name = "Bob's Entity";
|
|
556
|
+
bobsEntity.acOther = TilmeldAccessLevels.READ_ACCESS;
|
|
557
|
+
expect(await bobsEntity.$save()).toEqual(true);
|
|
558
|
+
expect(bobsEntity.guid).not.toBeNull();
|
|
559
|
+
expect(bob.$is(bobsEntity.user)).toEqual(true);
|
|
560
|
+
const testEntityBob = await nymph.getEntity({ class: TestModel }, { type: '&', guid: bobsEntity.guid || '' });
|
|
561
|
+
expect(testEntityBob).not.toBeNull();
|
|
562
|
+
expect(testEntityBob?.guid).toEqual(bobsEntity.guid);
|
|
563
|
+
tilmeld.clearSession();
|
|
564
|
+
await tilmeld.fillSession(alice);
|
|
565
|
+
const testEntityAlice = await nymph.getEntity({ class: TestModel }, { type: '&', guid: bobsEntity.guid || '' });
|
|
566
|
+
expect(testEntityAlice).not.toBeNull();
|
|
567
|
+
expect(testEntityAlice?.guid).toEqual(bobsEntity.guid);
|
|
568
|
+
if (testEntityAlice == null) {
|
|
569
|
+
throw new Error();
|
|
570
|
+
}
|
|
571
|
+
testEntityAlice.name = "Haha! It's mine now!";
|
|
572
|
+
try {
|
|
573
|
+
await testEntityAlice.$save();
|
|
574
|
+
throw new Error('It should have thrown AccessControlError.');
|
|
575
|
+
}
|
|
576
|
+
catch (e) {
|
|
577
|
+
expect(e).toBeInstanceOf(AccessControlError);
|
|
578
|
+
}
|
|
579
|
+
expect(await testEntityAlice.$refresh()).toEqual(true);
|
|
580
|
+
expect(testEntityAlice.name).toEqual("Bob's Entity");
|
|
581
|
+
});
|
|
582
|
+
it('alice can write to an entity everyone has write permission for', async () => {
|
|
583
|
+
const { bob, alice } = await makeUsers();
|
|
584
|
+
await tilmeld.fillSession(bob);
|
|
585
|
+
const bobsEntity = await TestModel.factory();
|
|
586
|
+
bobsEntity.name = "Bob's Entity";
|
|
587
|
+
bobsEntity.acOther = TilmeldAccessLevels.WRITE_ACCESS;
|
|
588
|
+
expect(await bobsEntity.$save()).toEqual(true);
|
|
589
|
+
expect(bobsEntity.guid).not.toBeNull();
|
|
590
|
+
expect(bob.$is(bobsEntity.user)).toEqual(true);
|
|
591
|
+
const testEntityBob = await nymph.getEntity({ class: TestModel }, { type: '&', guid: bobsEntity.guid || '' });
|
|
592
|
+
expect(testEntityBob).not.toBeNull();
|
|
593
|
+
expect(testEntityBob?.guid).toEqual(bobsEntity.guid);
|
|
594
|
+
tilmeld.clearSession();
|
|
595
|
+
await tilmeld.fillSession(alice);
|
|
596
|
+
const testEntityAlice = await nymph.getEntity({ class: TestModel }, { type: '&', guid: bobsEntity.guid || '' });
|
|
597
|
+
expect(testEntityAlice).not.toBeNull();
|
|
598
|
+
expect(testEntityAlice?.guid).toEqual(bobsEntity.guid);
|
|
599
|
+
if (testEntityAlice == null) {
|
|
600
|
+
throw new Error();
|
|
601
|
+
}
|
|
602
|
+
testEntityAlice.name = "Haha! It's mine now!";
|
|
603
|
+
expect(await testEntityAlice.$save()).toEqual(true);
|
|
604
|
+
expect(await testEntityAlice.$refresh()).toEqual(true);
|
|
605
|
+
expect(testEntityAlice.name).toEqual("Haha! It's mine now!");
|
|
606
|
+
});
|
|
607
|
+
it("alice can't delete an entity everyone doesn't have full permission for", async () => {
|
|
608
|
+
const { bob, alice } = await makeUsers();
|
|
609
|
+
await tilmeld.fillSession(bob);
|
|
610
|
+
const bobsEntity = await TestModel.factory();
|
|
611
|
+
bobsEntity.name = "Bob's Entity";
|
|
612
|
+
bobsEntity.acOther = TilmeldAccessLevels.WRITE_ACCESS;
|
|
613
|
+
expect(await bobsEntity.$save()).toEqual(true);
|
|
614
|
+
expect(bobsEntity.guid).not.toBeNull();
|
|
615
|
+
expect(bob.$is(bobsEntity.user)).toEqual(true);
|
|
616
|
+
const testEntityBob = await nymph.getEntity({ class: TestModel }, { type: '&', guid: bobsEntity.guid || '' });
|
|
617
|
+
expect(testEntityBob).not.toBeNull();
|
|
618
|
+
expect(testEntityBob?.guid).toEqual(bobsEntity.guid);
|
|
619
|
+
tilmeld.clearSession();
|
|
620
|
+
await tilmeld.fillSession(alice);
|
|
621
|
+
const testEntityAlice = await nymph.getEntity({ class: TestModel }, { type: '&', guid: bobsEntity.guid || '' });
|
|
622
|
+
expect(testEntityAlice).not.toBeNull();
|
|
623
|
+
expect(testEntityAlice?.guid).toEqual(bobsEntity.guid);
|
|
624
|
+
if (testEntityAlice == null) {
|
|
625
|
+
throw new Error();
|
|
626
|
+
}
|
|
627
|
+
try {
|
|
628
|
+
await testEntityAlice.$delete();
|
|
629
|
+
throw new Error('It should have thrown AccessControlError.');
|
|
630
|
+
}
|
|
631
|
+
catch (e) {
|
|
632
|
+
expect(e).toBeInstanceOf(AccessControlError);
|
|
633
|
+
}
|
|
634
|
+
expect(await testEntityAlice.$refresh()).toEqual(true);
|
|
635
|
+
expect(testEntityAlice.guid).toEqual(bobsEntity.guid);
|
|
636
|
+
});
|
|
637
|
+
it('alice can delete an entity everyone has full permission for', async () => {
|
|
638
|
+
const { bob, alice } = await makeUsers();
|
|
639
|
+
await tilmeld.fillSession(bob);
|
|
640
|
+
const bobsEntity = await TestModel.factory();
|
|
641
|
+
bobsEntity.name = "Bob's Entity";
|
|
642
|
+
bobsEntity.acOther = TilmeldAccessLevels.FULL_ACCESS;
|
|
643
|
+
expect(await bobsEntity.$save()).toEqual(true);
|
|
644
|
+
expect(bobsEntity.guid).not.toBeNull();
|
|
645
|
+
expect(bob.$is(bobsEntity.user)).toEqual(true);
|
|
646
|
+
const testEntityBob = await nymph.getEntity({ class: TestModel }, { type: '&', guid: bobsEntity.guid || '' });
|
|
647
|
+
expect(testEntityBob).not.toBeNull();
|
|
648
|
+
expect(testEntityBob?.guid).toEqual(bobsEntity.guid);
|
|
649
|
+
tilmeld.clearSession();
|
|
650
|
+
await tilmeld.fillSession(alice);
|
|
651
|
+
const testEntityAlice = await nymph.getEntity({ class: TestModel }, { type: '&', guid: bobsEntity.guid || '' });
|
|
652
|
+
expect(testEntityAlice).not.toBeNull();
|
|
653
|
+
expect(testEntityAlice?.guid).toEqual(bobsEntity.guid);
|
|
654
|
+
if (testEntityAlice == null) {
|
|
655
|
+
throw new Error();
|
|
656
|
+
}
|
|
657
|
+
expect(await testEntityAlice.$delete()).toEqual(true);
|
|
658
|
+
const verifyEntityAlice = await nymph.getEntity({ class: TestModel }, { type: '&', guid: bobsEntity.guid || '' });
|
|
659
|
+
expect(verifyEntityAlice).toBeNull();
|
|
660
|
+
});
|
|
661
|
+
it('a clear session can delete an entity everyone has full permission for', async () => {
|
|
662
|
+
const { bob } = await makeUsers();
|
|
663
|
+
await tilmeld.fillSession(bob);
|
|
664
|
+
const bobsEntity = await TestModel.factory();
|
|
665
|
+
bobsEntity.name = "Bob's Entity";
|
|
666
|
+
bobsEntity.acOther = TilmeldAccessLevels.FULL_ACCESS;
|
|
667
|
+
expect(await bobsEntity.$save()).toEqual(true);
|
|
668
|
+
expect(bobsEntity.guid).not.toBeNull();
|
|
669
|
+
expect(bob.$is(bobsEntity.user)).toEqual(true);
|
|
670
|
+
const testEntityBob = await nymph.getEntity({ class: TestModel }, { type: '&', guid: bobsEntity.guid || '' });
|
|
671
|
+
expect(testEntityBob).not.toBeNull();
|
|
672
|
+
expect(testEntityBob?.guid).toEqual(bobsEntity.guid);
|
|
673
|
+
tilmeld.clearSession();
|
|
674
|
+
const testEntityNobody = await nymph.getEntity({ class: TestModel }, { type: '&', guid: bobsEntity.guid || '' });
|
|
675
|
+
expect(testEntityNobody).not.toBeNull();
|
|
676
|
+
expect(testEntityNobody?.guid).toEqual(bobsEntity.guid);
|
|
677
|
+
if (testEntityNobody == null) {
|
|
678
|
+
throw new Error();
|
|
679
|
+
}
|
|
680
|
+
expect(await testEntityNobody.$delete()).toEqual(true);
|
|
681
|
+
const verifyEntityNobody = await nymph.getEntity({ class: TestModel }, { type: '&', guid: bobsEntity.guid || '' });
|
|
682
|
+
expect(verifyEntityNobody).toBeNull();
|
|
683
|
+
});
|
|
684
|
+
it('allows skip ac deletions', async () => {
|
|
685
|
+
const allEntities = [
|
|
686
|
+
...(await nymph.getEntities({ class: TestModel, skipAc: true })),
|
|
687
|
+
...(await nymph.getEntities({ class: User, skipAc: true })),
|
|
688
|
+
...(await nymph.getEntities({ class: Group, skipAc: true })),
|
|
689
|
+
];
|
|
690
|
+
for (let entity of allEntities) {
|
|
691
|
+
expect(await entity.$deleteSkipAC()).toEqual(true);
|
|
692
|
+
}
|
|
693
|
+
});
|
|
694
|
+
}
|
|
695
|
+
//# sourceMappingURL=testArtifacts.js.map
|