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

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

Issue 11569046: Add a pub command for managing uploaders for packages. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Code review changes Created 8 years 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
« no previous file with comments | « utils/pub/pub.dart ('k') | utils/tests/pub/pub_lish_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: utils/tests/pub/oauth2_test.dart
diff --git a/utils/tests/pub/oauth2_test.dart b/utils/tests/pub/oauth2_test.dart
index f640e114326546ec17a87bafb05d7e2224cdcfc7..08d97fe4861c15f5956ac259827f7f6579e595ec 100644
--- a/utils/tests/pub/oauth2_test.dart
+++ b/utils/tests/pub/oauth2_test.dart
@@ -149,6 +149,36 @@ main() {
run();
});
+
+ test('with server-rejected credentials, authenticates again and saves '
+ 'credentials.json', () {
+ var server = new ScheduledServer();
+ credentialsFile(server, 'access token').scheduleCreate();
+ var pub = startPubLish(server);
+
+ confirmPublish(pub);
+
+ server.handle('GET', '/packages/versions/new.json', (request, response) {
+ response.statusCode = 401;
+ response.headers.set('www-authenticate', 'Bearer error="invalid_token",'
+ ' error_description="your token sucks"');
+ response.outputStream.writeString(JSON.stringify({
+ 'error': {'message': 'your token sucks'}
+ }));
+ response.outputStream.close();
+ });
+
+ expectLater(pub.nextErrLine(), equals('OAuth2 authorization failed (your '
+ 'token sucks).'));
+ // 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?
+ expectLater(pub.nextLine(), equals(
+ 'Looks great! Are you ready to upload your package (y/n)? '
+ 'Pub needs your authorization to upload packages on your behalf.'));
+ pub.kill();
+ run();
+ });
}
void authorizePub(ScheduledProcess pub, ScheduledServer server,
« no previous file with comments | « utils/pub/pub.dart ('k') | utils/tests/pub/pub_lish_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698