| 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 import 'dart:convert'; |
| 5 import 'dart:io'; | 6 import 'dart:io'; |
| 6 import 'dart:json' as json; | |
| 7 | 7 |
| 8 import 'package:scheduled_test/scheduled_test.dart'; | 8 import 'package:scheduled_test/scheduled_test.dart'; |
| 9 import 'package:scheduled_test/scheduled_server.dart'; | 9 import 'package:scheduled_test/scheduled_server.dart'; |
| 10 | 10 |
| 11 import '../../lib/src/io.dart'; | 11 import '../../lib/src/io.dart'; |
| 12 import '../descriptor.dart' as d; | 12 import '../descriptor.dart' as d; |
| 13 import '../test_pub.dart'; | 13 import '../test_pub.dart'; |
| 14 | 14 |
| 15 main() { | 15 main() { |
| 16 initConfig(); | 16 initConfig(); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 28 confirmPublish(pub); | 28 confirmPublish(pub); |
| 29 | 29 |
| 30 server.handle('POST', '/token', (request) { | 30 server.handle('POST', '/token', (request) { |
| 31 return new ByteStream(request).toBytes().then((bytes) { | 31 return new ByteStream(request).toBytes().then((bytes) { |
| 32 var body = new String.fromCharCodes(bytes); | 32 var body = new String.fromCharCodes(bytes); |
| 33 expect(body, matches( | 33 expect(body, matches( |
| 34 new RegExp(r'(^|&)refresh_token=refresh\+token(&|$)'))); | 34 new RegExp(r'(^|&)refresh_token=refresh\+token(&|$)'))); |
| 35 | 35 |
| 36 request.response.headers.contentType = | 36 request.response.headers.contentType = |
| 37 new ContentType("application", "json"); | 37 new ContentType("application", "json"); |
| 38 request.response.write(json.stringify({ | 38 request.response.write(JSON.encode({ |
| 39 "access_token": "new access token", | 39 "access_token": "new access token", |
| 40 "token_type": "bearer" | 40 "token_type": "bearer" |
| 41 })); | 41 })); |
| 42 request.response.close(); | 42 request.response.close(); |
| 43 }); | 43 }); |
| 44 }); | 44 }); |
| 45 | 45 |
| 46 server.handle('GET', '/api/packages/versions/new', (request) { | 46 server.handle('GET', '/api/packages/versions/new', (request) { |
| 47 expect(request.headers.value('authorization'), | 47 expect(request.headers.value('authorization'), |
| 48 equals('Bearer new access token')); | 48 equals('Bearer new access token')); |
| 49 | 49 |
| 50 request.response.close(); | 50 request.response.close(); |
| 51 }); | 51 }); |
| 52 | 52 |
| 53 pub.shouldExit(); | 53 pub.shouldExit(); |
| 54 | 54 |
| 55 d.credentialsFile(server, 'new access token', refreshToken: 'refresh token') | 55 d.credentialsFile(server, 'new access token', refreshToken: 'refresh token') |
| 56 .validate(); | 56 .validate(); |
| 57 }); | 57 }); |
| 58 } | 58 } |
| OLD | NEW |