test: some error rework

This commit is contained in:
Gwen Lg
2026-02-17 21:01:47 +01:00
committed by Alex
parent 8341b7f914
commit 06e9756729
4 changed files with 43 additions and 17 deletions
+7 -2
View File
@@ -11,8 +11,13 @@ pub enum Error {
Common(CommonError),
/// Authorization Header Malformed
#[error("Authorization header malformed, unexpected scope: {0}")]
AuthorizationHeaderMalformed(String),
#[error(
"Authorization header malformed, unexpected scope: '{unexpected}', expected: '{expected}'"
)]
AuthorizationHeaderMalformed {
unexpected: String,
expected: String,
},
// Category: bad request
/// The request contained an invalid UTF-8 sequence in its path or in other parameters
+4 -1
View File
@@ -400,7 +400,10 @@ pub fn verify_v4(
) -> Result<Key, Error> {
let scope_expected = compute_scope(&auth.date, &garage.config.s3_api.s3_region, service);
if auth.scope != scope_expected {
return Err(Error::AuthorizationHeaderMalformed(auth.scope.to_string()));
return Err(Error::AuthorizationHeaderMalformed {
unexpected: auth.scope.to_string(),
expected: scope_expected,
});
}
let key = garage