Skip to content

Commit 3ddb954

Browse files
committed
Fix spin-factor-outbound-http tests
These two tests worked on the assumption that connections to the IPv6 "Discard Prefix" would always result in "connection refused". This is apparently not the case, so switch to using a very short connect timeout as a proxy for successfully passing pre-connect security checks. Signed-off-by: Lann Martin <[email protected]>
1 parent d08fbda commit 3ddb954

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

crates/factor-outbound-http/tests/factor_test.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@ async fn allowed_host_is_allowed() -> anyhow::Result<()> {
2929
let mut future_resp = wasi_http.send_request(req, test_request_config())?;
3030
future_resp.ready().await;
3131

32-
// We don't want to make an actual network request, so treat "connection refused" as success
32+
// We don't want to make an actual network request, so treat the (very short) timeout as success
3333
match future_resp.unwrap_ready().unwrap() {
3434
Ok(_) => bail!("expected Err, got Ok"),
35-
Err(err) => assert!(matches!(err, ErrorCode::ConnectionRefused), "{err:?}"),
35+
Err(err) => assert!(matches!(err, ErrorCode::ConnectionTimeout), "{err:?}"),
3636
};
3737
Ok(())
3838
}
@@ -48,10 +48,10 @@ async fn self_request_smoke_test() -> anyhow::Result<()> {
4848
let mut future_resp = wasi_http.send_request(req, test_request_config())?;
4949
future_resp.ready().await;
5050

51-
// We don't want to make an actual network request, so treat "connection refused" as success
51+
// We don't want to make an actual network request, so treat the (very short) timeout as success
5252
match future_resp.unwrap_ready().unwrap() {
5353
Ok(_) => bail!("expected Err, got Ok"),
54-
Err(err) => assert!(matches!(err, ErrorCode::ConnectionRefused), "{err:?}"),
54+
Err(err) => assert!(matches!(err, ErrorCode::ConnectionTimeout), "{err:?}"),
5555
};
5656
Ok(())
5757
}
@@ -134,8 +134,8 @@ async fn test_instance_state(
134134
fn test_request_config() -> OutgoingRequestConfig {
135135
OutgoingRequestConfig {
136136
use_tls: false,
137-
connect_timeout: Duration::from_secs(60),
138-
first_byte_timeout: Duration::from_secs(60),
139-
between_bytes_timeout: Duration::from_secs(60),
137+
connect_timeout: Duration::from_millis(1),
138+
first_byte_timeout: Duration::from_millis(1),
139+
between_bytes_timeout: Duration::from_millis(1),
140140
}
141141
}

0 commit comments

Comments
 (0)