Chromium Code Reviews| 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).')); |
|
Bob Nystrom
2012/12/17 18:41:58
If we show the error before retrying, I think we s
nweiz
2012/12/17 21:18:48
The user has to re-authorize before retrying, whic
|
| + // 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, |