Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(8)

Side by Side Diff: utils/tests/pub/oauth2_test.dart

Issue 11770004: Rename Date to DateTime. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 oauth2_test; 5 library oauth2_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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 pub.kill(); 54 pub.kill();
55 55
56 run(); 56 run();
57 }); 57 });
58 58
59 test('with an expired credentials.json, refreshes and saves the refreshed ' 59 test('with an expired credentials.json, refreshes and saves the refreshed '
60 'access token to credentials.json', () { 60 'access token to credentials.json', () {
61 var server = new ScheduledServer(); 61 var server = new ScheduledServer();
62 credentialsFile(server, 'access token', 62 credentialsFile(server, 'access token',
63 refreshToken: 'refresh token', 63 refreshToken: 'refresh token',
64 expiration: new Date.now().subtract(new Duration(hours: 1))) 64 expiration: new DateTime.now().subtract(new Duration(hours: 1)))
65 .scheduleCreate(); 65 .scheduleCreate();
66 66
67 var pub = startPubLish(server); 67 var pub = startPubLish(server);
68 confirmPublish(pub); 68 confirmPublish(pub);
69 69
70 server.handle('POST', '/token', (request, response) { 70 server.handle('POST', '/token', (request, response) {
71 return consumeInputStream(request.inputStream).then((bytes) { 71 return consumeInputStream(request.inputStream).then((bytes) {
72 var body = new String.fromCharCodes(bytes); 72 var body = new String.fromCharCodes(bytes);
73 expect(body, matches( 73 expect(body, matches(
74 new RegExp(r'(^|&)refresh_token=refresh\+token(&|$)'))); 74 new RegExp(r'(^|&)refresh_token=refresh\+token(&|$)')));
(...skipping 19 matching lines...) Expand all
94 credentialsFile(server, 'new access token', refreshToken: 'refresh token') 94 credentialsFile(server, 'new access token', refreshToken: 'refresh token')
95 .scheduleValidate(); 95 .scheduleValidate();
96 96
97 run(); 97 run();
98 }); 98 });
99 99
100 test('with an expired credentials.json without a refresh token, ' 100 test('with an expired credentials.json without a refresh token, '
101 'authenticates again and saves credentials.json', () { 101 'authenticates again and saves credentials.json', () {
102 var server = new ScheduledServer(); 102 var server = new ScheduledServer();
103 credentialsFile(server, 'access token', 103 credentialsFile(server, 'access token',
104 expiration: new Date.now().subtract(new Duration(hours: 1))) 104 expiration: new DateTime.now().subtract(new Duration(hours: 1)))
105 .scheduleCreate(); 105 .scheduleCreate();
106 106
107 var pub = startPubLish(server); 107 var pub = startPubLish(server);
108 confirmPublish(pub); 108 confirmPublish(pub);
109 109
110 expectLater(pub.nextErrLine(), equals("Pub's authorization to upload " 110 expectLater(pub.nextErrLine(), equals("Pub's authorization to upload "
111 "packages has expired and can't be automatically refreshed.")); 111 "packages has expired and can't be automatically refreshed."));
112 authorizePub(pub, server, "new access token"); 112 authorizePub(pub, server, "new access token");
113 113
114 server.handle('GET', '/packages/versions/new.json', (request, response) { 114 server.handle('GET', '/packages/versions/new.json', (request, response) {
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 215
216 response.headers.contentType = new ContentType("application", "json"); 216 response.headers.contentType = new ContentType("application", "json");
217 response.outputStream.writeString(JSON.stringify({ 217 response.outputStream.writeString(JSON.stringify({
218 "access_token": accessToken, 218 "access_token": accessToken,
219 "token_type": "bearer" 219 "token_type": "bearer"
220 })); 220 }));
221 response.outputStream.close(); 221 response.outputStream.close();
222 }); 222 });
223 }); 223 });
224 } 224 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698