11import { can } from "@infrastructure/discord/authz" ;
22
33describe ( "auth tests" , ( ) => {
4- it ( "will accept one role with all permissions" , ( ) => {
5- const discordID = "693093284998021141" ;
6- jest . mock (
7- "../../../../data/githubDiscordMap.json" ,
8- ( ) => ( {
9- User1 : {
10- discordID : discordID ,
11- roles : [ "admin" ] ,
12- } ,
13- } ) ,
14- { virtual : true } ,
15- ) ;
16- expect ( can ( discordID , [ "githubIssue:write" , "githubIssue:read" ] ) ) . toBe ( true ) ;
17- } ) ;
4+ it ( "will accept one role with all permissions" , ( ) => {
5+ const discordID = "693093284998021141" ;
6+ jest . mock (
7+ "../../../../data/githubDiscordMap.json" ,
8+ ( ) => ( {
9+ User1 : {
10+ discordID : discordID ,
11+ roles : [ "admin" ] ,
12+ } ,
13+ } ) ,
14+ { virtual : true } ,
15+ ) ;
16+ expect ( can ( discordID , [ "githubIssue:write" , "githubIssue:read" ] ) ) . toBe (
17+ true ,
18+ ) ;
19+ } ) ;
1820
19- it ( "will throw an error if user has no roles" , ( ) => {
20- const discordID = "12345" ;
21- jest . mock (
22- "../../../../data/githubDiscordMap.json" ,
23- ( ) => ( {
24- User1 : {
25- discordID : discordID ,
26- roles : [ ] ,
27- } ,
28- } ) ,
29- { virtual : true } ,
30- ) ;
31- expect ( can ( discordID , [ "githubIssue:read" , "githubIssue:write" ] ) ) . toBe ( false ) ;
32- } ) ;
21+ it ( "will throw an error if user has no roles" , ( ) => {
22+ const discordID = "12345" ;
23+ jest . mock (
24+ "../../../../data/githubDiscordMap.json" ,
25+ ( ) => ( {
26+ User1 : {
27+ discordID : discordID ,
28+ roles : [ ] ,
29+ } ,
30+ } ) ,
31+ { virtual : true } ,
32+ ) ;
33+ expect ( can ( discordID , [ "githubIssue:read" , "githubIssue:write" ] ) ) . toBe (
34+ false ,
35+ ) ;
36+ } ) ;
3337
34- it ( "will throw an error if user does not have all of the required permissions" , ( ) => {
35- const discordID = "142782738615762944" ;
36- jest . mock (
37- "../../../../data/githubDiscordMap.json" ,
38- ( ) => ( {
39- User1 : {
40- discordID : discordID ,
41- roles : [ "readonly" ] ,
42- } ,
43- } ) ,
44- { virtual : true } ,
45- ) ;
46- expect ( can ( discordID , [ "githubIssue:read" , "githubIssue:write" ] ) ) . toBe ( false ) ;
47- } ) ;
38+ it ( "will throw an error if user does not have all of the required permissions" , ( ) => {
39+ const discordID = "142782738615762944" ;
40+ jest . mock (
41+ "../../../../data/githubDiscordMap.json" ,
42+ ( ) => ( {
43+ User1 : {
44+ discordID : discordID ,
45+ roles : [ "readonly" ] ,
46+ } ,
47+ } ) ,
48+ { virtual : true } ,
49+ ) ;
50+ expect ( can ( discordID , [ "githubIssue:read" , "githubIssue:write" ] ) ) . toBe (
51+ false ,
52+ ) ;
53+ } ) ;
4854
49- it ( ' will throw an error if the user is not in the map' , ( ) => {
50- const id = "12345" ;
51- expect ( can ( id , [ "githubIssue:write" , "githubIssue:read" ] ) ) . toBe ( false ) ;
52- } ) ;
53- } ) ;
55+ it ( " will throw an error if the user is not in the map" , ( ) => {
56+ const id = "12345" ;
57+ expect ( can ( id , [ "githubIssue:write" , "githubIssue:read" ] ) ) . toBe ( false ) ;
58+ } ) ;
59+ } ) ;
0 commit comments