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

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

Issue 11416352: Handle OAuth2 AuthorizationExceptions in pub. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: 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/oauth2.dart ('k') | utils/tests/pub/test_pub.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: utils/tests/pub/pub_lish_test.dart
diff --git a/utils/tests/pub/pub_lish_test.dart b/utils/tests/pub/pub_lish_test.dart
index aa67161184e75eb01a9954e972d38cf9071d550c..165572a3856eaa6865683546bd233b274c46b4cf 100644
--- a/utils/tests/pub/pub_lish_test.dart
+++ b/utils/tests/pub/pub_lish_test.dart
@@ -72,8 +72,29 @@ main() {
// TODO(nweiz): Once a multipart/form-data parser in Dart exists, we should
// test that "pub lish" chooses the correct files to publish.
- // TODO(nweiz): Once issue 6813 is fixed, test that OAuth2 authentication
- // errors cause the client to try re-authenticating.
+ test('credentials are invalid', () {
+ var server = new ScheduledServer();
+ credentialsFile(server, 'access token').scheduleCreate();
+ var pub = startPubLish(server);
+
+ 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'}
+ }));
+ return closeHttpResponse(request, response);
+ });
+
+ expectLater(pub.nextErrLine(), equals('OAuth2 authorization failed (your '
Bob Nystrom 2012/12/05 17:39:46 The regular expect() function allows a literal in
nweiz 2012/12/05 19:33:55 That is supported. The "matcher" argument is passe
+ 'token sucks).'));
+ expectLater(pub.nextLine(), equals('Pub needs your authorization to upload '
+ 'packages on your behalf.'));
+ pub.kill();
+
+ run();
+ });
test('upload form provides an error', () {
var server = new ScheduledServer();
« no previous file with comments | « utils/pub/oauth2.dart ('k') | utils/tests/pub/test_pub.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698