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