Skip to content

Commit e865596

Browse files
committed
tests/krate/publish/validation: Add basic invalid_urls() test
1 parent ce82234 commit e865596

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
source: src/tests/krate/publish/validation.rs
3+
expression: response.into_json()
4+
---
5+
{
6+
"errors": [
7+
{
8+
"detail": "URL for field `documentation` must begin with http:// or https:// (url: javascript:alert('boom'))"
9+
}
10+
]
11+
}

src/tests/krate/publish/validation.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,3 +86,16 @@ fn license_and_description_required() {
8686

8787
assert!(app.stored_files().is_empty());
8888
}
89+
90+
#[test]
91+
fn invalid_urls() {
92+
let (app, _, _, token) = TestApp::full().with_token();
93+
94+
let response = token.publish_crate(
95+
PublishBuilder::new("foo", "1.0.0").documentation("javascript:alert('boom')"),
96+
);
97+
assert_eq!(response.status(), StatusCode::OK);
98+
assert_json_snapshot!(response.into_json());
99+
100+
assert!(app.stored_files().is_empty());
101+
}

0 commit comments

Comments
 (0)