summaryrefslogtreecommitdiff
path: root/cli/tests/integration/mod.rs
diff options
context:
space:
mode:
Diffstat (limited to 'cli/tests/integration/mod.rs')
-rw-r--r--cli/tests/integration/mod.rs49
1 files changed, 49 insertions, 0 deletions
diff --git a/cli/tests/integration/mod.rs b/cli/tests/integration/mod.rs
index 4ada4ef54..e3450c8a1 100644
--- a/cli/tests/integration/mod.rs
+++ b/cli/tests/integration/mod.rs
@@ -2,6 +2,7 @@
use crate::itest;
use deno_core::url;
+use deno_runtime::deno_fetch::reqwest;
use deno_runtime::deno_net::ops_tls::TlsStream;
use deno_runtime::deno_tls::rustls;
use deno_runtime::deno_tls::webpki;
@@ -1229,3 +1230,51 @@ async fn listen_tls_alpn_fail() {
})
.await;
}
+
+#[tokio::test]
+async fn http2_request_url() {
+ // TLS streams require the presence of an ambient local task set to gracefully
+ // close dropped connections in the background.
+ LocalSet::new()
+ .run_until(async {
+ let mut child = util::deno_cmd()
+ .current_dir(util::testdata_path())
+ .arg("run")
+ .arg("--unstable")
+ .arg("--quiet")
+ .arg("--allow-net")
+ .arg("--allow-read")
+ .arg("./http2_request_url.ts")
+ .arg("4506")
+ .stdout(std::process::Stdio::piped())
+ .spawn()
+ .unwrap();
+ let stdout = child.stdout.as_mut().unwrap();
+ let mut buffer = [0; 5];
+ let read = stdout.read(&mut buffer).unwrap();
+ assert_eq!(read, 5);
+ let msg = std::str::from_utf8(&buffer).unwrap();
+ assert_eq!(msg, "READY");
+
+ let cert = reqwest::Certificate::from_pem(include_bytes!(
+ "../testdata/tls/RootCA.crt"
+ ))
+ .unwrap();
+
+ let client = reqwest::Client::builder()
+ .add_root_certificate(cert)
+ .http2_prior_knowledge()
+ .build()
+ .unwrap();
+
+ let res = client.get("http://127.0.0.1:4506").send().await.unwrap();
+ assert_eq!(200, res.status());
+
+ let body = res.text().await.unwrap();
+ assert_eq!(body, "http://127.0.0.1:4506/");
+
+ child.kill().unwrap();
+ child.wait().unwrap();
+ })
+ .await;
+}