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 |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 }); | 43 }); |
44 | 44 |
45 test('builds the correct URL with scopes', () { | 45 test('builds the correct URL with scopes', () { |
46 var authorizationUrl = grant.getAuthorizationUrl( | 46 var authorizationUrl = grant.getAuthorizationUrl( |
47 redirectUrl, scopes: ['scope', 'other/scope']); | 47 redirectUrl, scopes: ['scope', 'other/scope']); |
48 expect(authorizationUrl.toString(), | 48 expect(authorizationUrl.toString(), |
49 equals('https://example.com/authorization' | 49 equals('https://example.com/authorization' |
50 '?response_type=code' | 50 '?response_type=code' |
51 '&client_id=identifier' | 51 '&client_id=identifier' |
52 '&redirect_uri=http%3A%2F%2Fexample.com%2Fredirect' | 52 '&redirect_uri=http%3A%2F%2Fexample.com%2Fredirect' |
53 '&scope=scope%20other%2Fscope')); | 53 '&scope=scope+other%2Fscope')); |
54 }); | 54 }); |
55 | 55 |
56 test('builds the correct URL with state', () { | 56 test('builds the correct URL with state', () { |
57 var authorizationUrl = grant.getAuthorizationUrl( | 57 var authorizationUrl = grant.getAuthorizationUrl( |
58 redirectUrl, state: 'state'); | 58 redirectUrl, state: 'state'); |
59 expect(authorizationUrl.toString(), | 59 expect(authorizationUrl.toString(), |
60 equals('https://example.com/authorization' | 60 equals('https://example.com/authorization' |
61 '?response_type=code' | 61 '?response_type=code' |
62 '&client_id=identifier' | 62 '&client_id=identifier' |
63 '&redirect_uri=http%3A%2F%2Fexample.com%2Fredirect' | 63 '&redirect_uri=http%3A%2F%2Fexample.com%2Fredirect' |
(...skipping 123 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 |