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

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

Issue 12428012: Properly handle errors from the OAuth2 token endpoint in pub. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Minor changes Created 7 years, 9 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
« no previous file with comments | « utils/pub/oauth2.dart ('k') | no next file » | 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 82c4e2ab0a49d10958c564b4e3e6bd4c25b34df8..afeedc6521dc5232dce6a3c31d3623af8a464b27 100644
--- a/utils/tests/pub/oauth2_test.dart
+++ b/utils/tests/pub/oauth2_test.dart
@@ -147,6 +147,40 @@ main() {
credentialsFile(server, 'new access token').scheduleValidate();
});
+ // Regression test for issue 8849.
+ integration('with a server-rejected refresh token, authenticates again and '
+ 'saves credentials.json', () {
+ var server = new ScheduledServer();
+ credentialsFile(server, 'access token',
+ refreshToken: 'bad refresh token',
+ expiration: new DateTime.now().subtract(new Duration(hours: 1)))
+ .scheduleCreate();
+
+ var pub = startPubLish(server);
+ confirmPublish(pub);
+
+ server.handle('POST', '/token', (request, response) {
+ return new ByteStream(request).toBytes().then((bytes) {
+ response.statusCode = 400;
+ response.reasonPhrase = 'Bad request';
+ response.headers.contentType = new ContentType("application", "json");
+ response.write(json.stringify({"error": "invalid_request"}));
+ response.close();
+ });
+ });
+
+ authorizePub(pub, server, 'new access token');
+
+ server.handle('GET', '/packages/versions/new.json', (request, response) {
+ expect(request.headers.value('authorization'),
+ equals('Bearer new access token'));
+
+ response.close();
+ });
+
+ pub.kill();
+ });
+
integration('with server-rejected credentials, authenticates again and saves '
'credentials.json', () {
var server = new ScheduledServer();
@@ -218,3 +252,4 @@ void handleAccessTokenRequest(ScheduledServer server, String accessToken) {
});
});
}
+
« no previous file with comments | « utils/pub/oauth2.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698