OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 library authorization_code_grant_test; | 5 library authorization_code_grant_test; |
6 | 6 |
7 import 'dart:async'; | 7 import 'dart:async'; |
8 import 'dart:io'; | 8 import 'dart:io'; |
9 import 'dart:json' as JSON; | 9 import 'dart:json' as JSON; |
10 import 'dart:uri'; | 10 import 'dart:uri'; |
(...skipping 15 matching lines...) Expand all Loading... |
26 client = new ExpectClient(); | 26 client = new ExpectClient(); |
27 grant = new oauth2.AuthorizationCodeGrant( | 27 grant = new oauth2.AuthorizationCodeGrant( |
28 'identifier', | 28 'identifier', |
29 'secret', | 29 'secret', |
30 Uri.parse('https://example.com/authorization'), | 30 Uri.parse('https://example.com/authorization'), |
31 Uri.parse('https://example.com/token'), | 31 Uri.parse('https://example.com/token'), |
32 httpClient: client); | 32 httpClient: client); |
33 } | 33 } |
34 | 34 |
35 void expectFutureThrows(future, predicate) { | 35 void expectFutureThrows(future, predicate) { |
36 future.catchError(expectAsync1((AsyncError e) { | 36 future.catchError(expectAsync1((error) { |
37 expect(predicate(e.error), isTrue); | 37 expect(predicate(error), isTrue); |
38 })); | 38 })); |
39 } | 39 } |
40 | 40 |
41 void main() { | 41 void main() { |
42 group('.getAuthorizationUrl', () { | 42 group('.getAuthorizationUrl', () { |
43 setUp(createGrant); | 43 setUp(createGrant); |
44 | 44 |
45 test('builds the correct URL', () { | 45 test('builds the correct URL', () { |
46 expect(grant.getAuthorizationUrl(redirectUrl).toString(), | 46 expect(grant.getAuthorizationUrl(redirectUrl).toString(), |
47 equals('https://example.com/authorization' | 47 equals('https://example.com/authorization' |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
205 }); | 205 }); |
206 | 206 |
207 expect(grant.handleAuthorizationCode('auth code'), | 207 expect(grant.handleAuthorizationCode('auth code'), |
208 completion(predicate((client) { | 208 completion(predicate((client) { |
209 expect(client.credentials.accessToken, equals('access token')); | 209 expect(client.credentials.accessToken, equals('access token')); |
210 return true; | 210 return true; |
211 }))); | 211 }))); |
212 }); | 212 }); |
213 }); | 213 }); |
214 } | 214 } |
OLD | NEW |