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

Unified Diff: utils/tests/pub/oauth2/utils.dart

Issue 14297021: Move pub into sdk/lib/_internal. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Disallow package: imports of pub. Created 7 years, 8 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 side-by-side diff with in-line comments
Download patch
Index: utils/tests/pub/oauth2/utils.dart
diff --git a/utils/tests/pub/oauth2/utils.dart b/utils/tests/pub/oauth2/utils.dart
deleted file mode 100644
index c0b7e97028edc3d40b8d20cbbb7c04dcc1cc2358..0000000000000000000000000000000000000000
--- a/utils/tests/pub/oauth2/utils.dart
+++ /dev/null
@@ -1,62 +0,0 @@
-// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE file.
-
-library oauth2.utils;
-
-import 'dart:io';
-import 'dart:json' as json;
-import 'dart:uri';
-
-import 'package:http/http.dart' as http;
-import 'package:scheduled_test/scheduled_process.dart';
-import 'package:scheduled_test/scheduled_test.dart';
-import 'package:scheduled_test/scheduled_server.dart';
-
-import '../../../pub/io.dart';
-import '../../../pub/utils.dart';
-import '../test_pub.dart';
-
-void authorizePub(ScheduledProcess pub, ScheduledServer server,
- [String accessToken="access token"]) {
- // TODO(rnystrom): The confirm line is run together with this one because
- // in normal usage, the user will have entered a newline on stdin which
- // gets echoed to the terminal. Do something better here?
- expect(pub.nextLine(), completion(equals(
- 'Looks great! Are you ready to upload your package (y/n)? '
- 'Pub needs your authorization to upload packages on your behalf.')));
-
- expect(pub.nextLine().then((line) {
- var match = new RegExp(r'[?&]redirect_uri=([0-9a-zA-Z%+-]+)[$&]')
- .firstMatch(line);
- expect(match, isNotNull);
-
- var redirectUrl = Uri.parse(decodeUriComponent(match.group(1)));
- redirectUrl = addQueryParameters(redirectUrl, {'code': 'access code'});
- return (new http.Request('GET', redirectUrl)..followRedirects = false)
- .send();
- }).then((response) {
- expect(response.headers['location'],
- equals('http://pub.dartlang.org/authorized'));
- }), completes);
-
- handleAccessTokenRequest(server, accessToken);
-}
-
-void handleAccessTokenRequest(ScheduledServer server, String accessToken) {
- server.handle('POST', '/token', (request) {
- return new ByteStream(request).toBytes().then((bytes) {
- var body = new String.fromCharCodes(bytes);
- expect(body, matches(new RegExp(r'(^|&)code=access\+code(&|$)')));
-
- request.response.headers.contentType =
- new ContentType("application", "json");
- request.response.write(json.stringify({
- "access_token": accessToken,
- "token_type": "bearer"
- }));
- request.response.close();
- });
- });
-}
-
« no previous file with comments | « utils/tests/pub/lock_file_test.dart ('k') | utils/tests/pub/oauth2/with_a_malformed_credentials_authenticates_again_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698