@@ -55,9 +55,9 @@ class AWSCognitoAuthPluginConfigTests: XCTestCase {
55
55
let categoryConfig = AuthCategoryConfiguration ( plugins: [
56
56
" awsCognitoAuthPlugin " : [
57
57
" CredentialsProvider " : [ " CognitoIdentity " : [ " Default " :
58
- [ " PoolId " : " xx " ,
59
- " Region " : " us-east-1 " ]
60
- ] ] ,
58
+ [ " PoolId " : " xx " ,
59
+ " Region " : " us-east-1 " ]
60
+ ] ] ,
61
61
" CognitoUserPool " : [ " Default " : [
62
62
" PoolId " : " xx " ,
63
63
" Region " : " us-east-1 " ,
@@ -89,9 +89,9 @@ class AWSCognitoAuthPluginConfigTests: XCTestCase {
89
89
let categoryConfig = AuthCategoryConfiguration ( plugins: [
90
90
" awsCognitoAuthPlugin " : [
91
91
" CredentialsProvider " : [ " CognitoIdentity " : [ " Default " :
92
- [ " PoolId " : " cc " ,
93
- " Region " : " us-east-1 " ]
94
- ] ]
92
+ [ " PoolId " : " cc " ,
93
+ " Region " : " us-east-1 " ]
94
+ ] ]
95
95
]
96
96
] )
97
97
let amplifyConfig = AmplifyConfiguration ( auth: categoryConfig)
@@ -147,13 +147,13 @@ class AWSCognitoAuthPluginConfigTests: XCTestCase {
147
147
let categoryConfig = AuthCategoryConfiguration ( plugins: [
148
148
" awsCognitoAuthPlugin " : [
149
149
" CredentialsProvider " : [ " CognitoIdentity " : [ " Default " :
150
- [ " xx " : " xx " ,
151
- " xx2 " : " us-east-1 " ]
152
- ] ] ,
150
+ [ " xx " : " xx " ,
151
+ " xx2 " : " us-east-1 " ]
152
+ ] ] ,
153
153
" CognitoUserPool " : [ " Default " : [
154
154
" xx " : " xx " ,
155
155
" xx2 " : " us-east-1 "
156
- ] ]
156
+ ] ]
157
157
]
158
158
] )
159
159
let amplifyConfig = AmplifyConfiguration ( auth: categoryConfig)
@@ -253,9 +253,9 @@ class AWSCognitoAuthPluginConfigTests: XCTestCase {
253
253
XCTFail ( " Auth configuration should not succeed " )
254
254
} catch {
255
255
guard let pluginError = error as? PluginError ,
256
- case . pluginConfigurationError = pluginError else {
257
- XCTFail ( " Should throw invalidConfiguration exception. But received \( error) " )
258
- return
256
+ case . pluginConfigurationError = pluginError else {
257
+ XCTFail ( " Should throw invalidConfiguration exception. But received \( error) " )
258
+ return
259
259
}
260
260
}
261
261
}
@@ -274,10 +274,11 @@ class AWSCognitoAuthPluginConfigTests: XCTestCase {
274
274
275
275
let categoryConfig = AuthCategoryConfiguration ( plugins: [
276
276
" awsCognitoAuthPlugin " : [
277
- " CredentialsProvider " : [ " CognitoIdentity " : [ " Default " :
278
- [ " PoolId " : " xx " ,
279
- " Region " : " us-east-1 " ]
280
- ] ] ,
277
+ " CredentialsProvider " : [ " CognitoIdentity " :
278
+ [ " Default " :
279
+ [ " PoolId " : " xx " ,
280
+ " Region " : " us-east-1 " ]
281
+ ] ] ,
281
282
" CognitoUserPool " : [ " Default " : [
282
283
" PoolId " : " xx " ,
283
284
" Region " : " us-east-1 " ,
@@ -293,65 +294,69 @@ class AWSCognitoAuthPluginConfigTests: XCTestCase {
293
294
XCTFail ( " Should not throw error. \( error) " )
294
295
}
295
296
296
- let signUpExpectation = expectation ( description: " Should receive a result " )
297
+ let signUpExpectation = expectation ( description: " Should receive a signUp result " )
297
298
_ = plugin. signUp ( username: " mockUsername " , password: " " , options: nil ) { _ in
298
299
signUpExpectation. fulfill ( )
299
300
}
300
301
301
302
var expectationList = [ signUpExpectation]
302
303
303
- for _ in 1 ... 50 {
304
- let fetchSessionExpectation = expectation ( description: " Should receive a result " )
304
+ for index in 1 ... 50 {
305
+ let fetchSessionExpectation = expectation (
306
+ description: " Should receive fetch Authsession result for \( index) " )
305
307
_ = plugin. fetchAuthSession ( options: nil ) { _ in
306
308
fetchSessionExpectation. fulfill ( )
307
309
}
308
310
expectationList. append ( fetchSessionExpectation)
309
311
}
310
312
311
- let signUpExpectation2 = expectation ( description: " Should receive a result " )
313
+ let signUpExpectation2 = expectation ( description: " Should receive a second signUp result " )
312
314
DispatchQueue . global ( ) . async {
313
315
314
316
_ = plugin. signUp ( username: " mockUsername " , password: " " , options: nil ) { _ in
315
317
signUpExpectation2. fulfill ( )
316
318
}
317
319
}
318
320
expectationList. append ( signUpExpectation2)
319
- wait ( for: expectationList, timeout: 10 , enforceOrder: true )
321
+ wait ( for: expectationList, timeout: 20 , enforceOrder: true )
320
322
}
321
-
323
+
322
324
func testUserNetworkPreferencesForIdentityPoolService( ) throws {
323
325
let networkPreferences = AWSCognitoNetworkPreferences ( maxRetryCount: 0 ,
324
326
timeoutIntervalForRequest: 30 ,
325
327
timeoutIntervalForResource: 30 )
326
328
let plugin = AWSCognitoAuthPlugin ( networkPreferences: networkPreferences)
327
329
328
- let json = JSONValue ( dictionaryLiteral: ( " CredentialsProvider " ,
329
- . init( dictionaryLiteral: ( " CognitoIdentity " ,
330
- . init( dictionaryLiteral: ( " Default " ,
331
- . init( dictionaryLiteral: ( " Region " , " us-east-1 " ) ) ) ) ) ) ) )
330
+ let json : JSONValue = [ " CredentialsProvider " :
331
+ [ " CognitoIdentity " :
332
+ [ " Default " :
333
+ [ " Region " : " us-east1 " ]
334
+ ]
335
+ ] ]
332
336
let identityPoolConfig = plugin. identityPoolServiceConfiguration ( from: json)
333
337
334
338
XCTAssertEqual ( identityPoolConfig? . maxRetryCount, networkPreferences. maxRetryCount)
335
339
XCTAssertEqual ( identityPoolConfig? . timeoutIntervalForResource, networkPreferences. timeoutIntervalForResource)
336
340
XCTAssertEqual ( identityPoolConfig? . timeoutIntervalForRequest, networkPreferences. timeoutIntervalForRequest)
337
341
}
338
-
342
+
339
343
func testUserNetworkPreferencesForUserPoolService( ) throws {
340
344
let networkPreferences = AWSCognitoNetworkPreferences ( maxRetryCount: 0 ,
341
345
timeoutIntervalForRequest: 30 ,
342
346
timeoutIntervalForResource: 30 )
343
347
let plugin = AWSCognitoAuthPlugin ( networkPreferences: networkPreferences)
344
-
345
- let json = JSONValue ( dictionaryLiteral: ( " CognitoUserPool " ,
346
- . init( dictionaryLiteral: ( " Default " ,
347
- . init( dictionaryLiteral: ( " Region " , " us-east-1 " ) ) ) ) ) )
348
+ let json : JSONValue = [ " CognitoUserPool " :
349
+ [ " Default " :
350
+ [ " Region " : " us-east1 " ]
351
+ ]
352
+ ]
348
353
let identityPoolConfig = try plugin. userPoolServiceConfiguration ( from: json)
349
354
350
355
XCTAssertEqual ( identityPoolConfig? . maxRetryCount, networkPreferences. maxRetryCount)
351
356
XCTAssertEqual ( identityPoolConfig? . timeoutIntervalForResource, networkPreferences. timeoutIntervalForResource)
352
357
XCTAssertEqual ( identityPoolConfig? . timeoutIntervalForRequest, networkPreferences. timeoutIntervalForRequest)
353
358
}
354
-
359
+
355
360
func testNoUserPreferences( ) throws {
356
361
let plugin = AWSCognitoAuthPlugin ( )
357
362
XCTAssertNil ( plugin. networkPreferences)
0 commit comments