kou commented on code in PR #43601:
URL: https://github.com/apache/arrow/pull/43601#discussion_r1768131908


##########
cpp/src/arrow/filesystem/s3fs_test.cc:
##########
@@ -1579,5 +1616,26 @@ TEST(S3GlobalOptions, DefaultsLogLevel) {
   }
 }
 
+TEST(CalculateSSECustomerKeyMD5, Sanity) {
+  ASSERT_FALSE(CalculateSSECustomerKeyMD5("").ok());  // invalid length
+  
ASSERT_FALSE(CalculateSSECustomerKeyMD5("1234567890123456789012345678901234567890")
+                   .ok());  // invalid length
+  // valid case, with ascii input key
+  ASSERT_OK_AND_ASSIGN(auto md5,
+                       
CalculateSSECustomerKeyMD5("NLbTMHZn9aCW3Li3ViAdBsoIldPCREw1"))
+  ASSERT_STREQ(md5.c_str(),
+               "7B3ilqBA6/PYeo5z9+a3OQ==");  // valid case
+  // valid case, with some non-ASCII character and a null byte in the 
sse_customer_key
+  char sse_customer_key[32] = {};
+  sse_customer_key[0] = '\x40';   // '@' character
+  sse_customer_key[1] = '\0';     // null byte
+  sse_customer_key[2] = '\xFF';   // non-ASCII
+  sse_customer_key[31] = '\xFA';  // non-ASCII
+  std::string sse_customer_key_string(sse_customer_key, 
sizeof(sse_customer_key));
+  ASSERT_OK_AND_ASSIGN(md5, 
CalculateSSECustomerKeyMD5(sse_customer_key_string))
+  ASSERT_STREQ(md5.c_str(),
+               "97FTa6lj0hE7lshKdBy61g==");  // valid case

Review Comment:
   ```suggestion
     ASSERT_EQ(md5, "97FTa6lj0hE7lshKdBy61g==");  // valid case
   ```



-- 
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: github-unsubscr...@arrow.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to