OLD | NEW |
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 'package:scheduled_test/scheduled_test.dart'; | 1 import 'package:scheduled_test/scheduled_test.dart'; |
6 import 'package:scheduled_test/scheduled_server.dart'; | 2 import 'package:scheduled_test/scheduled_server.dart'; |
7 import 'package:shelf/shelf.dart' as shelf; | 3 import 'package:shelf/shelf.dart' as shelf; |
8 | |
9 import '../descriptor.dart' as d; | 4 import '../descriptor.dart' as d; |
10 import '../test_pub.dart'; | 5 import '../test_pub.dart'; |
11 | 6 import 'utils.dart'; |
12 main() { | 7 main() { |
13 initConfig(); | 8 initConfig(); |
14 integration('with a pre-existing credentials.json does not authenticate', () { | 9 integration( |
| 10 'with no credentials.json, authenticates and saves ' 'credentials.json', |
| 11 () { |
15 d.validPackage.create(); | 12 d.validPackage.create(); |
16 | |
17 var server = new ScheduledServer(); | 13 var server = new ScheduledServer(); |
18 d.credentialsFile(server, 'access token').create(); | |
19 var pub = startPublish(server); | 14 var pub = startPublish(server); |
20 confirmPublish(pub); | 15 confirmPublish(pub); |
21 | 16 authorizePub(pub, server); |
22 server.handle('GET', '/api/packages/versions/new', (request) { | 17 server.handle('GET', '/api/packages/versions/new', (request) { |
23 expect(request.headers, | 18 expect( |
| 19 request.headers, |
24 containsPair('authorization', 'Bearer access token')); | 20 containsPair('authorization', 'Bearer access token')); |
25 | |
26 return new shelf.Response(200); | 21 return new shelf.Response(200); |
27 }); | 22 }); |
28 | 23 pub.shouldExit(1); |
29 pub.kill(); | 24 d.credentialsFile(server, 'access token').validate(); |
30 }); | 25 }); |
31 } | 26 } |
OLD | NEW |