| 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 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 147 expect(request.method, equals('POST')); | 147 expect(request.method, equals('POST')); |
| 148 expect(request.url.toString(), equals(grant.tokenEndpoint.toString())); | 148 expect(request.url.toString(), equals(grant.tokenEndpoint.toString())); |
| 149 expect(request.bodyFields, equals({ | 149 expect(request.bodyFields, equals({ |
| 150 'grant_type': 'authorization_code', | 150 'grant_type': 'authorization_code', |
| 151 'code': 'auth code', | 151 'code': 'auth code', |
| 152 'redirect_uri': redirectUrl.toString(), | 152 'redirect_uri': redirectUrl.toString(), |
| 153 'client_id': 'identifier', | 153 'client_id': 'identifier', |
| 154 'client_secret': 'secret' | 154 'client_secret': 'secret' |
| 155 })); | 155 })); |
| 156 | 156 |
| 157 return new Future.immediate(new http.Response(JSON.stringify({ | 157 return new Future.value(new http.Response(JSON.stringify({ |
| 158 'access_token': 'access token', | 158 'access_token': 'access token', |
| 159 'token_type': 'bearer', | 159 'token_type': 'bearer', |
| 160 }), 200, headers: {'content-type': 'application/json'})); | 160 }), 200, headers: {'content-type': 'application/json'})); |
| 161 }); | 161 }); |
| 162 | 162 |
| 163 grant.handleAuthorizationResponse({'code': 'auth code'}) | 163 grant.handleAuthorizationResponse({'code': 'auth code'}) |
| 164 .then(expectAsync1((client) { | 164 .then(expectAsync1((client) { |
| 165 expect(client.credentials.accessToken, equals('access token')); | 165 expect(client.credentials.accessToken, equals('access token')); |
| 166 })); | 166 })); |
| 167 }); | 167 }); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 191 expect(request.method, equals('POST')); | 191 expect(request.method, equals('POST')); |
| 192 expect(request.url.toString(), equals(grant.tokenEndpoint.toString())); | 192 expect(request.url.toString(), equals(grant.tokenEndpoint.toString())); |
| 193 expect(request.bodyFields, equals({ | 193 expect(request.bodyFields, equals({ |
| 194 'grant_type': 'authorization_code', | 194 'grant_type': 'authorization_code', |
| 195 'code': 'auth code', | 195 'code': 'auth code', |
| 196 'redirect_uri': redirectUrl.toString(), | 196 'redirect_uri': redirectUrl.toString(), |
| 197 'client_id': 'identifier', | 197 'client_id': 'identifier', |
| 198 'client_secret': 'secret' | 198 'client_secret': 'secret' |
| 199 })); | 199 })); |
| 200 | 200 |
| 201 return new Future.immediate(new http.Response(JSON.stringify({ | 201 return new Future.value(new http.Response(JSON.stringify({ |
| 202 'access_token': 'access token', | 202 'access_token': 'access token', |
| 203 'token_type': 'bearer', | 203 'token_type': 'bearer', |
| 204 }), 200, headers: {'content-type': 'application/json'})); | 204 }), 200, headers: {'content-type': 'application/json'})); |
| 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 |