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 pub_lish_test; | 5 library pub_lish_test; |
6 | 6 |
7 import 'dart:io'; | 7 import 'dart:io'; |
8 import 'dart:json'; | 8 import 'dart:json'; |
9 | 9 |
10 import 'test_pub.dart'; | 10 import 'test_pub.dart'; |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 'Looks great! Are you ready to upload your package (y/n)?' | 72 'Looks great! Are you ready to upload your package (y/n)?' |
73 ' Package test_pkg 1.0.0 uploaded!')); | 73 ' Package test_pkg 1.0.0 uploaded!')); |
74 pub.shouldExit(0); | 74 pub.shouldExit(0); |
75 | 75 |
76 run(); | 76 run(); |
77 }); | 77 }); |
78 | 78 |
79 // TODO(nweiz): Once a multipart/form-data parser in Dart exists, we should | 79 // TODO(nweiz): Once a multipart/form-data parser in Dart exists, we should |
80 // test that "pub lish" chooses the correct files to publish. | 80 // test that "pub lish" chooses the correct files to publish. |
81 | 81 |
82 test('credentials are invalid', () { | |
83 var server = new ScheduledServer(); | |
84 credentialsFile(server, 'access token').scheduleCreate(); | |
85 var pub = startPubLish(server); | |
86 | |
87 confirmPublish(pub); | |
88 | |
89 server.handle('GET', '/packages/versions/new.json', (request, response) { | |
90 response.statusCode = 401; | |
91 response.headers.set('www-authenticate', 'Bearer error="invalid_token",' | |
92 ' error_description="your token sucks"'); | |
93 response.outputStream.writeString(JSON.stringify({ | |
94 'error': {'message': 'your token sucks'} | |
95 })); | |
96 response.outputStream.close(); | |
97 }); | |
98 | |
99 expectLater(pub.nextErrLine(), equals('OAuth2 authorization failed (your ' | |
100 'token sucks).')); | |
101 // TODO(rnystrom): The confirm line is run together with this one because | |
102 // in normal usage, the user will have entered a newline on stdin which | |
103 // gets echoed to the terminal. Do something better here? | |
104 expectLater(pub.nextLine(), equals( | |
105 'Looks great! Are you ready to upload your package (y/n)? ' | |
106 'Pub needs your authorization to upload packages on your behalf.')); | |
107 pub.kill(); | |
108 run(); | |
109 }); | |
110 | |
111 test('package validation has an error', () { | 82 test('package validation has an error', () { |
112 var package = package("test_pkg", "1.0.0"); | 83 var package = package("test_pkg", "1.0.0"); |
113 package.remove("homepage"); | 84 package.remove("homepage"); |
114 dir(appPath, [pubspec(package)]).scheduleCreate(); | 85 dir(appPath, [pubspec(package)]).scheduleCreate(); |
115 | 86 |
116 var server = new ScheduledServer(); | 87 var server = new ScheduledServer(); |
117 var pub = startPubLish(server); | 88 var pub = startPubLish(server); |
118 | 89 |
119 pub.shouldExit(1); | 90 pub.shouldExit(1); |
120 expectLater(pub.remainingStderr(), | 91 expectLater(pub.remainingStderr(), |
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
426 response.outputStream.close(); | 397 response.outputStream.close(); |
427 }); | 398 }); |
428 | 399 |
429 expectLater(pub.nextErrLine(), equals('Invalid server response:')); | 400 expectLater(pub.nextErrLine(), equals('Invalid server response:')); |
430 expectLater(pub.nextErrLine(), equals(JSON.stringify(body))); | 401 expectLater(pub.nextErrLine(), equals(JSON.stringify(body))); |
431 pub.shouldExit(1); | 402 pub.shouldExit(1); |
432 | 403 |
433 run(); | 404 run(); |
434 }); | 405 }); |
435 } | 406 } |
OLD | NEW |