From 72f8e90e17f1aa61b8a095890dd52c2da2ed8ab2 Mon Sep 17 00:00:00 2001 From: houseme Date: Fri, 21 Aug 2026 02:47:36 +0800 Subject: [PATCH] test(e2e): box SSE-KMS negative errors Co-Authored-By: heihutu --- .../src/kms/kms_authorization_negative_matrix_test.rs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/crates/e2e_test/src/kms/kms_authorization_negative_matrix_test.rs b/crates/e2e_test/src/kms/kms_authorization_negative_matrix_test.rs index a6fd6cb43..9c78662f8 100644 --- a/crates/e2e_test/src/kms/kms_authorization_negative_matrix_test.rs +++ b/crates/e2e_test/src/kms/kms_authorization_negative_matrix_test.rs @@ -39,6 +39,7 @@ use std::time::Duration; use tracing::info; type TestResult = Result<(), Box>; +type S3OperationResult = Result>; const ALLOWED_KEY: &str = "kms-matrix-allowed-key"; const OTHER_KEY: &str = "kms-matrix-other-key"; @@ -130,7 +131,7 @@ fn policy_document(statements: Vec) -> String { serde_json::json!({ "Version": "2012-10-17", "Statement": statements }).to_string() } -async fn put_sse_kms(client: &Client, key: &str, kms_key_id: &str) -> Result<(), aws_sdk_s3::Error> { +async fn put_sse_kms(client: &Client, key: &str, kms_key_id: &str) -> S3OperationResult<()> { client .put_object() .bucket(BUCKET) @@ -141,14 +142,14 @@ async fn put_sse_kms(client: &Client, key: &str, kms_key_id: &str) -> Result<(), .send() .await .map(|_| ()) - .map_err(aws_sdk_s3::Error::from) + .map_err(|err| Box::new(aws_sdk_s3::Error::from(err))) } /// Assert the operation failed with `AccessDenied` rather than any other error. /// /// A bare `is_err` would also accept `KMSKeyDisabled` or an internal error, which /// would hide both a leak of key state and an outage masquerading as a denial. -fn assert_access_denied(result: Result, what: &str) { +fn assert_access_denied(result: S3OperationResult, what: &str) { let error = result.expect_err(&format!("{what} must be denied")); assert_eq!(error.code(), Some("AccessDenied"), "{what} must fail with AccessDenied: {error:?}"); } @@ -296,7 +297,7 @@ async fn sse_kms_per_key_authorization_negative_matrix() -> TestResult { .send() .await .map(|_| ()) - .map_err(aws_sdk_s3::Error::from), + .map_err(|err| Box::new(aws_sdk_s3::Error::from(err))), "SSE-KMS read by an identity holding no kms grant", ); @@ -310,7 +311,7 @@ async fn sse_kms_per_key_authorization_negative_matrix() -> TestResult { .send() .await .map(|_| ()) - .map_err(aws_sdk_s3::Error::from), + .map_err(|err| Box::new(aws_sdk_s3::Error::from(err))), "SSE-KMS read by an identity holding kms:GenerateDataKey but not kms:Decrypt", );