| 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:io'; | 7 import 'dart:io'; |
| 8 import 'dart:json'; | 8 import 'dart:json'; |
| 9 import 'dart:uri'; | 9 import 'dart:uri'; |
| 10 | 10 |
| 11 import '../../unittest/lib/unittest.dart'; | 11 import '../../unittest/lib/unittest.dart'; |
| 12 import '../../http/lib/http.dart' as http; | 12 import '../../http/lib/http.dart' as http; |
| 13 import '../../http/lib/testing.dart'; | 13 import '../../http/lib/testing.dart'; |
| 14 import '../lib/oauth2.dart' as oauth2; | 14 import '../lib/oauth2.dart' as oauth2; |
| 15 import 'utils.dart'; | 15 import 'utils.dart'; |
| 16 | 16 |
| 17 final redirectUrl = new Uri.fromString('http://example.com/redirect'); | 17 final redirectUrl = new Uri.fromString('http://example.com/redirect'); |
| 18 | 18 |
| 19 ExpectClient client; | 19 ExpectClient client; |
| 20 | 20 |
| 21 AuthorizationCodeGrant grant; | 21 oauth2.AuthorizationCodeGrant grant; |
| 22 | 22 |
| 23 void createGrant() { | 23 void createGrant() { |
| 24 client = new ExpectClient(); | 24 client = new ExpectClient(); |
| 25 grant = new oauth2.AuthorizationCodeGrant( | 25 grant = new oauth2.AuthorizationCodeGrant( |
| 26 'identifier', | 26 'identifier', |
| 27 'secret', | 27 'secret', |
| 28 new Uri.fromString('https://example.com/authorization'), | 28 new Uri.fromString('https://example.com/authorization'), |
| 29 new Uri.fromString('https://example.com/token'), | 29 new Uri.fromString('https://example.com/token'), |
| 30 httpClient: client); | 30 httpClient: client); |
| 31 } | 31 } |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 187 }); | 187 }); |
| 188 | 188 |
| 189 expect(grant.handleAuthorizationCode('auth code'), | 189 expect(grant.handleAuthorizationCode('auth code'), |
| 190 completion(predicate((client) { | 190 completion(predicate((client) { |
| 191 expect(client.credentials.accessToken, equals('access token')); | 191 expect(client.credentials.accessToken, equals('access token')); |
| 192 return true; | 192 return true; |
| 193 }))); | 193 }))); |
| 194 }); | 194 }); |
| 195 }); | 195 }); |
| 196 } | 196 } |
| OLD | NEW |