add tests for fragment and userinfo URLs

This commit is contained in:
Johann150 2021-04-08 00:11:47 +02:00
parent ba9297eabf
commit 869a784b59
No known key found for this signature in database
GPG key ID: 9EE6577A2A06F8F1

View file

@ -244,6 +244,45 @@ fn full_header_preset() {
);
}
#[test]
/// - URLS with fragments are rejected
fn fragment() {
let page = get(
&["--addr", "[::]:1983", "--hostname", "example.com"],
addr(1983),
"gemini://example.com/#fragment",
)
.expect("could not get page");
assert_eq!(page.header.status, Status::BadRequest);
}
#[test]
/// - URLS with username are rejected
fn username() {
let page = get(
&["--addr", "[::]:1984", "--hostname", "example.com"],
addr(1984),
"gemini://user@example.com/",
)
.expect("could not get page");
assert_eq!(page.header.status, Status::BadRequest);
}
#[test]
/// - URLS with password are rejected
fn password() {
let page = get(
&["--addr", "[::]:1984", "--hostname", "example.com"],
addr(1984),
"gemini://:secret@example.com/",
)
.expect("could not get page");
assert_eq!(page.header.status, Status::BadRequest);
}
#[test]
/// - hostname is checked when provided
/// - status for wrong host is "proxy request refused"