summaryrefslogtreecommitdiff
path: root/cli/tests/integration/mod.rs
diff options
context:
space:
mode:
authorBasiqueEvangelist <basiqueevangelist@yandex.ru>2021-09-08 07:18:11 +0300
committerGitHub <noreply@github.com>2021-09-08 06:18:11 +0200
commit08e12380a06509e64e69a1b165f3c007373494c1 (patch)
tree6663b4d38a8d2fd5daf1b3f189a1a1bc67270e64 /cli/tests/integration/mod.rs
parentbf6dbf9855cb21d27838c56932c7536c0cd80a55 (diff)
feat(cli): Support Basic authentication in DENO_AUTH_TOKENS (#11910)
Diffstat (limited to 'cli/tests/integration/mod.rs')
-rw-r--r--cli/tests/integration/mod.rs48
1 files changed, 48 insertions, 0 deletions
diff --git a/cli/tests/integration/mod.rs b/cli/tests/integration/mod.rs
index 7d13c7831..4ada4ef54 100644
--- a/cli/tests/integration/mod.rs
+++ b/cli/tests/integration/mod.rs
@@ -1077,6 +1077,54 @@ fn js_unit_tests() {
assert!(status.success());
}
+#[test]
+fn basic_auth_tokens() {
+ let _g = util::http_server();
+
+ let output = util::deno_cmd()
+ .current_dir(util::root_path())
+ .arg("run")
+ .arg("http://127.0.0.1:4554/001_hello.js")
+ .stdout(std::process::Stdio::piped())
+ .stderr(std::process::Stdio::piped())
+ .spawn()
+ .unwrap()
+ .wait_with_output()
+ .unwrap();
+
+ assert!(!output.status.success());
+
+ let stdout_str = std::str::from_utf8(&output.stdout).unwrap().trim();
+ assert!(stdout_str.is_empty());
+
+ let stderr_str = std::str::from_utf8(&output.stderr).unwrap().trim();
+ eprintln!("{}", stderr_str);
+
+ assert!(stderr_str.contains(
+ "Import 'http://127.0.0.1:4554/001_hello.js' failed: 404 Not Found"
+ ));
+
+ let output = util::deno_cmd()
+ .current_dir(util::root_path())
+ .arg("run")
+ .arg("http://127.0.0.1:4554/001_hello.js")
+ .env("DENO_AUTH_TOKENS", "testuser123:testpassabc@127.0.0.1:4554")
+ .stdout(std::process::Stdio::piped())
+ .stderr(std::process::Stdio::piped())
+ .spawn()
+ .unwrap()
+ .wait_with_output()
+ .unwrap();
+
+ let stderr_str = std::str::from_utf8(&output.stderr).unwrap().trim();
+ eprintln!("{}", stderr_str);
+
+ assert!(output.status.success());
+
+ let stdout_str = std::str::from_utf8(&output.stdout).unwrap().trim();
+ assert_eq!(util::strip_ansi_codes(stdout_str), "Hello World");
+}
+
#[tokio::test]
async fn listen_tls_alpn() {
// TLS streams require the presence of an ambient local task set to gracefully