Skip to content

Commit cc39913

Browse files
committed
adding unit tests
1 parent 126ab2a commit cc39913

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

tests/aws-cpp-sdk-core-tests/aws/auth/AWSCredentialsProviderTest.cpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1305,3 +1305,25 @@ TEST_F(AWSCachedCredentialsTest, ShouldCacheCredenitalAsync)
13051305
ASSERT_TRUE(containCredentials(creds, {"and", "no", "surprises"}));
13061306
ASSERT_FALSE(containCredentials(creds, {"a", "quiet", "life"}));
13071307
}
1308+
1309+
TEST_F(EnvironmentModifyingTest, TestDefaultAWSCredentialsProviderChainWithConfig)
1310+
{
1311+
// Create a credentials file with a custom profile
1312+
Aws::OFStream credsFile(m_credsFileName.c_str(), Aws::OFStream::out | Aws::OFStream::trunc);
1313+
credsFile << "[custom-profile]" << std::endl;
1314+
credsFile << "aws_access_key_id = CustomProfileAccessKey" << std::endl;
1315+
credsFile << "aws_secret_access_key = CustomProfileSecretKey" << std::endl;
1316+
credsFile.close();
1317+
1318+
// Create config with custom profile
1319+
Aws::Client::ClientConfiguration::CredentialProviderConfiguration config;
1320+
config.profile = "custom-profile";
1321+
1322+
// Test the constructor with config
1323+
DefaultAWSCredentialsProviderChain providerChain(config);
1324+
1325+
// Verify it uses the custom profile
1326+
AWSCredentials creds = providerChain.GetAWSCredentials();
1327+
EXPECT_STREQ("CustomProfileAccessKey", creds.GetAWSAccessKeyId().c_str());
1328+
EXPECT_STREQ("CustomProfileSecretKey", creds.GetAWSSecretKey().c_str());
1329+
}

0 commit comments

Comments
 (0)