@@ -75,6 +75,54 @@ describe("default", () => {
75
75
} ) ;
76
76
} ) ;
77
77
78
+ test ( "authorized installation created" , async ( ) => {
79
+ const result = await authorizer ( {
80
+ allowedOrgs : [ "rapidsai" ] ,
81
+ event : makeInstallationEvent ( {
82
+ action : "created" ,
83
+ orgName : "rapidsai" ,
84
+ } ) ,
85
+ } ) ;
86
+ expect ( mockDeleteInstallation ) . not . toHaveBeenCalled ( ) ;
87
+ expect ( result ) . toStrictEqual ( {
88
+ msg : "New installation from authorized organization." ,
89
+ httpCode : 200 ,
90
+ isAuthorized : true ,
91
+ } ) ;
92
+ } ) ;
93
+
94
+ test ( "authorized installation created (case insensitive 1)" , async ( ) => {
95
+ const result = await authorizer ( {
96
+ allowedOrgs : [ "RAPIDSAI" ] ,
97
+ event : makeInstallationEvent ( {
98
+ action : "created" ,
99
+ orgName : "rapidsai" ,
100
+ } ) ,
101
+ } ) ;
102
+ expect ( mockDeleteInstallation ) . not . toHaveBeenCalled ( ) ;
103
+ expect ( result ) . toStrictEqual ( {
104
+ msg : "New installation from authorized organization." ,
105
+ httpCode : 200 ,
106
+ isAuthorized : true ,
107
+ } ) ;
108
+ } ) ;
109
+
110
+ test ( "authorized installation created (case insensitive 2)" , async ( ) => {
111
+ const result = await authorizer ( {
112
+ allowedOrgs : [ "rapidsai" ] ,
113
+ event : makeInstallationEvent ( {
114
+ action : "created" ,
115
+ orgName : "RAPIDSAI" ,
116
+ } ) ,
117
+ } ) ;
118
+ expect ( mockDeleteInstallation ) . not . toHaveBeenCalled ( ) ;
119
+ expect ( result ) . toStrictEqual ( {
120
+ msg : "New installation from authorized organization." ,
121
+ httpCode : 200 ,
122
+ isAuthorized : true ,
123
+ } ) ;
124
+ } ) ;
125
+
78
126
test ( "installation deleted (no org object)" , async ( ) => {
79
127
const result = await authorizer ( {
80
128
allowedOrgs : [ "rapidsai" ] ,
@@ -91,7 +139,7 @@ describe("default", () => {
91
139
} ) ;
92
140
} ) ;
93
141
94
- test ( "issue_comment created | delete success" , async ( ) => {
142
+ test ( "unauthorized org issue_comment | delete success" , async ( ) => {
95
143
mockDeleteInstallation . mockReturnValueOnce ( "deleted successfully" ) ;
96
144
const result = await authorizer ( {
97
145
allowedOrgs : [ "rapidsai" ] ,
@@ -106,7 +154,7 @@ describe("default", () => {
106
154
} ) ;
107
155
} ) ;
108
156
109
- test ( "issue_comment created | delete failed" , async ( ) => {
157
+ test ( "unauthorized org issue_comment | delete failed" , async ( ) => {
110
158
mockDeleteInstallation . mockRejectedValueOnce ( "error deleting installation" ) ;
111
159
const result = await authorizer ( {
112
160
allowedOrgs : [ "rapidsai" ] ,
@@ -121,7 +169,7 @@ describe("default", () => {
121
169
} ) ;
122
170
} ) ;
123
171
124
- test ( "issue_comment created | delete success " , async ( ) => {
172
+ test ( "authorized org issue_comment " , async ( ) => {
125
173
mockDeleteInstallation . mockReturnValueOnce ( "deleted successfully" ) ;
126
174
const result = await authorizer ( {
127
175
allowedOrgs : [ "rapidsai" ] ,
@@ -135,4 +183,34 @@ describe("default", () => {
135
183
isAuthorized : true ,
136
184
} ) ;
137
185
} ) ;
186
+
187
+ test ( "authorized org issue_comment (case insensitive 1)" , async ( ) => {
188
+ mockDeleteInstallation . mockReturnValueOnce ( "deleted successfully" ) ;
189
+ const result = await authorizer ( {
190
+ allowedOrgs : [ "rapidsai" ] ,
191
+ event : makeIssueCommentEvent ( {
192
+ orgName : "RAPIDSAI" ,
193
+ } ) ,
194
+ } ) ;
195
+ expect ( result ) . toStrictEqual ( {
196
+ msg : "Organization is authorized." ,
197
+ httpCode : 200 ,
198
+ isAuthorized : true ,
199
+ } ) ;
200
+ } ) ;
201
+
202
+ test ( "authorized org issue_comment (case insensitive 2)" , async ( ) => {
203
+ mockDeleteInstallation . mockReturnValueOnce ( "deleted successfully" ) ;
204
+ const result = await authorizer ( {
205
+ allowedOrgs : [ "RAPIDSAI" ] ,
206
+ event : makeIssueCommentEvent ( {
207
+ orgName : "rapidsai" ,
208
+ } ) ,
209
+ } ) ;
210
+ expect ( result ) . toStrictEqual ( {
211
+ msg : "Organization is authorized." ,
212
+ httpCode : 200 ,
213
+ isAuthorized : true ,
214
+ } ) ;
215
+ } ) ;
138
216
} ) ;
0 commit comments