| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 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 | 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. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 library oauth2_test; | 5 library oauth2_test; |
| 6 | 6 |
| 7 import 'dart:io'; | 7 import 'dart:io'; |
| 8 import 'dart:json'; | 8 import 'dart:json'; |
| 9 import 'dart:uri'; | 9 import 'dart:uri'; |
| 10 | 10 |
| 11 import 'test_pub.dart'; | 11 import 'test_pub.dart'; |
| 12 import '../../../pkg/http/lib/http.dart' as http; | 12 import '../../../pkg/http/lib/http.dart' as http; |
| 13 import '../../../pkg/unittest/lib/unittest.dart'; | 13 import '../../../pkg/unittest/lib/unittest.dart'; |
| 14 import '../../pub/io.dart'; | 14 import '../../pub/io.dart'; |
| 15 import '../../pub/utils.dart'; | 15 import '../../pub/utils.dart'; |
| 16 | 16 |
| 17 main() { | 17 main() { |
| 18 setUp(() { | 18 setUp(() => normalPackage.scheduleCreate()); |
| 19 dir(appPath, [ | |
| 20 libPubspec("test_pkg", "1.0.0"), | |
| 21 file("LICENSE", "Eh, do what you want.") | |
| 22 ]).scheduleCreate(); | |
| 23 }); | |
| 24 | 19 |
| 25 test('with no credentials.json, authenticates and saves credentials.json', | 20 test('with no credentials.json, authenticates and saves credentials.json', |
| 26 () { | 21 () { |
| 27 var server = new ScheduledServer(); | 22 var server = new ScheduledServer(); |
| 28 var pub = startPubLish(server); | 23 var pub = startPubLish(server); |
| 29 authorizePub(pub, server); | 24 authorizePub(pub, server); |
| 30 | 25 |
| 31 server.handle('GET', '/packages/versions/new.json', (request, response) { | 26 server.handle('GET', '/packages/versions/new.json', (request, response) { |
| 32 expect(request.headers.value('authorization'), | 27 expect(request.headers.value('authorization'), |
| 33 equals('Bearer access token')); | 28 equals('Bearer access token')); |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 181 | 176 |
| 182 response.headers.contentType = new ContentType("application", "json"); | 177 response.headers.contentType = new ContentType("application", "json"); |
| 183 response.outputStream.writeString(JSON.stringify({ | 178 response.outputStream.writeString(JSON.stringify({ |
| 184 "access_token": accessToken, | 179 "access_token": accessToken, |
| 185 "token_type": "bearer" | 180 "token_type": "bearer" |
| 186 })); | 181 })); |
| 187 response.outputStream.close(); | 182 response.outputStream.close(); |
| 188 }); | 183 }); |
| 189 }); | 184 }); |
| 190 } | 185 } |
| OLD | NEW |