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.utils; | 5 library oauth2.utils; |
6 | 6 |
7 import 'dart:io'; | 7 import 'dart:io'; |
8 import 'dart:json' as json; | 8 import 'dart:json' as json; |
9 import 'dart:uri'; | 9 import 'dart:uri'; |
10 | 10 |
11 import 'package:http/http.dart' as http; | 11 import 'package:http/http.dart' as http; |
12 import 'package:scheduled_test/scheduled_process.dart'; | 12 import 'package:scheduled_test/scheduled_process.dart'; |
13 import 'package:scheduled_test/scheduled_test.dart'; | 13 import 'package:scheduled_test/scheduled_test.dart'; |
14 import 'package:scheduled_test/scheduled_server.dart'; | 14 import 'package:scheduled_test/scheduled_server.dart'; |
15 | 15 |
16 import '../../../pub/io.dart'; | 16 import '../../lib/src/io.dart'; |
17 import '../../../pub/utils.dart'; | 17 import '../../lib/src/utils.dart'; |
18 import '../test_pub.dart'; | 18 import '../test_pub.dart'; |
19 | 19 |
20 void authorizePub(ScheduledProcess pub, ScheduledServer server, | 20 void authorizePub(ScheduledProcess pub, ScheduledServer server, |
21 [String accessToken="access token"]) { | 21 [String accessToken="access token"]) { |
22 // TODO(rnystrom): The confirm line is run together with this one because | 22 // TODO(rnystrom): The confirm line is run together with this one because |
23 // in normal usage, the user will have entered a newline on stdin which | 23 // in normal usage, the user will have entered a newline on stdin which |
24 // gets echoed to the terminal. Do something better here? | 24 // gets echoed to the terminal. Do something better here? |
25 expect(pub.nextLine(), completion(equals( | 25 expect(pub.nextLine(), completion(equals( |
26 'Looks great! Are you ready to upload your package (y/n)? ' | 26 'Looks great! Are you ready to upload your package (y/n)? ' |
27 'Pub needs your authorization to upload packages on your behalf.'))); | 27 'Pub needs your authorization to upload packages on your behalf.'))); |
(...skipping 25 matching lines...) Expand all Loading... |
53 new ContentType("application", "json"); | 53 new ContentType("application", "json"); |
54 request.response.write(json.stringify({ | 54 request.response.write(json.stringify({ |
55 "access_token": accessToken, | 55 "access_token": accessToken, |
56 "token_type": "bearer" | 56 "token_type": "bearer" |
57 })); | 57 })); |
58 request.response.close(); | 58 request.response.close(); |
59 }); | 59 }); |
60 }); | 60 }); |
61 } | 61 } |
62 | 62 |
OLD | NEW |