orc-shared 1.2.0-dev.2 → 1.2.0-dev.6
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/dist/actions/modules.js +63 -1
- package/dist/actions/scopes.js +59 -22
- package/dist/components/AppFrame/MenuItem.js +5 -14
- package/dist/components/AppFrame/Sidebar.js +11 -5
- package/dist/components/ApplicationModuleLoader.js +143 -0
- package/dist/components/Authenticate.js +12 -12
- package/dist/components/MaterialUI/DataDisplay/SelectionList.js +1 -1
- package/dist/components/MaterialUI/Navigation/ExternalLink.js +113 -0
- package/dist/components/MaterialUI/muiThemes.js +5 -0
- package/dist/components/Modules.js +126 -41
- package/dist/components/Routing/FullPage.js +3 -1
- package/dist/components/Routing/Page.js +5 -3
- package/dist/components/Routing/Segment.js +1 -1
- package/dist/components/Routing/withWaypointing.js +6 -2
- package/dist/components/Scope/useScopeConfirmationModalState.js +7 -16
- package/dist/components/Scope/useScopeData.js +4 -13
- package/dist/constants.js +19 -2
- package/dist/content/iconsSheet.svg +3 -0
- package/dist/reducers/modules.js +39 -1
- package/dist/reducers/scopes.js +27 -0
- package/dist/reducers/settings.js +31 -2
- package/dist/selectors/authentication.js +57 -18
- package/dist/selectors/modules.js +15 -1
- package/dist/selectors/scope.js +7 -1
- package/dist/selectors/settings.js +13 -1
- package/package.json +6 -5
- package/src/actions/modules.js +30 -0
- package/src/actions/modules.test.js +50 -1
- package/src/actions/scopes.js +33 -7
- package/src/actions/scopes.test.js +84 -14
- package/src/components/AppFrame/AppFrame.test.js +9 -0
- package/src/components/AppFrame/MenuItem.js +3 -5
- package/src/components/AppFrame/MenuItem.test.js +2 -24
- package/src/components/AppFrame/Sidebar.js +8 -1
- package/src/components/AppFrame/Sidebar.test.js +18 -0
- package/src/components/ApplicationModuleLoader.js +52 -0
- package/src/components/ApplicationModuleLoader.test.js +149 -0
- package/src/components/Authenticate.js +5 -4
- package/src/components/Authenticate.test.js +23 -4
- package/src/components/MaterialUI/DataDisplay/SelectionList.js +1 -1
- package/src/components/MaterialUI/DataDisplay/SelectionList.test.js +2 -2
- package/src/components/MaterialUI/Navigation/ExternalLink.js +25 -0
- package/src/components/MaterialUI/Navigation/ExternalLink.test.js +26 -0
- package/src/components/MaterialUI/muiThemes.js +5 -0
- package/src/components/Modules.js +103 -20
- package/src/components/Modules.test.js +315 -28
- package/src/components/Provision.test.js +34 -0
- package/src/components/Routing/FullPage.js +2 -1
- package/src/components/Routing/FullPage.test.js +23 -0
- package/src/components/Routing/Page.js +2 -2
- package/src/components/Routing/Page.test.js +20 -0
- package/src/components/Routing/Segment.js +1 -1
- package/src/components/Routing/withWaypointing.js +2 -2
- package/src/components/Routing/withWaypointing.test.js +33 -5
- package/src/components/Scope/useScopeConfirmationModalState.js +5 -16
- package/src/components/Scope/useScopeConfirmationModalState.test.js +39 -13
- package/src/components/Scope/useScopeData.js +0 -3
- package/src/components/Scope/useScopeData.test.js +0 -27
- package/src/constants.js +15 -0
- package/src/content/iconsSheet.svg +3 -0
- package/src/hocs/withScopeData.test.js +0 -31
- package/src/reducers/modules.js +48 -2
- package/src/reducers/modules.test.js +117 -2
- package/src/reducers/scopes.js +30 -0
- package/src/reducers/scopes.test.js +45 -1
- package/src/reducers/settings.js +26 -2
- package/src/reducers/settings.test.js +74 -6
- package/src/selectors/authentication.js +53 -27
- package/src/selectors/authentication.test.js +600 -12
- package/src/selectors/modules.js +7 -0
- package/src/selectors/modules.test.js +16 -1
- package/src/selectors/scope.js +2 -0
- package/src/selectors/scope.test.js +5 -0
- package/src/selectors/settings.js +6 -0
|
@@ -6,8 +6,47 @@ import {
|
|
|
6
6
|
hasEditorPermissions,
|
|
7
7
|
hasAdministratorPermissions,
|
|
8
8
|
hasReaderPermissions,
|
|
9
|
+
hasEditorPermissionsForScope,
|
|
10
|
+
hasAdministratorPermissionsForScope,
|
|
11
|
+
hasReaderPermissionsForScope,
|
|
9
12
|
} from "./authentication";
|
|
10
13
|
|
|
14
|
+
const state = {
|
|
15
|
+
navigation: {
|
|
16
|
+
route: { location: {}, match: { params: { scope: "Global" } } },
|
|
17
|
+
},
|
|
18
|
+
settings: { defaultScope: "Global" },
|
|
19
|
+
locale: {
|
|
20
|
+
locale: "fr",
|
|
21
|
+
supportedLocales: ["en", "fr"],
|
|
22
|
+
},
|
|
23
|
+
scopes: {
|
|
24
|
+
Global: {
|
|
25
|
+
name: { en: "Global", fr: "Global" },
|
|
26
|
+
id: "Global",
|
|
27
|
+
children: ["MyScope"],
|
|
28
|
+
currency: {
|
|
29
|
+
displayName: {
|
|
30
|
+
en: "Euro",
|
|
31
|
+
fr: "Euro",
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
defaultCulture: "en-US",
|
|
35
|
+
},
|
|
36
|
+
MyScope: {
|
|
37
|
+
name: { en: "First child", fr: "Premier fils" },
|
|
38
|
+
id: "FirstChild",
|
|
39
|
+
children: ["ChildScope"],
|
|
40
|
+
parentScopeId: "Global",
|
|
41
|
+
},
|
|
42
|
+
ChildScope: {
|
|
43
|
+
name: { en: "First grandchild", fr: "Premier petit-fils" },
|
|
44
|
+
id: "FirstGrandchild",
|
|
45
|
+
parentScopeId: "MyScope",
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
};
|
|
49
|
+
|
|
11
50
|
describe("selectCurrentUsername", () => {
|
|
12
51
|
it("Gets the logged in username", () =>
|
|
13
52
|
expect(
|
|
@@ -142,10 +181,7 @@ describe("hasEditorPermissions", () => {
|
|
|
142
181
|
[
|
|
143
182
|
Immutable.fromJS({
|
|
144
183
|
authentication: { rolesClaimsValues: claims },
|
|
145
|
-
|
|
146
|
-
route: { location: {}, match: { params: { scope: "Global" } } },
|
|
147
|
-
},
|
|
148
|
-
settings: { defaultScope: "Global" },
|
|
184
|
+
...state,
|
|
149
185
|
}),
|
|
150
186
|
],
|
|
151
187
|
"to equal",
|
|
@@ -212,6 +248,34 @@ describe("hasEditorPermissions", () => {
|
|
|
212
248
|
);
|
|
213
249
|
});
|
|
214
250
|
|
|
251
|
+
it("Retrieves true if user has editor permissions just in specified scope with permission on parents", () => {
|
|
252
|
+
const claims = Immutable.fromJS({
|
|
253
|
+
Orders: {
|
|
254
|
+
MyScope: {
|
|
255
|
+
Editor: true,
|
|
256
|
+
},
|
|
257
|
+
},
|
|
258
|
+
});
|
|
259
|
+
|
|
260
|
+
expect(
|
|
261
|
+
hasEditorPermissions,
|
|
262
|
+
"when called with",
|
|
263
|
+
["Orders"],
|
|
264
|
+
"called with",
|
|
265
|
+
[
|
|
266
|
+
Immutable.fromJS({
|
|
267
|
+
authentication: { rolesClaimsValues: claims },
|
|
268
|
+
...state,
|
|
269
|
+
navigation: {
|
|
270
|
+
route: { location: {}, match: { params: { scope: "ChildScope" } } },
|
|
271
|
+
},
|
|
272
|
+
}),
|
|
273
|
+
],
|
|
274
|
+
"to equal",
|
|
275
|
+
true,
|
|
276
|
+
);
|
|
277
|
+
});
|
|
278
|
+
|
|
215
279
|
it("Retrieves false if app roles claims are null", () => {
|
|
216
280
|
expect(
|
|
217
281
|
hasEditorPermissions,
|
|
@@ -233,6 +297,164 @@ describe("hasEditorPermissions", () => {
|
|
|
233
297
|
});
|
|
234
298
|
});
|
|
235
299
|
|
|
300
|
+
describe("hasEditorPermissionsForScope", () => {
|
|
301
|
+
it("Retrieves true if user has editor permissions in specified group", () => {
|
|
302
|
+
const claims = Immutable.fromJS({
|
|
303
|
+
Orders: {
|
|
304
|
+
"*": {
|
|
305
|
+
Editor: true,
|
|
306
|
+
},
|
|
307
|
+
},
|
|
308
|
+
});
|
|
309
|
+
|
|
310
|
+
expect(
|
|
311
|
+
hasEditorPermissionsForScope,
|
|
312
|
+
"when called with",
|
|
313
|
+
["Global", "Orders"],
|
|
314
|
+
"called with",
|
|
315
|
+
[
|
|
316
|
+
Immutable.fromJS({
|
|
317
|
+
authentication: { rolesClaimsValues: claims },
|
|
318
|
+
}),
|
|
319
|
+
],
|
|
320
|
+
"to equal",
|
|
321
|
+
true,
|
|
322
|
+
);
|
|
323
|
+
});
|
|
324
|
+
|
|
325
|
+
it("Retrieves false if user has not editor permissions in specified group", () => {
|
|
326
|
+
const claims = Immutable.fromJS({
|
|
327
|
+
Orders: {
|
|
328
|
+
"*": {
|
|
329
|
+
Editor: false,
|
|
330
|
+
},
|
|
331
|
+
},
|
|
332
|
+
});
|
|
333
|
+
|
|
334
|
+
expect(
|
|
335
|
+
hasEditorPermissionsForScope,
|
|
336
|
+
"when called with",
|
|
337
|
+
["Global", "Orders"],
|
|
338
|
+
"called with",
|
|
339
|
+
[
|
|
340
|
+
Immutable.fromJS({
|
|
341
|
+
authentication: { rolesClaimsValues: claims },
|
|
342
|
+
...state,
|
|
343
|
+
}),
|
|
344
|
+
],
|
|
345
|
+
"to equal",
|
|
346
|
+
false,
|
|
347
|
+
);
|
|
348
|
+
});
|
|
349
|
+
|
|
350
|
+
it("Retrieves true if user hasn't global editor permissions but, has in current scope in specified group", () => {
|
|
351
|
+
const claims = Immutable.fromJS({
|
|
352
|
+
Orders: {
|
|
353
|
+
"*": {
|
|
354
|
+
Editor: false,
|
|
355
|
+
},
|
|
356
|
+
MyScope: {
|
|
357
|
+
Editor: true,
|
|
358
|
+
},
|
|
359
|
+
},
|
|
360
|
+
});
|
|
361
|
+
|
|
362
|
+
expect(
|
|
363
|
+
hasEditorPermissionsForScope,
|
|
364
|
+
"when called with",
|
|
365
|
+
["MyScope", "Orders"],
|
|
366
|
+
"called with",
|
|
367
|
+
[
|
|
368
|
+
Immutable.fromJS({
|
|
369
|
+
authentication: { rolesClaimsValues: claims },
|
|
370
|
+
navigation: {
|
|
371
|
+
route: { location: {}, match: { params: { scope: "MyScope" } } },
|
|
372
|
+
},
|
|
373
|
+
settings: { defaultScope: "Global" },
|
|
374
|
+
}),
|
|
375
|
+
],
|
|
376
|
+
"to equal",
|
|
377
|
+
true,
|
|
378
|
+
);
|
|
379
|
+
});
|
|
380
|
+
|
|
381
|
+
it("Retrieves true if user has editor permissions just in specified scope", () => {
|
|
382
|
+
const claims = Immutable.fromJS({
|
|
383
|
+
Orders: {
|
|
384
|
+
MyScope: {
|
|
385
|
+
Editor: true,
|
|
386
|
+
},
|
|
387
|
+
},
|
|
388
|
+
});
|
|
389
|
+
|
|
390
|
+
expect(
|
|
391
|
+
hasEditorPermissionsForScope,
|
|
392
|
+
"when called with",
|
|
393
|
+
["MyScope", "Orders"],
|
|
394
|
+
"called with",
|
|
395
|
+
[
|
|
396
|
+
Immutable.fromJS({
|
|
397
|
+
authentication: { rolesClaimsValues: claims },
|
|
398
|
+
navigation: {
|
|
399
|
+
route: { location: {}, match: { params: { scope: "MyScope" } } },
|
|
400
|
+
},
|
|
401
|
+
settings: { defaultScope: "Global" },
|
|
402
|
+
}),
|
|
403
|
+
],
|
|
404
|
+
"to equal",
|
|
405
|
+
true,
|
|
406
|
+
);
|
|
407
|
+
});
|
|
408
|
+
|
|
409
|
+
it("Retrieves true if user has editor permissions just in specified scope with permission on parents", () => {
|
|
410
|
+
const claims = Immutable.fromJS({
|
|
411
|
+
Orders: {
|
|
412
|
+
MyScope: {
|
|
413
|
+
Editor: true,
|
|
414
|
+
},
|
|
415
|
+
},
|
|
416
|
+
});
|
|
417
|
+
|
|
418
|
+
expect(
|
|
419
|
+
hasEditorPermissionsForScope,
|
|
420
|
+
"when called with",
|
|
421
|
+
["ChildScope", "Orders"],
|
|
422
|
+
"called with",
|
|
423
|
+
[
|
|
424
|
+
Immutable.fromJS({
|
|
425
|
+
authentication: { rolesClaimsValues: claims },
|
|
426
|
+
...state,
|
|
427
|
+
navigation: {
|
|
428
|
+
route: { location: {}, match: { params: { scope: "ChildScope" } } },
|
|
429
|
+
},
|
|
430
|
+
}),
|
|
431
|
+
],
|
|
432
|
+
"to equal",
|
|
433
|
+
true,
|
|
434
|
+
);
|
|
435
|
+
});
|
|
436
|
+
|
|
437
|
+
it("Retrieves false if app roles claims are null", () => {
|
|
438
|
+
expect(
|
|
439
|
+
hasEditorPermissionsForScope,
|
|
440
|
+
"when called with",
|
|
441
|
+
["Global", "Orders"],
|
|
442
|
+
"called with",
|
|
443
|
+
[
|
|
444
|
+
Immutable.fromJS({
|
|
445
|
+
authentication: { rolesClaimsValues: {} },
|
|
446
|
+
navigation: {
|
|
447
|
+
route: { location: {}, match: { params: { scope: "Global" } } },
|
|
448
|
+
},
|
|
449
|
+
settings: { defaultScope: "Global" },
|
|
450
|
+
}),
|
|
451
|
+
],
|
|
452
|
+
"to equal",
|
|
453
|
+
false,
|
|
454
|
+
);
|
|
455
|
+
});
|
|
456
|
+
});
|
|
457
|
+
|
|
236
458
|
describe("hasAdministratorPermissions", () => {
|
|
237
459
|
it("Retrieves true if user has global administrator permissions in specified group", () => {
|
|
238
460
|
const claims = Immutable.fromJS({
|
|
@@ -279,10 +501,7 @@ describe("hasAdministratorPermissions", () => {
|
|
|
279
501
|
[
|
|
280
502
|
Immutable.fromJS({
|
|
281
503
|
authentication: { rolesClaimsValues: claims },
|
|
282
|
-
|
|
283
|
-
route: { location: {}, match: { params: { scope: "Global" } } },
|
|
284
|
-
},
|
|
285
|
-
settings: { defaultScope: "Global" },
|
|
504
|
+
...state,
|
|
286
505
|
}),
|
|
287
506
|
],
|
|
288
507
|
"to equal",
|
|
@@ -349,6 +568,34 @@ describe("hasAdministratorPermissions", () => {
|
|
|
349
568
|
);
|
|
350
569
|
});
|
|
351
570
|
|
|
571
|
+
it("Retrieves true if user has administrator permissions just in specified scope with permission on parents", () => {
|
|
572
|
+
const claims = Immutable.fromJS({
|
|
573
|
+
Orders: {
|
|
574
|
+
MyScope: {
|
|
575
|
+
Administrator: true,
|
|
576
|
+
},
|
|
577
|
+
},
|
|
578
|
+
});
|
|
579
|
+
|
|
580
|
+
expect(
|
|
581
|
+
hasAdministratorPermissions,
|
|
582
|
+
"when called with",
|
|
583
|
+
["Orders"],
|
|
584
|
+
"called with",
|
|
585
|
+
[
|
|
586
|
+
Immutable.fromJS({
|
|
587
|
+
authentication: { rolesClaimsValues: claims },
|
|
588
|
+
...state,
|
|
589
|
+
navigation: {
|
|
590
|
+
route: { location: {}, match: { params: { scope: "ChildScope" } } },
|
|
591
|
+
},
|
|
592
|
+
}),
|
|
593
|
+
],
|
|
594
|
+
"to equal",
|
|
595
|
+
true,
|
|
596
|
+
);
|
|
597
|
+
});
|
|
598
|
+
|
|
352
599
|
it("Retrieves false if app roles claims are null", () => {
|
|
353
600
|
expect(
|
|
354
601
|
hasAdministratorPermissions,
|
|
@@ -370,6 +617,164 @@ describe("hasAdministratorPermissions", () => {
|
|
|
370
617
|
});
|
|
371
618
|
});
|
|
372
619
|
|
|
620
|
+
describe("hasAdministratorPermissionsForScope", () => {
|
|
621
|
+
it("Retrieves true if user has administrator permissions in specified group", () => {
|
|
622
|
+
const claims = Immutable.fromJS({
|
|
623
|
+
Orders: {
|
|
624
|
+
"*": {
|
|
625
|
+
Administrator: true,
|
|
626
|
+
},
|
|
627
|
+
},
|
|
628
|
+
});
|
|
629
|
+
|
|
630
|
+
expect(
|
|
631
|
+
hasAdministratorPermissionsForScope,
|
|
632
|
+
"when called with",
|
|
633
|
+
["Global", "Orders"],
|
|
634
|
+
"called with",
|
|
635
|
+
[
|
|
636
|
+
Immutable.fromJS({
|
|
637
|
+
authentication: { rolesClaimsValues: claims },
|
|
638
|
+
}),
|
|
639
|
+
],
|
|
640
|
+
"to equal",
|
|
641
|
+
true,
|
|
642
|
+
);
|
|
643
|
+
});
|
|
644
|
+
|
|
645
|
+
it("Retrieves false if user has not administrator permissions in specified group", () => {
|
|
646
|
+
const claims = Immutable.fromJS({
|
|
647
|
+
Orders: {
|
|
648
|
+
"*": {
|
|
649
|
+
Administrator: false,
|
|
650
|
+
},
|
|
651
|
+
},
|
|
652
|
+
});
|
|
653
|
+
|
|
654
|
+
expect(
|
|
655
|
+
hasAdministratorPermissionsForScope,
|
|
656
|
+
"when called with",
|
|
657
|
+
["Global", "Orders"],
|
|
658
|
+
"called with",
|
|
659
|
+
[
|
|
660
|
+
Immutable.fromJS({
|
|
661
|
+
authentication: { rolesClaimsValues: claims },
|
|
662
|
+
...state,
|
|
663
|
+
}),
|
|
664
|
+
],
|
|
665
|
+
"to equal",
|
|
666
|
+
false,
|
|
667
|
+
);
|
|
668
|
+
});
|
|
669
|
+
|
|
670
|
+
it("Retrieves true if user hasn't global administrator permissions but, has in current scope in specified group", () => {
|
|
671
|
+
const claims = Immutable.fromJS({
|
|
672
|
+
Orders: {
|
|
673
|
+
"*": {
|
|
674
|
+
Administrator: false,
|
|
675
|
+
},
|
|
676
|
+
MyScope: {
|
|
677
|
+
Administrator: true,
|
|
678
|
+
},
|
|
679
|
+
},
|
|
680
|
+
});
|
|
681
|
+
|
|
682
|
+
expect(
|
|
683
|
+
hasAdministratorPermissionsForScope,
|
|
684
|
+
"when called with",
|
|
685
|
+
["MyScope", "Orders"],
|
|
686
|
+
"called with",
|
|
687
|
+
[
|
|
688
|
+
Immutable.fromJS({
|
|
689
|
+
authentication: { rolesClaimsValues: claims },
|
|
690
|
+
navigation: {
|
|
691
|
+
route: { location: {}, match: { params: { scope: "MyScope" } } },
|
|
692
|
+
},
|
|
693
|
+
settings: { defaultScope: "Global" },
|
|
694
|
+
}),
|
|
695
|
+
],
|
|
696
|
+
"to equal",
|
|
697
|
+
true,
|
|
698
|
+
);
|
|
699
|
+
});
|
|
700
|
+
|
|
701
|
+
it("Retrieves true if user has administrator permissions just in specified scope", () => {
|
|
702
|
+
const claims = Immutable.fromJS({
|
|
703
|
+
Orders: {
|
|
704
|
+
MyScope: {
|
|
705
|
+
Administrator: true,
|
|
706
|
+
},
|
|
707
|
+
},
|
|
708
|
+
});
|
|
709
|
+
|
|
710
|
+
expect(
|
|
711
|
+
hasAdministratorPermissionsForScope,
|
|
712
|
+
"when called with",
|
|
713
|
+
["MyScope", "Orders"],
|
|
714
|
+
"called with",
|
|
715
|
+
[
|
|
716
|
+
Immutable.fromJS({
|
|
717
|
+
authentication: { rolesClaimsValues: claims },
|
|
718
|
+
navigation: {
|
|
719
|
+
route: { location: {}, match: { params: { scope: "MyScope" } } },
|
|
720
|
+
},
|
|
721
|
+
settings: { defaultScope: "Global" },
|
|
722
|
+
}),
|
|
723
|
+
],
|
|
724
|
+
"to equal",
|
|
725
|
+
true,
|
|
726
|
+
);
|
|
727
|
+
});
|
|
728
|
+
|
|
729
|
+
it("Retrieves true if user has administrator permissions just in specified scope with permission on parents", () => {
|
|
730
|
+
const claims = Immutable.fromJS({
|
|
731
|
+
Orders: {
|
|
732
|
+
MyScope: {
|
|
733
|
+
Administrator: true,
|
|
734
|
+
},
|
|
735
|
+
},
|
|
736
|
+
});
|
|
737
|
+
|
|
738
|
+
expect(
|
|
739
|
+
hasAdministratorPermissionsForScope,
|
|
740
|
+
"when called with",
|
|
741
|
+
["ChildScope", "Orders"],
|
|
742
|
+
"called with",
|
|
743
|
+
[
|
|
744
|
+
Immutable.fromJS({
|
|
745
|
+
authentication: { rolesClaimsValues: claims },
|
|
746
|
+
...state,
|
|
747
|
+
navigation: {
|
|
748
|
+
route: { location: {}, match: { params: { scope: "ChildScope" } } },
|
|
749
|
+
},
|
|
750
|
+
}),
|
|
751
|
+
],
|
|
752
|
+
"to equal",
|
|
753
|
+
true,
|
|
754
|
+
);
|
|
755
|
+
});
|
|
756
|
+
|
|
757
|
+
it("Retrieves false if app roles claims are null", () => {
|
|
758
|
+
expect(
|
|
759
|
+
hasAdministratorPermissionsForScope,
|
|
760
|
+
"when called with",
|
|
761
|
+
["Global", "Orders"],
|
|
762
|
+
"called with",
|
|
763
|
+
[
|
|
764
|
+
Immutable.fromJS({
|
|
765
|
+
authentication: { rolesClaimsValues: {} },
|
|
766
|
+
navigation: {
|
|
767
|
+
route: { location: {}, match: { params: { scope: "Global" } } },
|
|
768
|
+
},
|
|
769
|
+
settings: { defaultScope: "Global" },
|
|
770
|
+
}),
|
|
771
|
+
],
|
|
772
|
+
"to equal",
|
|
773
|
+
false,
|
|
774
|
+
);
|
|
775
|
+
});
|
|
776
|
+
});
|
|
777
|
+
|
|
373
778
|
describe("hasReaderPermissions", () => {
|
|
374
779
|
it("Retrieves true if user has reader permissions in specified group", () => {
|
|
375
780
|
const claims = Immutable.fromJS({
|
|
@@ -416,10 +821,7 @@ describe("hasReaderPermissions", () => {
|
|
|
416
821
|
[
|
|
417
822
|
Immutable.fromJS({
|
|
418
823
|
authentication: { rolesClaimsValues: claims },
|
|
419
|
-
|
|
420
|
-
route: { location: {}, match: { params: { scope: "Global" } } },
|
|
421
|
-
},
|
|
422
|
-
settings: { defaultScope: "Global" },
|
|
824
|
+
...state,
|
|
423
825
|
}),
|
|
424
826
|
],
|
|
425
827
|
"to equal",
|
|
@@ -486,6 +888,34 @@ describe("hasReaderPermissions", () => {
|
|
|
486
888
|
);
|
|
487
889
|
});
|
|
488
890
|
|
|
891
|
+
it("Retrieves true if user has reader permissions just in specified scope with permission on parents", () => {
|
|
892
|
+
const claims = Immutable.fromJS({
|
|
893
|
+
Orders: {
|
|
894
|
+
MyScope: {
|
|
895
|
+
Reader: true,
|
|
896
|
+
},
|
|
897
|
+
},
|
|
898
|
+
});
|
|
899
|
+
|
|
900
|
+
expect(
|
|
901
|
+
hasReaderPermissions,
|
|
902
|
+
"when called with",
|
|
903
|
+
["Orders"],
|
|
904
|
+
"called with",
|
|
905
|
+
[
|
|
906
|
+
Immutable.fromJS({
|
|
907
|
+
authentication: { rolesClaimsValues: claims },
|
|
908
|
+
...state,
|
|
909
|
+
navigation: {
|
|
910
|
+
route: { location: {}, match: { params: { scope: "ChildScope" } } },
|
|
911
|
+
},
|
|
912
|
+
}),
|
|
913
|
+
],
|
|
914
|
+
"to equal",
|
|
915
|
+
true,
|
|
916
|
+
);
|
|
917
|
+
});
|
|
918
|
+
|
|
489
919
|
it("Retrieves false if app roles claims are null", () => {
|
|
490
920
|
expect(
|
|
491
921
|
hasReaderPermissions,
|
|
@@ -506,3 +936,161 @@ describe("hasReaderPermissions", () => {
|
|
|
506
936
|
);
|
|
507
937
|
});
|
|
508
938
|
});
|
|
939
|
+
|
|
940
|
+
describe("hasReaderPermissionsForScope", () => {
|
|
941
|
+
it("Retrieves true if user has administrator permissions in specified group", () => {
|
|
942
|
+
const claims = Immutable.fromJS({
|
|
943
|
+
Orders: {
|
|
944
|
+
"*": {
|
|
945
|
+
Reader: true,
|
|
946
|
+
},
|
|
947
|
+
},
|
|
948
|
+
});
|
|
949
|
+
|
|
950
|
+
expect(
|
|
951
|
+
hasReaderPermissionsForScope,
|
|
952
|
+
"when called with",
|
|
953
|
+
["Global", "Orders"],
|
|
954
|
+
"called with",
|
|
955
|
+
[
|
|
956
|
+
Immutable.fromJS({
|
|
957
|
+
authentication: { rolesClaimsValues: claims },
|
|
958
|
+
}),
|
|
959
|
+
],
|
|
960
|
+
"to equal",
|
|
961
|
+
true,
|
|
962
|
+
);
|
|
963
|
+
});
|
|
964
|
+
|
|
965
|
+
it("Retrieves false if user has not administrator permissions in specified group", () => {
|
|
966
|
+
const claims = Immutable.fromJS({
|
|
967
|
+
Orders: {
|
|
968
|
+
"*": {
|
|
969
|
+
Reader: false,
|
|
970
|
+
},
|
|
971
|
+
},
|
|
972
|
+
});
|
|
973
|
+
|
|
974
|
+
expect(
|
|
975
|
+
hasReaderPermissionsForScope,
|
|
976
|
+
"when called with",
|
|
977
|
+
["Global", "Orders"],
|
|
978
|
+
"called with",
|
|
979
|
+
[
|
|
980
|
+
Immutable.fromJS({
|
|
981
|
+
authentication: { rolesClaimsValues: claims },
|
|
982
|
+
...state,
|
|
983
|
+
}),
|
|
984
|
+
],
|
|
985
|
+
"to equal",
|
|
986
|
+
false,
|
|
987
|
+
);
|
|
988
|
+
});
|
|
989
|
+
|
|
990
|
+
it("Retrieves true if user hasn't global administrator permissions but, has in current scope in specified group", () => {
|
|
991
|
+
const claims = Immutable.fromJS({
|
|
992
|
+
Orders: {
|
|
993
|
+
"*": {
|
|
994
|
+
Reader: false,
|
|
995
|
+
},
|
|
996
|
+
MyScope: {
|
|
997
|
+
Reader: true,
|
|
998
|
+
},
|
|
999
|
+
},
|
|
1000
|
+
});
|
|
1001
|
+
|
|
1002
|
+
expect(
|
|
1003
|
+
hasReaderPermissionsForScope,
|
|
1004
|
+
"when called with",
|
|
1005
|
+
["MyScope", "Orders"],
|
|
1006
|
+
"called with",
|
|
1007
|
+
[
|
|
1008
|
+
Immutable.fromJS({
|
|
1009
|
+
authentication: { rolesClaimsValues: claims },
|
|
1010
|
+
navigation: {
|
|
1011
|
+
route: { location: {}, match: { params: { scope: "MyScope" } } },
|
|
1012
|
+
},
|
|
1013
|
+
settings: { defaultScope: "Global" },
|
|
1014
|
+
}),
|
|
1015
|
+
],
|
|
1016
|
+
"to equal",
|
|
1017
|
+
true,
|
|
1018
|
+
);
|
|
1019
|
+
});
|
|
1020
|
+
|
|
1021
|
+
it("Retrieves true if user has administrator permissions just in specified scope", () => {
|
|
1022
|
+
const claims = Immutable.fromJS({
|
|
1023
|
+
Orders: {
|
|
1024
|
+
MyScope: {
|
|
1025
|
+
Reader: true,
|
|
1026
|
+
},
|
|
1027
|
+
},
|
|
1028
|
+
});
|
|
1029
|
+
|
|
1030
|
+
expect(
|
|
1031
|
+
hasReaderPermissionsForScope,
|
|
1032
|
+
"when called with",
|
|
1033
|
+
["MyScope", "Orders"],
|
|
1034
|
+
"called with",
|
|
1035
|
+
[
|
|
1036
|
+
Immutable.fromJS({
|
|
1037
|
+
authentication: { rolesClaimsValues: claims },
|
|
1038
|
+
navigation: {
|
|
1039
|
+
route: { location: {}, match: { params: { scope: "MyScope" } } },
|
|
1040
|
+
},
|
|
1041
|
+
settings: { defaultScope: "Global" },
|
|
1042
|
+
}),
|
|
1043
|
+
],
|
|
1044
|
+
"to equal",
|
|
1045
|
+
true,
|
|
1046
|
+
);
|
|
1047
|
+
});
|
|
1048
|
+
|
|
1049
|
+
it("Retrieves true if user has administrator permissions just in specified scope with permission on parents", () => {
|
|
1050
|
+
const claims = Immutable.fromJS({
|
|
1051
|
+
Orders: {
|
|
1052
|
+
MyScope: {
|
|
1053
|
+
Reader: true,
|
|
1054
|
+
},
|
|
1055
|
+
},
|
|
1056
|
+
});
|
|
1057
|
+
|
|
1058
|
+
expect(
|
|
1059
|
+
hasReaderPermissionsForScope,
|
|
1060
|
+
"when called with",
|
|
1061
|
+
["ChildScope", "Orders"],
|
|
1062
|
+
"called with",
|
|
1063
|
+
[
|
|
1064
|
+
Immutable.fromJS({
|
|
1065
|
+
authentication: { rolesClaimsValues: claims },
|
|
1066
|
+
...state,
|
|
1067
|
+
navigation: {
|
|
1068
|
+
route: { location: {}, match: { params: { scope: "ChildScope" } } },
|
|
1069
|
+
},
|
|
1070
|
+
}),
|
|
1071
|
+
],
|
|
1072
|
+
"to equal",
|
|
1073
|
+
true,
|
|
1074
|
+
);
|
|
1075
|
+
});
|
|
1076
|
+
|
|
1077
|
+
it("Retrieves false if app roles claims are null", () => {
|
|
1078
|
+
expect(
|
|
1079
|
+
hasReaderPermissionsForScope,
|
|
1080
|
+
"when called with",
|
|
1081
|
+
["Global", "Orders"],
|
|
1082
|
+
"called with",
|
|
1083
|
+
[
|
|
1084
|
+
Immutable.fromJS({
|
|
1085
|
+
authentication: { rolesClaimsValues: {} },
|
|
1086
|
+
navigation: {
|
|
1087
|
+
route: { location: {}, match: { params: { scope: "Global" } } },
|
|
1088
|
+
},
|
|
1089
|
+
settings: { defaultScope: "Global" },
|
|
1090
|
+
}),
|
|
1091
|
+
],
|
|
1092
|
+
"to equal",
|
|
1093
|
+
false,
|
|
1094
|
+
);
|
|
1095
|
+
});
|
|
1096
|
+
});
|
package/src/selectors/modules.js
CHANGED
|
@@ -3,3 +3,10 @@ import { createSelector } from "reselect";
|
|
|
3
3
|
const modulesData = state => state.get("modules");
|
|
4
4
|
|
|
5
5
|
export const modulesSelector = createSelector(modulesData, data => data.getIn(["tree"]));
|
|
6
|
+
|
|
7
|
+
export const getScopeModuleInformationSelector = createSelector(modulesData, data => {
|
|
8
|
+
return {
|
|
9
|
+
visibleModules: data.getIn(["visibleModules"]).toJS(),
|
|
10
|
+
...data.getIn(["lastScopeAndModuleSelection"]).toJS(),
|
|
11
|
+
};
|
|
12
|
+
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import Immutable from "immutable";
|
|
2
|
-
import { modulesSelector } from "./modules";
|
|
2
|
+
import { getScopeModuleInformationSelector, modulesSelector } from "./modules";
|
|
3
3
|
|
|
4
4
|
describe("modulesSelector", () => {
|
|
5
5
|
let state;
|
|
@@ -7,6 +7,12 @@ describe("modulesSelector", () => {
|
|
|
7
7
|
state = Immutable.fromJS({
|
|
8
8
|
modules: {
|
|
9
9
|
tree: "modulesTree",
|
|
10
|
+
visibleModules: ["a", "module123"],
|
|
11
|
+
lastScopeAndModuleSelection: {
|
|
12
|
+
scope: "Norway",
|
|
13
|
+
moduleName: "Profiles",
|
|
14
|
+
routingPerformed: false,
|
|
15
|
+
},
|
|
10
16
|
},
|
|
11
17
|
});
|
|
12
18
|
});
|
|
@@ -14,4 +20,13 @@ describe("modulesSelector", () => {
|
|
|
14
20
|
it("Retrieves modules", () => {
|
|
15
21
|
expect(modulesSelector, "when called with", [state], "to equal", "modulesTree");
|
|
16
22
|
});
|
|
23
|
+
|
|
24
|
+
it("Retrieves modules and scope information", () => {
|
|
25
|
+
expect(getScopeModuleInformationSelector, "when called with", [state], "to equal", {
|
|
26
|
+
visibleModules: ["a", "module123"],
|
|
27
|
+
scope: "Norway",
|
|
28
|
+
moduleName: "Profiles",
|
|
29
|
+
routingPerformed: false,
|
|
30
|
+
});
|
|
31
|
+
});
|
|
17
32
|
});
|
package/src/selectors/scope.js
CHANGED
|
@@ -13,6 +13,8 @@ import { getLocalization } from "../utils/localizationHelper";
|
|
|
13
13
|
|
|
14
14
|
const scopeData = state => state.get("scopes");
|
|
15
15
|
|
|
16
|
+
export const getScopesSelector = createSelector(scopeData, scopes => scopes);
|
|
17
|
+
|
|
16
18
|
const localizedScopesSelector = createSelector(scopeData, currentLocaleOrDefault, (scopes, locale) =>
|
|
17
19
|
scopes.map(scope =>
|
|
18
20
|
scope.withMutations(s => {
|