singhsaabir commented on code in PR #636:
URL:
https://github.com/apache/arrow-rs-object-store/pull/636#discussion_r2787335547
##########
src/aws/client.rs:
##########
@@ -1010,4 +1020,72 @@ mod tests {
assert_eq!(result.unwrap(), "test-upload-id");
mock.shutdown().await;
}
+
+ #[tokio::test]
+ async fn test_default_headers_signed() {
+ let mock = MockServer::new().await;
+
+ mock.push_fn(|req| {
+ // Verify default headers are present
+ assert_eq!(req.headers().get("x-amz-meta-test").unwrap(),
"test-value");
+ assert_eq!(req.headers().get("x-amz-tagging").unwrap(),
"key=value");
+
+ // Verify headers are included in signature
+ let auth =
req.headers().get(AUTHORIZATION).unwrap().to_str().unwrap();
+ assert!(
+ auth.contains("x-amz-meta-test"),
+ "x-amz-meta-test not in SignedHeaders: {auth}"
+ );
+ assert!(
+ auth.contains("x-amz-tagging"),
+ "x-amz-tagging not in SignedHeaders: {auth}"
+ );
+
+ Response::builder()
+ .status(200)
+ .header("etag", "\"test-etag\"")
+ .body(String::new())
+ .unwrap()
+ });
+
+ let credential = AwsCredential {
+ key_id: "AKIAIOSFODNN7EXAMPLE".to_string(),
+ secret_key: "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY".to_string(),
+ token: None,
+ };
+
+ let mut default_headers = HeaderMap::new();
+ default_headers.insert("x-amz-meta-test",
"test-value".parse().unwrap());
+ default_headers.insert("x-amz-tagging", "key=value".parse().unwrap());
+
+ let config = S3Config {
+ bucket_endpoint: mock.url().to_string(),
+ bucket: "test-bucket".to_string(),
+ region: "us-east-1".to_string(),
+ credentials:
Arc::new(crate::StaticCredentialProvider::new(credential)),
+ client_options: ClientOptions::new()
+ .with_allow_http(true)
+ .with_default_headers(default_headers),
+ skip_signature: false,
+ session_provider: None,
+ retry_config: Default::default(),
+ sign_payload: false,
+ disable_tagging: false,
+ checksum: None,
+ copy_if_not_exists: None,
+ conditional_put: Default::default(),
+ encryption_headers: Default::default(),
+ request_payer: false,
+ };
+
+ let client = S3Client::new(config,
HttpClient::new(reqwest::Client::new()));
+ let result = client
+ .request(Method::PUT, &Path::from("test"))
+ .with_payload(PutPayload::default())
+ .do_put()
+ .await;
+
Review Comment:
Thank you for the quick review! Added tests.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]