| 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; | |
| 6 | |
| 7 import 'dart:async'; | 5 import 'dart:async'; |
| 8 import 'dart:convert'; | 6 import 'dart:convert'; |
| 9 | 7 |
| 10 import 'package:http/http.dart' as http; | 8 import 'package:http/http.dart' as http; |
| 11 import 'package:oauth2/oauth2.dart' as oauth2; | 9 import 'package:oauth2/oauth2.dart' as oauth2; |
| 12 import 'package:test/test.dart'; | 10 import 'package:test/test.dart'; |
| 13 | 11 |
| 14 import 'utils.dart'; | 12 import 'utils.dart'; |
| 15 | 13 |
| 16 final Uri tokenEndpoint = Uri.parse('http://example.com/token'); | 14 final Uri tokenEndpoint = Uri.parse('http://example.com/token'); |
| 17 | 15 |
| 18 ExpectClient httpClient; | |
| 19 | |
| 20 void main() { | 16 void main() { |
| 17 var httpClient; |
| 21 setUp(() => httpClient = new ExpectClient()); | 18 setUp(() => httpClient = new ExpectClient()); |
| 22 | 19 |
| 23 test('is not expired if no expiration exists', () { | 20 test('is not expired if no expiration exists', () { |
| 24 var credentials = new oauth2.Credentials('access token'); | 21 var credentials = new oauth2.Credentials('access token'); |
| 25 expect(credentials.isExpired, isFalse); | 22 expect(credentials.isExpired, isFalse); |
| 26 }); | 23 }); |
| 27 | 24 |
| 28 test('is not expired if the expiration is in the future', () { | 25 test('is not expired if the expiration is in the future', () { |
| 29 var expiration = new DateTime.now().add(new Duration(hours: 1)); | 26 var expiration = new DateTime.now().add(new Duration(hours: 1)); |
| 30 var credentials = new oauth2.Credentials( | 27 var credentials = new oauth2.Credentials( |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 165 expect(() => fromMap({"accessToken": "foo", "scopes": 12}), | 162 expect(() => fromMap({"accessToken": "foo", "scopes": 12}), |
| 166 throwsFormatException); | 163 throwsFormatException); |
| 167 }); | 164 }); |
| 168 | 165 |
| 169 test("should throw a FormatException if expiration is not an int", () { | 166 test("should throw a FormatException if expiration is not an int", () { |
| 170 expect(() => fromMap({"accessToken": "foo", "expiration": "12"}), | 167 expect(() => fromMap({"accessToken": "foo", "expiration": "12"}), |
| 171 throwsFormatException); | 168 throwsFormatException); |
| 172 }); | 169 }); |
| 173 }); | 170 }); |
| 174 } | 171 } |
| OLD | NEW |