@@ -62,7 +62,8 @@ class AWSCognitoAuthPluginConfigTests: XCTestCase {
62
62
" PoolId " : " xx " ,
63
63
" Region " : " us-east-1 " ,
64
64
" AppClientId " : " xx " ,
65
- " AppClientSecret " : " xx " ] ]
65
+ " AppClientSecret " : " xx " ,
66
+ " Endpoint " : " example.org " ] ]
66
67
]
67
68
] )
68
69
let amplifyConfig = AmplifyConfiguration ( auth: categoryConfig)
@@ -119,7 +120,8 @@ class AWSCognitoAuthPluginConfigTests: XCTestCase {
119
120
" PoolId " : " xx " ,
120
121
" Region " : " us-east-1 " ,
121
122
" AppClientId " : " xx " ,
122
- " AppClientSecret " : " xx " ] ]
123
+ " AppClientSecret " : " xx " ,
124
+ " Endpoint " : " example.org " ] ]
123
125
]
124
126
] )
125
127
let amplifyConfig = AmplifyConfiguration ( auth: categoryConfig)
@@ -166,6 +168,76 @@ class AWSCognitoAuthPluginConfigTests: XCTestCase {
166
168
}
167
169
}
168
170
171
+ /// Test Auth configuration with endpoint url containing scheme for user pool
172
+ ///
173
+ /// - Given: Given invalid config with endpoint url containing scheme for user pool
174
+ /// - When:
175
+ /// - I configure auth with the given configuration
176
+ /// - Then:
177
+ /// - I should get an exception.
178
+ ///
179
+ func testConfigWithInvalidUserPoolEndpointWithScheme( ) throws {
180
+ let plugin = AWSCognitoAuthPlugin ( )
181
+ try Amplify . add ( plugin: plugin)
182
+
183
+ let categoryConfig = AuthCategoryConfiguration ( plugins: [
184
+ " awsCognitoAuthPlugin " : [
185
+ " CognitoUserPool " : [ " Default " : [
186
+ " PoolId " : " xx " ,
187
+ " Region " : " us-east-1 " ,
188
+ " AppClientId " : " xx " ,
189
+ " AppClientSecret " : " xx " ,
190
+ " Endpoint " : " https://example.org " ] ]
191
+ ]
192
+ ] )
193
+
194
+ let amplifyConfig = AmplifyConfiguration ( auth: categoryConfig)
195
+ do {
196
+ try Amplify . configure ( amplifyConfig)
197
+ XCTFail ( " Should have thrown a AuthError.configuration error for invalid endpoint url " )
198
+ } catch {
199
+ guard case AuthError . configuration = error else {
200
+ XCTFail ( " Should have thrown a AuthError.configuration error for invalid endpoint url " )
201
+ return
202
+ }
203
+ }
204
+ }
205
+
206
+ /// Test Auth configuration with endpoint url containing path for user pool
207
+ ///
208
+ /// - Given: Given invalid config with endpoint url containing path for user pool
209
+ /// - When:
210
+ /// - I configure auth with the given configuration
211
+ /// - Then:
212
+ /// - I should get an exception.
213
+ ///
214
+ func testConfigWithInvalidUserPoolEndpointWithPath( ) throws {
215
+ let plugin = AWSCognitoAuthPlugin ( )
216
+ try Amplify . add ( plugin: plugin)
217
+
218
+ let categoryConfig = AuthCategoryConfiguration ( plugins: [
219
+ " awsCognitoAuthPlugin " : [
220
+ " CognitoUserPool " : [ " Default " : [
221
+ " PoolId " : " xx " ,
222
+ " Region " : " us-east-1 " ,
223
+ " AppClientId " : " xx " ,
224
+ " AppClientSecret " : " xx " ,
225
+ " Endpoint " : " example.org/path " ] ]
226
+ ]
227
+ ] )
228
+
229
+ let amplifyConfig = AmplifyConfiguration ( auth: categoryConfig)
230
+ do {
231
+ try Amplify . configure ( amplifyConfig)
232
+ XCTFail ( " Should have thrown a AuthError.configuration error for invalid endpoint url " )
233
+ } catch {
234
+ guard case AuthError . configuration = error else {
235
+ XCTFail ( " Should have thrown a AuthError.configuration error for invalid endpoint url " )
236
+ return
237
+ }
238
+ }
239
+ }
240
+
169
241
/// Test Auth configuration with nil value
170
242
///
171
243
/// - Given: Given a nil config for user pool and identity pool
@@ -210,7 +282,8 @@ class AWSCognitoAuthPluginConfigTests: XCTestCase {
210
282
" PoolId " : " xx " ,
211
283
" Region " : " us-east-1 " ,
212
284
" AppClientId " : " xx " ,
213
- " AppClientSecret " : " xx " ] ]
285
+ " AppClientSecret " : " xx " ,
286
+ " Endpoint " : " example.org " ] ]
214
287
]
215
288
] )
216
289
let amplifyConfig = AmplifyConfiguration ( auth: categoryConfig)
0 commit comments