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

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

Issue 12052038: Rename new Uri.fromString to Uri.parse. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Reupload because of Error. 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/curl_client_test.dart ('k') | utils/tests/pub/test_pub.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' as json; 8 import 'dart:json' as json;
9 import 'dart:uri'; 9 import 'dart:uri';
10 10
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 // gets echoed to the terminal. Do something better here? 177 // gets echoed to the terminal. Do something better here?
178 expectLater(pub.nextLine(), equals( 178 expectLater(pub.nextLine(), equals(
179 'Looks great! Are you ready to upload your package (y/n)? ' 179 'Looks great! Are you ready to upload your package (y/n)? '
180 'Pub needs your authorization to upload packages on your behalf.')); 180 'Pub needs your authorization to upload packages on your behalf.'));
181 181
182 expectLater(pub.nextLine().then((line) { 182 expectLater(pub.nextLine().then((line) {
183 var match = new RegExp(r'[?&]redirect_uri=([0-9a-zA-Z%+-]+)[$&]') 183 var match = new RegExp(r'[?&]redirect_uri=([0-9a-zA-Z%+-]+)[$&]')
184 .firstMatch(line); 184 .firstMatch(line);
185 expect(match, isNotNull); 185 expect(match, isNotNull);
186 186
187 var redirectUrl = new Uri.fromString(decodeUriComponent(match.group(1))); 187 var redirectUrl = Uri.parse(decodeUriComponent(match.group(1)));
188 redirectUrl = addQueryParameters(redirectUrl, {'code': 'access code'}); 188 redirectUrl = addQueryParameters(redirectUrl, {'code': 'access code'});
189 return (new http.Request('GET', redirectUrl)..followRedirects = false) 189 return (new http.Request('GET', redirectUrl)..followRedirects = false)
190 .send(); 190 .send();
191 }).then((response) { 191 }).then((response) {
192 expect(response.headers['location'], 192 expect(response.headers['location'],
193 equals(['http://pub.dartlang.org/authorized'])); 193 equals(['http://pub.dartlang.org/authorized']));
194 }), anything); 194 }), anything);
195 195
196 handleAccessTokenRequest(server, accessToken); 196 handleAccessTokenRequest(server, accessToken);
197 } 197 }
198 198
199 void handleAccessTokenRequest(ScheduledServer server, String accessToken) { 199 void handleAccessTokenRequest(ScheduledServer server, String accessToken) {
200 server.handle('POST', '/token', (request, response) { 200 server.handle('POST', '/token', (request, response) {
201 return consumeInputStream(request.inputStream).then((bytes) { 201 return consumeInputStream(request.inputStream).then((bytes) {
202 var body = new String.fromCharCodes(bytes); 202 var body = new String.fromCharCodes(bytes);
203 expect(body, matches(new RegExp(r'(^|&)code=access\+code(&|$)'))); 203 expect(body, matches(new RegExp(r'(^|&)code=access\+code(&|$)')));
204 204
205 response.headers.contentType = new ContentType("application", "json"); 205 response.headers.contentType = new ContentType("application", "json");
206 response.outputStream.writeString(json.stringify({ 206 response.outputStream.writeString(json.stringify({
207 "access_token": accessToken, 207 "access_token": accessToken,
208 "token_type": "bearer" 208 "token_type": "bearer"
209 })); 209 }));
210 response.outputStream.close(); 210 response.outputStream.close();
211 }); 211 });
212 }); 212 });
213 } 213 }
OLDNEW
« no previous file with comments | « utils/tests/pub/curl_client_test.dart ('k') | utils/tests/pub/test_pub.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698