Skip to content

Commit 45f9294

Browse files
authored
test(badssl): add test case for wrong host on BadSSL (#1202)
1 parent 556d025 commit 45f9294

1 file changed

Lines changed: 31 additions & 5 deletions

File tree

tests/badssl.rs

Lines changed: 31 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ macro_rules! join {
1515
async fn test_badssl_modern() {
1616
let text = Client::builder()
1717
.no_proxy()
18-
.connect_timeout(Duration::from_secs(360))
1918
.build()
2019
.unwrap()
2120
.get("https://mozilla-modern.badssl.com/")
@@ -26,14 +25,13 @@ async fn test_badssl_modern() {
2625
.await
2726
.unwrap();
2827

29-
assert!(!text.is_empty());
28+
assert!(text.contains("<title>mozilla-modern.badssl.com</title>"));
3029
}
3130

3231
#[tokio::test]
3332
async fn test_badssl_self_signed() {
3433
let text = Client::builder()
3534
.tls_cert_verification(false)
36-
.connect_timeout(Duration::from_secs(360))
3735
.no_proxy()
3836
.build()
3937
.unwrap()
@@ -45,8 +43,37 @@ async fn test_badssl_self_signed() {
4543
.await
4644
.unwrap();
4745

48-
assert!(!text.is_empty());
46+
assert!(text.contains("<title>self-signed.badssl.com</title>"));
47+
}
48+
49+
#[tokio::test]
50+
async fn test_badssl_wrong_host() {
51+
let text = Client::builder()
52+
.tls_verify_hostname(false)
53+
.no_proxy()
54+
.build()
55+
.unwrap()
56+
.get("https://wrong.host.badssl.com/")
57+
.send()
58+
.await
59+
.unwrap()
60+
.text()
61+
.await
62+
.unwrap();
63+
64+
assert!(text.contains("<title>wrong.host.badssl.com</title>"));
65+
66+
let result = Client::builder()
67+
.tls_verify_hostname(false)
68+
.build()
69+
.unwrap()
70+
.get("https://self-signed.badssl.com/")
71+
.send()
72+
.await;
73+
74+
assert!(result.is_err());
4975
}
76+
5077
const CURVES_LIST: &str = join!(
5178
":",
5279
"X25519",
@@ -189,7 +216,6 @@ async fn test_aes_hw_override() -> wreq::Result<()> {
189216
async fn test_tls_self_signed_cert() {
190217
let client = Client::builder()
191218
.tls_cert_verification(false)
192-
.connect_timeout(Duration::from_secs(360))
193219
.tls_info(true)
194220
.build()
195221
.unwrap();

0 commit comments

Comments
 (0)