@@ -12,6 +12,7 @@ describe('Contentstack apps test', () => {
12
12
expect ( app . urlPath ) . to . be . equal ( '/manifests' )
13
13
expect ( app . create ) . to . not . equal ( undefined )
14
14
expect ( app . findAll ) . to . not . equal ( undefined )
15
+ expect ( app . findAllAuthorized ) . to . not . equal ( undefined )
15
16
expect ( app . fetch ) . to . be . equal ( undefined )
16
17
expect ( app . update ) . to . be . equal ( undefined )
17
18
expect ( app . delete ) . to . be . equal ( undefined )
@@ -20,6 +21,8 @@ describe('Contentstack apps test', () => {
20
21
expect ( app . hosting ) . to . be . equal ( undefined )
21
22
expect ( app . install ) . to . be . equal ( undefined )
22
23
expect ( app . installation ) . to . be . equal ( undefined )
24
+ expect ( app . getRequests ) . to . be . equal ( undefined )
25
+ expect ( app . authorize ) . to . be . equal ( undefined )
23
26
done ( )
24
27
} )
25
28
@@ -29,6 +32,7 @@ describe('Contentstack apps test', () => {
29
32
expect ( app . urlPath ) . to . be . equal ( `/manifests/${ uid } ` )
30
33
expect ( app . create ) . to . be . equal ( undefined )
31
34
expect ( app . findAll ) . to . be . equal ( undefined )
35
+ expect ( app . findAllAuthorized ) . to . be . equal ( undefined )
32
36
expect ( app . fetch ) . to . not . equal ( undefined )
33
37
expect ( app . update ) . to . not . equal ( undefined )
34
38
expect ( app . delete ) . to . not . equal ( undefined )
@@ -37,6 +41,8 @@ describe('Contentstack apps test', () => {
37
41
expect ( app . hosting ) . to . not . equal ( undefined )
38
42
expect ( app . install ) . to . not . equal ( undefined )
39
43
expect ( app . installation ) . to . not . equal ( undefined )
44
+ expect ( app . getRequests ) . to . not . equal ( undefined )
45
+ expect ( app . authorize ) . to . not . equal ( undefined )
40
46
expect ( app . hosting ( ) ) . to . not . equal ( undefined )
41
47
expect ( app . installation ( ) ) . to . not . equal ( undefined )
42
48
expect ( app . installation ( uid ) ) . to . not . equal ( undefined )
@@ -50,6 +56,7 @@ describe('Contentstack apps test', () => {
50
56
expect ( app . urlPath ) . to . be . equal ( `/manifests/${ uid } ` )
51
57
expect ( app . create ) . to . be . equal ( undefined )
52
58
expect ( app . findAll ) . to . be . equal ( undefined )
59
+ expect ( app . findAllAuthorized ) . to . be . equal ( undefined )
53
60
expect ( app . fetch ) . to . not . equal ( undefined )
54
61
expect ( app . update ) . to . not . equal ( undefined )
55
62
expect ( app . delete ) . to . not . equal ( undefined )
@@ -58,6 +65,8 @@ describe('Contentstack apps test', () => {
58
65
expect ( app . hosting ) . to . not . equal ( undefined )
59
66
expect ( app . install ) . to . not . equal ( undefined )
60
67
expect ( app . installation ) . to . not . equal ( undefined )
68
+ expect ( app . getRequests ) . to . not . equal ( undefined )
69
+ expect ( app . authorize ) . to . not . equal ( undefined )
61
70
done ( )
62
71
} )
63
72
@@ -146,6 +155,38 @@ describe('Contentstack apps test', () => {
146
155
. catch ( done )
147
156
} )
148
157
158
+ it ( 'Get all authorized apps in organization test' , done => {
159
+ const content = {
160
+ visibility : 'private' ,
161
+ description : 'This is a test App.' ,
162
+ name : 'New App' ,
163
+ org_id : 'org_uid' ,
164
+ created_at : '2021-07-20T13:34:54.791Z' ,
165
+ updated_at : '2021-07-27T14:05:19.452Z' ,
166
+ id : 'id'
167
+ }
168
+ const mock = new MockAdapter ( Axios )
169
+ mock . onGet ( `/authorized-apps` ) . reply ( 200 , {
170
+ data : [
171
+ content
172
+ ]
173
+ } )
174
+
175
+ makeApp ( { } )
176
+ . findAllAuthorized ( )
177
+ . then ( ( response ) => {
178
+ expect ( response . data [ 0 ] . visibility ) . to . be . equal ( content . visibility )
179
+ expect ( response . data [ 0 ] . description ) . to . be . equal ( content . description )
180
+ expect ( response . data [ 0 ] . name ) . to . be . equal ( content . name )
181
+ expect ( response . data [ 0 ] . org_id ) . to . be . equal ( content . org_id )
182
+ expect ( response . data [ 0 ] . created_at ) . to . be . equal ( content . created_at )
183
+ expect ( response . data [ 0 ] . updated_at ) . to . be . equal ( content . updated_at )
184
+ expect ( response . data [ 0 ] . id ) . to . be . equal ( content . id )
185
+ done ( )
186
+ } )
187
+ . catch ( done )
188
+ } )
189
+
149
190
it ( 'Get oAuth configuration test' , done => {
150
191
const mock = new MockAdapter ( Axios )
151
192
const uid = appMock . uid
@@ -231,6 +272,36 @@ describe('Contentstack apps test', () => {
231
272
} )
232
273
. catch ( done )
233
274
} )
275
+ it ( 'test authorize app' , ( done ) => {
276
+ const uid = appMock . uid
277
+ const mock = new MockAdapter ( Axios )
278
+ mock . onPost ( `/manifests/${ appMock . uid } /authorize` ) . reply ( 200 , {
279
+ data : { redirect_uri : 'uri' }
280
+ } )
281
+
282
+ makeApp ( { data : { uid } } )
283
+ . authorize ( { responseType : 'type' , clientId : 'id' , redirectUri : 'uri' , scope : 'scope' } )
284
+ . then ( ( response ) => {
285
+ expect ( response . data . redirect_uri ) . to . be . equal ( 'uri' )
286
+ done ( )
287
+ } )
288
+ . catch ( done )
289
+ } )
290
+ it ( 'test authorize app fail request' , ( done ) => {
291
+ const uid = appMock . uid
292
+ const mock = new MockAdapter ( Axios )
293
+ mock . onPost ( `/manifests/${ appMock . uid } /authorize` ) . reply ( 400 , {
294
+
295
+ } )
296
+
297
+ makeApp ( { data : { uid } } )
298
+ . authorize ( { state : 'state' , responseType : 'type' , clientId : 'id' , redirectUri : 'uri' , scope : 'scope' } )
299
+ . then ( done )
300
+ . catch ( ( error ) => {
301
+ expect ( error ) . to . not . equal ( undefined )
302
+ done ( )
303
+ } )
304
+ } )
234
305
it ( 'test fetch request for app uid fail request' , ( done ) => {
235
306
const uid = appMock . uid
236
307
const mock = new MockAdapter ( Axios )
@@ -246,6 +317,35 @@ describe('Contentstack apps test', () => {
246
317
done ( )
247
318
} )
248
319
} )
320
+ it ( 'test authorize app fail request' , ( done ) => {
321
+ const uid = appMock . uid
322
+ const mock = new MockAdapter ( Axios )
323
+ mock . onPost ( `/manifests/${ appMock . uid } /requests` ) . reply ( 400 , {
324
+
325
+ } )
326
+
327
+ makeApp ( { data : { uid } } )
328
+ . getRequests ( )
329
+ . then ( done )
330
+ . catch ( ( error ) => {
331
+ expect ( error ) . to . not . equal ( undefined )
332
+ done ( )
333
+ } )
334
+ } )
335
+ it ( 'Get all authorized apps in organization fail request' , done => {
336
+ const mock = new MockAdapter ( Axios )
337
+ mock . onGet ( `/authorized-apps` ) . reply ( 400 , {
338
+
339
+ } )
340
+
341
+ makeApp ( { } )
342
+ . findAllAuthorized ( )
343
+ . then ( done )
344
+ . catch ( ( error ) => {
345
+ expect ( error ) . to . not . equal ( undefined )
346
+ done ( )
347
+ } )
348
+ } )
249
349
} )
250
350
251
351
function checkApp ( app ) {
0 commit comments