commit 869a784b593116d33b6e133a5dbe9169d2beec80
parent ba9297eabfe89f9df07465c9ac5cf3d32bb3a874
Author: Johann150 <johann.galle@protonmail.com>
Date: Thu, 8 Apr 2021 00:11:47 +0200
add tests for fragment and userinfo URLs
Diffstat:
1 file changed, 39 insertions(+), 0 deletions(-)
diff --git a/tests/tests.rs b/tests/tests.rs
@@ -245,6 +245,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"
fn hostname_check() {