| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | |
| 2 // for details. All rights reserved. Use of this source code is governed by a | |
| 3 // BSD-style license that can be found in the LICENSE file. | |
| 4 | |
| 5 import 'dart:convert'; | |
| 6 | |
| 7 import 'package:scheduled_test/scheduled_test.dart'; | |
| 8 import 'package:scheduled_test/scheduled_server.dart'; | |
| 9 import 'package:shelf/shelf.dart' as shelf; | |
| 10 | |
| 11 import '../../lib/src/io.dart'; | |
| 12 import '../descriptor.dart' as d; | |
| 13 import '../test_pub.dart'; | |
| 14 import 'utils.dart'; | |
| 15 | |
| 16 main() { | |
| 17 initConfig(); | |
| 18 // Regression test for issue 8849. | |
| 19 integration( | |
| 20 'with a server-rejected refresh token, authenticates again and ' | |
| 21 'saves credentials.json', | |
| 22 () { | |
| 23 d.validPackage.create(); | |
| 24 | |
| 25 var server = new ScheduledServer(); | |
| 26 d.credentialsFile( | |
| 27 server, | |
| 28 'access token', | |
| 29 refreshToken: 'bad refresh token', | |
| 30 expiration: new DateTime.now().subtract(new Duration(hours: 1))).create(
); | |
| 31 | |
| 32 var pub = startPublish(server); | |
| 33 | |
| 34 confirmPublish(pub); | |
| 35 | |
| 36 server.handle('POST', '/token', (request) { | |
| 37 return drainStream(request.read()).then((_) { | |
| 38 return new shelf.Response(400, body: JSON.encode({ | |
| 39 "error": "invalid_request" | |
| 40 }), headers: { | |
| 41 'content-type': 'application/json' | |
| 42 }); | |
| 43 }); | |
| 44 }); | |
| 45 | |
| 46 pub.stdout.expect(startsWith('Uploading...')); | |
| 47 authorizePub(pub, server, 'new access token'); | |
| 48 | |
| 49 server.handle('GET', '/api/packages/versions/new', (request) { | |
| 50 expect( | |
| 51 request.headers, | |
| 52 containsPair('authorization', 'Bearer new access token')); | |
| 53 | |
| 54 return new shelf.Response(200); | |
| 55 }); | |
| 56 | |
| 57 pub.kill(); | |
| 58 }); | |
| 59 } | |
| OLD | NEW |