@@ -159,6 +159,40 @@ class TestCompass: XCTestCase {
159159 self . waitForExpectationsWithTimeout ( 4.0 , handler: nil )
160160 }
161161
162+ func testParseRegularURLWithFragmentsAndGoogleOAuth2AccessToken( ) {
163+ let expectation = self . expectationWithDescription ( " Parse URL with fragments and Google OAuth 2.0 access token format " )
164+ let url = NSURL ( string: " compassTests://callback/#access_token=ya29.Ci8nA1pNVMFffHkS5-sXooNGvTB9q8QPtoM56sWpipRyjhwwEiKyZxvRQTR8saqWzQ&token_type=Bearer&expires_in=3600 " ) !
165+
166+ Compass . parse ( url) { route, arguments, _ in
167+ XCTAssertEqual ( route, " callback " )
168+ XCTAssertEqual ( arguments. count, 3 )
169+ XCTAssertEqual ( arguments [ " access_token " ] , " ya29.Ci8nA1pNVMFffHkS5-sXooNGvTB9q8QPtoM56sWpipRyjhwwEiKyZxvRQTR8saqWzQ " )
170+ XCTAssertEqual ( arguments [ " expires_in " ] , " 3600 " )
171+ XCTAssertEqual ( arguments [ " token_type " ] , " Bearer " )
172+
173+ expectation. fulfill ( )
174+ }
175+
176+ self . waitForExpectationsWithTimeout ( 4.0 , handler: nil )
177+ }
178+
179+ func testParseRegularURLWithFragmentsAndAlternativeAccessToken( ) {
180+ let expectation = self . expectationWithDescription ( " Parse URL with fragments and alternative access token format " )
181+ let url = NSURL ( string: " compassTests://callback/#access_token=ya29.Ci8nA1pNVMFffHkS5-sXooNGvTB9q8QPtoM56sWpipRyjhwwEiKyZxvRQTR8saqWzQ=&token_type=Bearer&expires_in=3600 " ) !
182+
183+ Compass . parse ( url) { route, arguments, _ in
184+ XCTAssertEqual ( route, " callback " )
185+ XCTAssertEqual ( arguments. count, 3 )
186+ XCTAssertEqual ( arguments [ " access_token " ] , " ya29.Ci8nA1pNVMFffHkS5-sXooNGvTB9q8QPtoM56sWpipRyjhwwEiKyZxvRQTR8saqWzQ= " )
187+ XCTAssertEqual ( arguments [ " expires_in " ] , " 3600 " )
188+ XCTAssertEqual ( arguments [ " token_type " ] , " Bearer " )
189+
190+ expectation. fulfill ( )
191+ }
192+
193+ self . waitForExpectationsWithTimeout ( 4.0 , handler: nil )
194+ }
195+
162196 func testParseRegularURLWithSlashQuery( ) {
163197 let expectation = self . expectationWithDescription ( " Parse URL with slash query " )
164198 let url = NSURL ( string: " compassTests://callback/?access_token=Yo0OMrVZbRWNmgA6BT99hyuTUTNRGvqEEAQyeN1eslclzhFD0M8AidB4Z7Vs2NU8WoSNW0vYb961O38l&token_type=Bearer&expires_in=3600 " ) !
@@ -176,6 +210,40 @@ class TestCompass: XCTestCase {
176210 self . waitForExpectationsWithTimeout ( 4.0 , handler: nil )
177211 }
178212
213+ func testParseRegularURLWithSlashQueryAndGoogleOAuth2AccessToken( ) {
214+ let expectation = self . expectationWithDescription ( " Parse URL with slash query and Google OAuth 2.0 access token format " )
215+ let url = NSURL ( string: " compassTests://callback/?access_token=ya29.Ci8nA1pNVMFffHkS5-sXooNGvTB9q8QPtoM56sWpipRyjhwwEiKyZxvRQTR8saqWzQ&token_type=Bearer&expires_in=3600 " ) !
216+
217+ Compass . parse ( url) { route, arguments, _ in
218+ XCTAssertEqual ( route, " callback " )
219+ XCTAssertEqual ( arguments. count, 3 )
220+ XCTAssertEqual ( arguments [ " access_token " ] , " ya29.Ci8nA1pNVMFffHkS5-sXooNGvTB9q8QPtoM56sWpipRyjhwwEiKyZxvRQTR8saqWzQ " )
221+ XCTAssertEqual ( arguments [ " expires_in " ] , " 3600 " )
222+ XCTAssertEqual ( arguments [ " token_type " ] , " Bearer " )
223+
224+ expectation. fulfill ( )
225+ }
226+
227+ self . waitForExpectationsWithTimeout ( 4.0 , handler: nil )
228+ }
229+
230+ func testParseRegularURLWithSlashQueryAndAlternativeAccessToken( ) {
231+ let expectation = self . expectationWithDescription ( " Parse URL with slash query and alternative access token format " )
232+ let url = NSURL ( string: " compassTests://callback/?access_token=ya29.Ci8nA1pNVMFffHkS5-sXooNGvTB9q8QPtoM56sWpipRyjhwwEiKyZxvRQTR8saqWzQ=&token_type=Bearer&expires_in=3600 " ) !
233+
234+ Compass . parse ( url) { route, arguments, _ in
235+ XCTAssertEqual ( route, " callback " )
236+ XCTAssertEqual ( arguments. count, 3 )
237+ XCTAssertEqual ( arguments [ " access_token " ] , " ya29.Ci8nA1pNVMFffHkS5-sXooNGvTB9q8QPtoM56sWpipRyjhwwEiKyZxvRQTR8saqWzQ= " )
238+ XCTAssertEqual ( arguments [ " expires_in " ] , " 3600 " )
239+ XCTAssertEqual ( arguments [ " token_type " ] , " Bearer " )
240+
241+ expectation. fulfill ( )
242+ }
243+
244+ self . waitForExpectationsWithTimeout ( 4.0 , handler: nil )
245+ }
246+
179247 func testParseRegularURLWithQuery( ) {
180248 let expectation = self . expectationWithDescription ( " Parse URL with query " )
181249 let url = NSURL ( string: " compassTests://callback?access_token=Yo0OMrVZbRWNmgA6BT99hyuTUTNRGvqEEAQyeN1eslclzhFD0M8AidB4Z7Vs2NU8WoSNW0vYb961O38l&token_type=Bearer&expires_in=3600 " ) !
@@ -192,4 +260,38 @@ class TestCompass: XCTestCase {
192260
193261 self . waitForExpectationsWithTimeout ( 4.0 , handler: nil )
194262 }
263+
264+ func testParseRegularURLWithQueryAndGoogleOAuth2AccessToken( ) {
265+ let expectation = self . expectationWithDescription ( " Parse URL with query and Google OAuth 2.0 access token format " )
266+ let url = NSURL ( string: " compassTests://callback?access_token=ya29.Ci8nA1pNVMFffHkS5-sXooNGvTB9q8QPtoM56sWpipRyjhwwEiKyZxvRQTR8saqWzQ&token_type=Bearer&expires_in=3600 " ) !
267+
268+ Compass . parse ( url) { route, arguments, _ in
269+ XCTAssertEqual ( route, " callback " )
270+ XCTAssertEqual ( arguments. count, 3 )
271+ XCTAssertEqual ( arguments [ " access_token " ] , " ya29.Ci8nA1pNVMFffHkS5-sXooNGvTB9q8QPtoM56sWpipRyjhwwEiKyZxvRQTR8saqWzQ " )
272+ XCTAssertEqual ( arguments [ " expires_in " ] , " 3600 " )
273+ XCTAssertEqual ( arguments [ " token_type " ] , " Bearer " )
274+
275+ expectation. fulfill ( )
276+ }
277+
278+ self . waitForExpectationsWithTimeout ( 4.0 , handler: nil )
279+ }
280+
281+ func testParseRegularURLWithQueryAndAlternativeAccessToken( ) {
282+ let expectation = self . expectationWithDescription ( " Parse URL with query and alternative access token format " )
283+ let url = NSURL ( string: " compassTests://callback?access_token=ya29.Ci8nA1pNVMFffHkS5-sXooNGvTB9q8QPtoM56sWpipRyjhwwEiKyZxvRQTR8saqWzQ=&token_type=Bearer&expires_in=3600 " ) !
284+
285+ Compass . parse ( url) { route, arguments, _ in
286+ XCTAssertEqual ( route, " callback " )
287+ XCTAssertEqual ( arguments. count, 3 )
288+ XCTAssertEqual ( arguments [ " access_token " ] , " ya29.Ci8nA1pNVMFffHkS5-sXooNGvTB9q8QPtoM56sWpipRyjhwwEiKyZxvRQTR8saqWzQ= " )
289+ XCTAssertEqual ( arguments [ " expires_in " ] , " 3600 " )
290+ XCTAssertEqual ( arguments [ " token_type " ] , " Bearer " )
291+
292+ expectation. fulfill ( )
293+ }
294+
295+ self . waitForExpectationsWithTimeout ( 4.0 , handler: nil )
296+ }
195297}
0 commit comments