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

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

Issue 11785028: Commit Martin's patch for pub + lib_v2. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Revise. 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
« no previous file with comments | « utils/tests/pub/io_test.dart ('k') | utils/tests/pub/pub_uploader_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 183
184 void authorizePub(ScheduledProcess pub, ScheduledServer server, 184 void authorizePub(ScheduledProcess pub, ScheduledServer server,
185 [String accessToken="access token"]) { 185 [String accessToken="access token"]) {
186 // TODO(rnystrom): The confirm line is run together with this one because 186 // TODO(rnystrom): The confirm line is run together with this one because
187 // in normal usage, the user will have entered a newline on stdin which 187 // in normal usage, the user will have entered a newline on stdin which
188 // gets echoed to the terminal. Do something better here? 188 // gets echoed to the terminal. Do something better here?
189 expectLater(pub.nextLine(), equals( 189 expectLater(pub.nextLine(), equals(
190 'Looks great! Are you ready to upload your package (y/n)? ' 190 'Looks great! Are you ready to upload your package (y/n)? '
191 'Pub needs your authorization to upload packages on your behalf.')); 191 'Pub needs your authorization to upload packages on your behalf.'));
192 192
193 expectLater(pub.nextLine().chain((line) { 193 expectLater(pub.nextLine().then((line) {
194 var match = new RegExp(r'[?&]redirect_uri=([0-9a-zA-Z%+-]+)[$&]') 194 var match = new RegExp(r'[?&]redirect_uri=([0-9a-zA-Z%+-]+)[$&]')
195 .firstMatch(line); 195 .firstMatch(line);
196 expect(match, isNotNull); 196 expect(match, isNotNull);
197 197
198 var redirectUrl = new Uri.fromString(decodeUriComponent(match.group(1))); 198 var redirectUrl = new Uri.fromString(decodeUriComponent(match.group(1)));
199 redirectUrl = addQueryParameters(redirectUrl, {'code': 'access code'}); 199 redirectUrl = addQueryParameters(redirectUrl, {'code': 'access code'});
200 return (new http.Request('GET', redirectUrl)..followRedirects = false) 200 return (new http.Request('GET', redirectUrl)..followRedirects = false)
201 .send(); 201 .send();
202 }).then((response) { 202 }).then((response) {
203 expect(response.headers['location'], 203 expect(response.headers['location'],
(...skipping 11 matching lines...) Expand all
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
« no previous file with comments | « utils/tests/pub/io_test.dart ('k') | utils/tests/pub/pub_uploader_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698