Skip to content

Commit f1cd64d

Browse files
committed
fix urls in integration tests
1 parent eae40e0 commit f1cd64d

File tree

1 file changed

+35
-24
lines changed

1 file changed

+35
-24
lines changed

nexus/tests/integration_tests/webhooks.rs

Lines changed: 35 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ const ALERTS_BASE_PATH: &str = "/v1/alerts";
3333
const ALERT_RECEIVERS_BASE_PATH: &str = "/v1/alert-receivers";
3434
const WEBHOOK_RECEIVERS_BASE_PATH: &str = "/v1/webhook-receivers";
3535
const SECRETS_BASE_PATH: &str = "/v1/webhook-secrets";
36-
const DELIVERIES_BASE_PATH: &str = "/v1/alert-deliveries";
3736

3837
async fn webhook_create(
3938
ctx: &ControlPlaneTestContext,
@@ -112,15 +111,11 @@ async fn alert_deliveries_list(
112111
client: &ClientTestContext,
113112
webhook_name_or_id: impl Into<NameOrId>,
114113
) -> Collection<views::AlertDelivery> {
115-
let rx = webhook_name_or_id.into();
116-
NexusRequest::iter_collection_authn(
117-
client,
118-
&format!("{DELIVERIES_BASE_PATH}?receiver={rx}"),
119-
"",
120-
None,
121-
)
122-
.await
123-
.unwrap()
114+
let mut rx_url = alert_rx_url(webhook_name_or_id);
115+
rx_url.push_str("/deliveries");
116+
NexusRequest::iter_collection_authn(client, &rx_url, "", None)
117+
.await
118+
.unwrap()
124119
}
125120

126121
async fn alert_delivery_resend(
@@ -239,15 +234,15 @@ fn subscription_remove_url(
239234
)
240235
}
241236

242-
async fn webhook_send_probe(
237+
async fn alert_receiver_send_probe(
243238
ctx: &ControlPlaneTestContext,
244239
webhook_id: &AlertReceiverUuid,
245240
resend: bool,
246241
status: http::StatusCode,
247242
) -> views::AlertProbeResult {
248243
let pathparams = if resend { "?resend=true" } else { "" };
249244
let path =
250-
format!("{WEBHOOK_RECEIVERS_BASE_PATH}/{webhook_id}/probe{pathparams}");
245+
format!("{ALERT_RECEIVERS_BASE_PATH}/{webhook_id}/probe{pathparams}");
251246
NexusRequest::new(
252247
RequestBuilder::new(&ctx.external_client, http::Method::POST, &path)
253248
.expect_status(Some(status)),
@@ -1141,9 +1136,13 @@ async fn test_probe(cptestctx: &ControlPlaneTestContext) {
11411136
};
11421137

11431138
// Send a probe. The probe should fail due to a timeout.
1144-
let probe1 =
1145-
webhook_send_probe(&cptestctx, &rx_id, false, http::StatusCode::OK)
1146-
.await;
1139+
let probe1 = alert_receiver_send_probe(
1140+
&cptestctx,
1141+
&rx_id,
1142+
false,
1143+
http::StatusCode::OK,
1144+
)
1145+
.await;
11471146
dbg!(&probe1);
11481147

11491148
mock.assert_async().await;
@@ -1183,9 +1182,13 @@ async fn test_probe(cptestctx: &ControlPlaneTestContext) {
11831182
.await
11841183
};
11851184

1186-
let probe2 =
1187-
webhook_send_probe(&cptestctx, &rx_id, false, http::StatusCode::OK)
1188-
.await;
1185+
let probe2 = alert_receiver_send_probe(
1186+
&cptestctx,
1187+
&rx_id,
1188+
false,
1189+
http::StatusCode::OK,
1190+
)
1191+
.await;
11891192
dbg!(&probe2);
11901193

11911194
mock.assert_async().await;
@@ -1228,9 +1231,13 @@ async fn test_probe(cptestctx: &ControlPlaneTestContext) {
12281231
.await
12291232
};
12301233

1231-
let probe3 =
1232-
webhook_send_probe(&cptestctx, &rx_id, false, http::StatusCode::OK)
1233-
.await;
1234+
let probe3 = alert_receiver_send_probe(
1235+
&cptestctx,
1236+
&rx_id,
1237+
false,
1238+
http::StatusCode::OK,
1239+
)
1240+
.await;
12341241
dbg!(&probe3);
12351242
mock.assert_async().await;
12361243

@@ -1392,9 +1399,13 @@ async fn test_probe_resends_failed_deliveries(
13921399

13931400
// Send a probe with ?resend=true
13941401
let rx_id = AlertReceiverUuid::from_untyped_uuid(webhook.identity.id);
1395-
let probe =
1396-
webhook_send_probe(&cptestctx, &rx_id, true, http::StatusCode::OK)
1397-
.await;
1402+
let probe = alert_receiver_send_probe(
1403+
&cptestctx,
1404+
&rx_id,
1405+
true,
1406+
http::StatusCode::OK,
1407+
)
1408+
.await;
13981409
dbg!(&probe);
13991410
probe_mock.assert_async().await;
14001411
probe_mock.delete_async().await;

0 commit comments

Comments
 (0)