1111#include < aws/testing/platform/PlatformTesting.h>
1212#include < aws/core/auth/AWSCredentialsProvider.h>
1313#include < aws/core/auth/AWSCredentialsProviderChain.h>
14+ #include < aws/core/auth/GeneralHTTPCredentialsProvider.h>
1415#include < aws/core/client/AWSClient.h>
1516#include < aws/core/utils/StringUtils.h>
1617#include < aws/core/utils/HashingUtils.h>
2223using namespace Aws ::Client;
2324using namespace Aws ::Auth;
2425using namespace Aws ::Http;
26+ using namespace Aws ::Http::Standard;
2527
2628namespace {
2729const char * TEST_LOG_TAG = " CredentialTrackingTest" ;
@@ -213,4 +215,30 @@ TEST_F(CredentialTrackingTest, TestInstanceProfileCredentialsTracking)
213215 Aws::MakeShared<Aws::Config::EC2InstanceProfileConfigLoader>(TEST_LOG_TAG, mockClient), 1000 );
214216
215217 RunTestWithCredentialsProvider (std::move (imdsProvider), " 0" );
218+ }
219+
220+ TEST_F (CredentialTrackingTest, TestHTTPCredentialsTracking)
221+ {
222+ // First mock: Response for credentials retrieval
223+ std::shared_ptr<HttpRequest> requestTmp =
224+ CreateHttpRequest (Aws::Http::URI (" dummy" ), Aws::Http::HttpMethod::HTTP_GET,
225+ Aws::Utils::Stream::DefaultResponseStreamFactoryMethod);
226+ auto successResponse = Aws::MakeShared<Standard::StandardHttpResponse>(TEST_LOG_TAG, requestTmp);
227+ successResponse->SetResponseCode (HttpResponseCode::OK);
228+ successResponse->GetResponseBody () << R"( {
229+ "AccessKeyId": "test-http-access-key",
230+ "SecretAccessKey": "test-http-secret-key",
231+ "Token": "test-http-token",
232+ "Expiration": "2037-04-19T00:00:00Z"
233+ })" ;
234+ mockHttpClient->AddResponseToReturn (successResponse);
235+
236+ // Set environment for HTTP credentials provider
237+ Aws::Environment::EnvironmentRAII testEnvironment{{
238+ {" AWS_CONTAINER_CREDENTIALS_FULL_URI" , " http://127.0.0.1/credentials" },
239+ }};
240+
241+ auto credsProvider = Aws::MakeShared<Aws::Auth::GeneralHTTPCredentialsProvider>(TEST_LOG_TAG,
242+ " " , " http://127.0.0.1/credentials" , " " , " " );
243+ RunTestWithCredentialsProvider (std::move (credsProvider), " z" );
216244}
0 commit comments