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 credentials_test; | 5 library credentials_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 28 matching lines...) Expand all Loading... |
39 var credentials = new oauth2.Credentials( | 39 var credentials = new oauth2.Credentials( |
40 'access token', null, null, null, expiration); | 40 'access token', null, null, null, expiration); |
41 expect(credentials.isExpired, isTrue); | 41 expect(credentials.isExpired, isTrue); |
42 }); | 42 }); |
43 | 43 |
44 test("can't refresh without a refresh token", () { | 44 test("can't refresh without a refresh token", () { |
45 var credentials = new oauth2.Credentials( | 45 var credentials = new oauth2.Credentials( |
46 'access token', null, tokenEndpoint); | 46 'access token', null, tokenEndpoint); |
47 expect(credentials.canRefresh, false); | 47 expect(credentials.canRefresh, false); |
48 credentials.refresh('identifier', 'secret', httpClient: httpClient) | 48 credentials.refresh('identifier', 'secret', httpClient: httpClient) |
49 .catchError(expectAsync1((e) { | 49 .catchError(expectAsync1((error) { |
50 expect(e.error is StateError, isTrue); | 50 expect(error is StateError, isTrue); |
51 })); | 51 })); |
52 }); | 52 }); |
53 | 53 |
54 test("can't refresh without a token endpoint", () { | 54 test("can't refresh without a token endpoint", () { |
55 var credentials = new oauth2.Credentials('access token', 'refresh token'); | 55 var credentials = new oauth2.Credentials('access token', 'refresh token'); |
56 expect(credentials.canRefresh, false); | 56 expect(credentials.canRefresh, false); |
57 credentials.refresh('identifier', 'secret', httpClient: httpClient) | 57 credentials.refresh('identifier', 'secret', httpClient: httpClient) |
58 .catchError(expectAsync1((e) { | 58 .catchError(expectAsync1((error) { |
59 expect(e.error is StateError, isTrue); | 59 expect(error is StateError, isTrue); |
60 })); | 60 })); |
61 }); | 61 }); |
62 | 62 |
63 test("can refresh with a refresh token and a token endpoint", () { | 63 test("can refresh with a refresh token and a token endpoint", () { |
64 var credentials = new oauth2.Credentials( | 64 var credentials = new oauth2.Credentials( |
65 'access token', 'refresh token', tokenEndpoint, ['scope1', 'scope2']); | 65 'access token', 'refresh token', tokenEndpoint, ['scope1', 'scope2']); |
66 expect(credentials.canRefresh, true); | 66 expect(credentials.canRefresh, true); |
67 | 67 |
68 httpClient.expectRequest((request) { | 68 httpClient.expectRequest((request) { |
69 expect(request.method, equals('POST')); | 69 expect(request.method, equals('POST')); |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
171 expect(() => fromMap({"accessToken": "foo", "scopes": 12}), | 171 expect(() => fromMap({"accessToken": "foo", "scopes": 12}), |
172 throwsFormatException); | 172 throwsFormatException); |
173 }); | 173 }); |
174 | 174 |
175 test("should throw a FormatException if expiration is not an int", () { | 175 test("should throw a FormatException if expiration is not an int", () { |
176 expect(() => fromMap({"accessToken": "foo", "expiration": "12"}), | 176 expect(() => fromMap({"accessToken": "foo", "expiration": "12"}), |
177 throwsFormatException); | 177 throwsFormatException); |
178 }); | 178 }); |
179 }); | 179 }); |
180 } | 180 } |
OLD | NEW |