Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(629)

Unified Diff: utils/tests/pub/pubspec_test.dart

Issue 11412017: Validate that the homepage is using an approved scheme. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « utils/pub/pubspec.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: utils/tests/pub/pubspec_test.dart
diff --git a/utils/tests/pub/pubspec_test.dart b/utils/tests/pub/pubspec_test.dart
index 92976e8c1979114885a3f7f81820ab52f202c68b..dabb7dd44508643b00b6acb5dbc36e55e1592009 100644
--- a/utils/tests/pub/pubspec_test.dart
+++ b/utils/tests/pub/pubspec_test.dart
@@ -26,6 +26,11 @@ main() {
var sources = new SourceRegistry();
sources.register(new MockSource());
+ expectFormatError(String pubspec) {
+ expect(() => new Pubspec.parse(pubspec, sources),
+ throwsFormatException);
+ }
+
test("allows a version constraint for dependencies", () {
var pubspec = new Pubspec.parse('''
dependencies:
@@ -50,55 +55,51 @@ dependencies:
});
test("throws if the description isn't valid", () {
- expect(() {
- new Pubspec.parse('''
+ expectFormatError('''
dependencies:
foo:
mock: bad
-''', sources);
- }, throwsFormatException);
+''');
});
test("throws if 'name' is not a string", () {
- expect(() => new Pubspec.parse('name: [not, a, string]', sources),
- throwsFormatException);
+ expectFormatError('name: [not, a, string]');
});
test("throws if 'homepage' is not a string", () {
- expect(() => new Pubspec.parse('homepage: [not, a, string]', sources),
- throwsFormatException);
+ expectFormatError('homepage:');
+ expectFormatError('homepage: [not, a, string]');
+ });
+
+ test("throws if 'homepage' doesn't have an HTTP scheme", () {
+ new Pubspec.parse('homepage: http://ok.com', sources);
+ new Pubspec.parse('homepage: https://also-ok.com', sources);
+
+ expectFormatError('ftp://badscheme.com');
+ expectFormatError('javascript:alert("!!!")');
+ expectFormatError('data:image/png;base64,somedata');
+ expectFormatError('homepage: no-scheme.com');
});
test("throws if 'authors' is not a string or a list of strings", () {
new Pubspec.parse('authors: ok fine', sources);
new Pubspec.parse('authors: [also, ok, fine]', sources);
- expect(() => new Pubspec.parse('authors: 123', sources),
- throwsFormatException);
-
- expect(() => new Pubspec.parse('authors: {not: {a: string}}', sources),
- throwsFormatException);
-
- expect(() => new Pubspec.parse('authors: [ok, {not: ok}]', sources),
- throwsFormatException);
+ expectFormatError('authors: 123');
+ expectFormatError('authors: {not: {a: string}}');
+ expectFormatError('authors: [ok, {not: ok}]');
});
test("throws if 'author' is not a string", () {
new Pubspec.parse('author: ok fine', sources);
- expect(() => new Pubspec.parse('author: 123', sources),
- throwsFormatException);
-
- expect(() => new Pubspec.parse('author: {not: {a: string}}', sources),
- throwsFormatException);
-
- expect(() => new Pubspec.parse('author: [not, ok]', sources),
- throwsFormatException);
+ expectFormatError('author: 123');
+ expectFormatError('author: {not: {a: string}}');
+ expectFormatError('author: [not, ok]');
});
test("throws if both 'author' and 'authors' are present", () {
- expect(() => new Pubspec.parse('{author: abe, authors: ted}', sources),
- throwsFormatException);
+ expectFormatError('{author: abe, authors: ted}');
});
test("allows comment-only files", () {
« no previous file with comments | « utils/pub/pubspec.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698