Skip to content

Commit c0f2eec

Browse files
committed
Strengthen parity test assertions for unauthenticated admin routes
- Assert Axum also returns WWW-Authenticate header on 401 (was CF-only) - Add admin_deactivate_unauthenticated_parity covering the deactivate path - Rename cookie_behavior_note → publisher_proxy_fallback_parity (name now reflects what the test actually verifies) - Fix expect("collect body") → expect("should collect body") per style guide
1 parent 5f91da2 commit c0f2eec

1 file changed

Lines changed: 36 additions & 3 deletions

File tree

crates/integration-tests/tests/parity.rs

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ async fn discovery_route_body_is_json_parity() {
146146
.into_body()
147147
.collect()
148148
.await
149-
.expect("collect body")
149+
.expect("should collect body")
150150
.to_bytes();
151151
(status, body)
152152
};
@@ -199,7 +199,7 @@ async fn admin_rotate_unauthenticated_parity() {
199199
// Both adapters must return 401 for unauthenticated admin requests.
200200
// The authenticated-path divergence (Axum→501 no-KV, CF→4xx no-KV)
201201
// is separate and not covered here.
202-
let (axum_status, _) = axum_post_headers("/admin/keys/rotate", "{}").await;
202+
let (axum_status, axum_headers) = axum_post_headers("/admin/keys/rotate", "{}").await;
203203
let (cf_status, cf_headers) = cf_post_headers("/admin/keys/rotate", "{}").await;
204204

205205
assert_eq!(
@@ -215,6 +215,10 @@ async fn admin_rotate_unauthenticated_parity() {
215215
"both adapters must return the same status for unauthenticated admin route"
216216
);
217217

218+
assert!(
219+
axum_headers.contains_key("www-authenticate"),
220+
"Axum 401 must include WWW-Authenticate header"
221+
);
218222
let cf_www_auth = cf_headers
219223
.get("www-authenticate")
220224
.expect("should have www-authenticate header on 401")
@@ -226,6 +230,35 @@ async fn admin_rotate_unauthenticated_parity() {
226230
);
227231
}
228232

233+
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
234+
async fn admin_deactivate_unauthenticated_parity() {
235+
// Mirror of admin_rotate_unauthenticated_parity for the deactivate endpoint.
236+
let (axum_status, axum_headers) = axum_post_headers("/admin/keys/deactivate", "{}").await;
237+
let (cf_status, cf_headers) = cf_post_headers("/admin/keys/deactivate", "{}").await;
238+
239+
assert_eq!(
240+
axum_status, 401,
241+
"Axum must return 401 for unauthenticated admin/keys/deactivate"
242+
);
243+
assert_eq!(
244+
cf_status, 401,
245+
"Cloudflare must return 401 for unauthenticated admin/keys/deactivate"
246+
);
247+
assert_eq!(
248+
axum_status, cf_status,
249+
"both adapters must return the same status for unauthenticated admin/keys/deactivate"
250+
);
251+
252+
assert!(
253+
axum_headers.contains_key("www-authenticate"),
254+
"Axum 401 on admin/keys/deactivate must include WWW-Authenticate header"
255+
);
256+
assert!(
257+
cf_headers.contains_key("www-authenticate"),
258+
"Cloudflare 401 on admin/keys/deactivate must include WWW-Authenticate header"
259+
);
260+
}
261+
229262
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
230263
async fn geo_header_parity_on_all_responses() {
231264
let routes_to_check: &[(&str, &str, &str)] = &[
@@ -267,7 +300,7 @@ async fn auction_not_challenged_by_auth_parity() {
267300
}
268301

269302
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
270-
async fn cookie_behavior_note() {
303+
async fn publisher_proxy_fallback_parity() {
271304
// Cookie (Set-Cookie) parity for the publisher proxy requires a live origin.
272305
// Without an origin, both adapters return an error (4xx or 5xx). The parity
273306
// assertion is that Set-Cookie presence matches across adapters regardless of

0 commit comments

Comments
 (0)