@@ -62,7 +62,8 @@ class AWSCognitoAuthPluginConfigTests: XCTestCase {
6262 " PoolId " : " xx " ,
6363 " Region " : " us-east-1 " ,
6464 " AppClientId " : " xx " ,
65- " AppClientSecret " : " xx " ] ]
65+ " AppClientSecret " : " xx " ,
66+ " Endpoint " : " example.org " ] ]
6667 ]
6768 ] )
6869 let amplifyConfig = AmplifyConfiguration ( auth: categoryConfig)
@@ -119,7 +120,8 @@ class AWSCognitoAuthPluginConfigTests: XCTestCase {
119120 " PoolId " : " xx " ,
120121 " Region " : " us-east-1 " ,
121122 " AppClientId " : " xx " ,
122- " AppClientSecret " : " xx " ] ]
123+ " AppClientSecret " : " xx " ,
124+ " Endpoint " : " example.org " ] ]
123125 ]
124126 ] )
125127 let amplifyConfig = AmplifyConfiguration ( auth: categoryConfig)
@@ -166,6 +168,76 @@ class AWSCognitoAuthPluginConfigTests: XCTestCase {
166168 }
167169 }
168170
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+
169241 /// Test Auth configuration with nil value
170242 ///
171243 /// - Given: Given a nil config for user pool and identity pool
@@ -210,7 +282,8 @@ class AWSCognitoAuthPluginConfigTests: XCTestCase {
210282 " PoolId " : " xx " ,
211283 " Region " : " us-east-1 " ,
212284 " AppClientId " : " xx " ,
213- " AppClientSecret " : " xx " ] ]
285+ " AppClientSecret " : " xx " ,
286+ " Endpoint " : " example.org " ] ]
214287 ]
215288 ] )
216289 let amplifyConfig = AmplifyConfiguration ( auth: categoryConfig)
0 commit comments