hive-c0re: test verify_hmac guards and webhook status mapping
`verify_hmac` is the only authentication gate on the public `/webhook/config-pr` endpoint, and neither of its guard clauses nor the handler's "unavailable" → 503 / otherwise → 401 mapping had a test. The tests build a real `AppState` over the tempdir `Coordinator` that the socket_server schedule tests already use. That helper is widened from `pub(in crate::socket_server)` to `pub(crate)` and re-exported from `socket_server` under `#[cfg(test)]`, so non-test code is unchanged. Removing the missing-secret guard (replacing it with `unwrap_or_default()`) fails verify_hmac_rejects_every_delivery_when_no_secret_is_loaded and config_pr_answers_503_when_no_secret_is_loaded. Deleting the missing-header guard fails verify_hmac_rejects_a_delivery_with_no_usable_signature_header. Breaking the "unavailable" match fails the 503 test. Without the missing-header guard, an unsigned delivery is still refused by `verify_signature` (no `sha256=` prefix). The test therefore pins the guard's own message rather than the bare rejection. Closes #4654
This commit is contained in:
parent
7488c337cc
commit
a40c0026cf
3 changed files with 141 additions and 1 deletions
|
|
@ -27,6 +27,8 @@ mod schedules;
|
|||
pub(crate) use config_approvals::submit_merge_config_pr;
|
||||
pub(crate) use schedules::filter_ghost_schedule_targets;
|
||||
pub use schedules::schedule_to_wire_public;
|
||||
#[cfg(test)]
|
||||
pub(crate) use schedules::tests::coordinator;
|
||||
|
||||
use schedules::{
|
||||
EditSchedulePatch, handle_cancel_schedule, handle_edit_schedule, handle_fire_schedule_now,
|
||||
|
|
|
|||
|
|
@ -380,7 +380,7 @@ pub(super) mod tests {
|
|||
/// A real `Coordinator` over a throwaway sqlite dir. The socket-server
|
||||
/// handlers take `&Arc<Coordinator>`, so there is no lighter way in;
|
||||
/// `open` touches nothing outside the db path it is handed.
|
||||
pub(in crate::socket_server) fn coordinator() -> (tempfile::TempDir, Arc<Coordinator>) {
|
||||
pub(crate) fn coordinator() -> (tempfile::TempDir, Arc<Coordinator>) {
|
||||
let dir = tempfile::tempdir().expect("tempdir");
|
||||
let coord = Coordinator::open(
|
||||
&dir.path().join("broker.sqlite"),
|
||||
|
|
|
|||
Loading…
Reference in a new issue