@@ -72,28 +72,23 @@ TEST_F(SigV4AuthTest, LifecycleFinalizeRefusesWhileSessionsAlive) {
7272 EXPECT_TRUE (IsAwsSdkInitialized ());
7373}
7474
75- TEST_F (SigV4AuthTest, DirectlyConstructedSessionDoesNotCorruptLifecycleCount) {
76- // A directly-constructed session never registered with AwsSdkLifecycle, so
77- // destroying it must not decrement the count. Otherwise it underflows, and a
78- // later real session wraps it back to zero, letting FinalizeAwsSdk() shut the
79- // SDK down while a session is still alive.
75+ TEST_F (SigV4AuthTest, SessionRegistrationBalancesLifecycleCount) {
8076 {
8177 auto delegate = AuthSession::MakeDefault ({});
8278 auto credentials = std::make_shared<Aws::Auth::SimpleAWSCredentialsProvider>(
8379 Aws::Auth::AWSCredentials (" id" , " secret" ));
84- auto direct = std::make_shared<SigV4AuthSession>(delegate, " us-east-1" , " execute-api" ,
85- credentials);
86- } // destroyed here — must leave the lifecycle count untouched
80+ auto session_result =
81+ SigV4AuthSession::Make (delegate, " us-east-1" , " execute-api" , credentials);
82+ ASSERT_THAT (session_result, IsOk ());
83+ EXPECT_THAT (FinalizeAwsSdk (), IsError (ErrorKind::kInvalid ));
84+ }
8785
8886 auto properties = MakeSigV4Properties ();
8987 auto manager_result = AuthManagers::Load (" test-catalog" , properties);
9088 ASSERT_THAT (manager_result, IsOk ());
9189 auto session_result = manager_result.value ()->CatalogSession (client_, properties);
9290 ASSERT_THAT (session_result, IsOk ());
9391
94- // Exactly one live (registered) session, so Finalize must refuse. With the
95- // underflow bug the count would have wrapped and Finalize could wrongly
96- // succeed and shut the SDK down.
9792 EXPECT_THAT (FinalizeAwsSdk (), IsError (ErrorKind::kInvalid ));
9893 EXPECT_TRUE (IsAwsSdkInitialized ());
9994}
@@ -338,7 +333,8 @@ TEST_F(SigV4AuthTest, AuthenticateWithBodyDetailedHeaders) {
338333 ASSERT_NE (auth_it, headers.end ());
339334 EXPECT_TRUE (auth_it->second .starts_with (" AWS4-HMAC-SHA256 Credential=" ));
340335
341- // x-amz-content-sha256 should be Base64-encoded body SHA256 (matching Java)
336+ // Java parity: the x-amz-content-sha256 header is Base64(SHA256(body)) for
337+ // non-empty bodies; the canonical request payload hash stays lowercase hex.
342338 auto sha_it = headers.find (" x-amz-content-sha256" );
343339 ASSERT_NE (sha_it, headers.end ());
344340 EXPECT_NE (sha_it->second , SigV4AuthSession::kEmptyBodySha256 );
@@ -390,8 +386,10 @@ TEST_F(SigV4AuthTest, ConflictingSigV4HeadersRelocated) {
390386 auto credentials =
391387 std::make_shared<Aws::Auth::SimpleAWSCredentialsProvider>(Aws::Auth::AWSCredentials (
392388 " AKIAIOSFODNN7EXAMPLE" , " wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY" ));
393- auto session = std::make_shared<SigV4AuthSession>(delegate, " us-east-1" , " execute-api" ,
394- credentials);
389+ auto session_result =
390+ SigV4AuthSession::Make (delegate, " us-east-1" , " execute-api" , credentials);
391+ ASSERT_THAT (session_result, IsOk ());
392+ auto session = session_result.value ();
395393
396394 HttpRequest request{.method = HttpMethod::kGet , .url = " http://localhost:8080/path" };
397395 auto auth_result = session->Authenticate (request);
@@ -418,11 +416,11 @@ TEST_F(SigV4AuthTest, SessionCloseDelegatesToInner) {
418416 auto delegate = AuthSession::MakeDefault ({});
419417 auto credentials = std::make_shared<Aws::Auth::SimpleAWSCredentialsProvider>(
420418 Aws::Auth::AWSCredentials (" id" , " secret" ));
421- auto session = std::make_shared<SigV4AuthSession>(delegate, " us-east-1" , " execute-api" ,
422- credentials);
419+ auto session_result =
420+ SigV4AuthSession::Make (delegate, " us-east-1" , " execute-api" , credentials);
421+ ASSERT_THAT (session_result, IsOk ());
423422
424- // Close should succeed without error
425- EXPECT_THAT (session->Close (), IsOk ());
423+ EXPECT_THAT (session_result.value ()->Close (), IsOk ());
426424}
427425
428426TEST_F (SigV4AuthTest, CreateCustomDelegateNone) {
0 commit comments