File tree 1 file changed +46
-0
lines changed
1 file changed +46
-0
lines changed Original file line number Diff line number Diff line change @@ -171,6 +171,52 @@ describe('Fetch jwt', () => {
171
171
) . resolves . toEqual ( { access_token : mockAccessToken , expires_in : 123456 } ) ;
172
172
} ) ;
173
173
174
+ test ( 'valid jwt, qualified scopes' , ( ) => {
175
+ fetch . mockImplementation ( ( ) => mockResultSuccess ) ;
176
+ const metaScopes = [
177
+ 'https://ims-na1.adobelogin.com/s/ent_dataservices_sdk'
178
+ ] ;
179
+ jwt . sign = jest . fn ( ) . mockImplementation ( payload => {
180
+ expect ( payload [ metaScopes [ 0 ] ] ) . toBe ( true ) ;
181
+ return 'my_jwt_token' ;
182
+ } ) ;
183
+
184
+ return expect (
185
+ auth ( {
186
+ clientId,
187
+ clientSecret,
188
+ technicalAccountId,
189
+ orgId,
190
+ metaScopes,
191
+ privateKey
192
+ } )
193
+ ) . resolves . toEqual ( { access_token : mockAccessToken , expires_in : 123456 } ) ;
194
+ } ) ;
195
+
196
+ test ( 'valid jwt, unqualified scopes' , ( ) => {
197
+ fetch . mockImplementation ( ( ) => mockResultSuccess ) ;
198
+ const metaScopes = 'ent_dataservices_sdk,some_other_scope' ;
199
+ jwt . sign = jest . fn ( ) . mockImplementation ( payload => {
200
+ expect (
201
+ payload [ 'https://ims-na1.adobelogin.com/s/ent_dataservices_sdk' ]
202
+ ) . toBe ( true ) ;
203
+ expect ( payload [ 'https://ims-na1.adobelogin.com/s/some_other_scope' ] ) . toBe (
204
+ true
205
+ ) ;
206
+ return 'my_jwt_token' ;
207
+ } ) ;
208
+ return expect (
209
+ auth ( {
210
+ clientId,
211
+ clientSecret,
212
+ technicalAccountId,
213
+ orgId,
214
+ metaScopes,
215
+ privateKey
216
+ } )
217
+ ) . resolves . toEqual ( { access_token : mockAccessToken , expires_in : 123456 } ) ;
218
+ } ) ;
219
+
174
220
test ( 'invalid jwt, expected endpoint error' , ( ) => {
175
221
expect . assertions ( 1 ) ;
176
222
fetch . mockImplementation ( ( ) => mockResultFailure ) ;
You can’t perform that action at this time.
0 commit comments