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/SSOCredentialsProvider.h>
1514#include < aws/core/auth/GeneralHTTPCredentialsProvider.h>
1615#include < aws/core/client/AWSClient.h>
1716#include < aws/core/utils/StringUtils.h>
2019#include < aws/core/utils/FileSystemUtils.h>
2120#include < fstream>
2221#include < sys/stat.h>
23- #include < thread>
2422
2523using namespace Aws ::Client;
2624using namespace Aws ::Auth;
2725using namespace Aws ::Http;
28- using namespace Aws ::FileSystem;
2926using namespace Aws ::Http::Standard;
3027
3128namespace {
@@ -105,26 +102,6 @@ class CredentialTrackingTest : public Aws::Testing::AwsCppSdkGTestSuite
105102 Aws::Http::InitHttp ();
106103 }
107104
108- void SaveEnvironmentVariable (const char * variableName)
109- {
110- m_environment.emplace_back (variableName, Aws::Environment::GetEnv (variableName));
111- }
112-
113- void RestoreEnvironmentVariables ()
114- {
115- for (const auto & iter : m_environment)
116- {
117- if (iter.second .empty ())
118- {
119- Aws::Environment::UnSetEnv (iter.first );
120- }
121- else
122- {
123- Aws::Environment::SetEnv (iter.first , iter.second .c_str (), 1 );
124- }
125- }
126- }
127-
128105 void RunTestWithCredentialsProvider (const std::shared_ptr<AWSCredentialsProvider>& credentialsProvider, const Aws::String& id) {
129106 // Setup mock response
130107 std::shared_ptr<HttpRequest> requestTmp =
@@ -265,72 +242,4 @@ TEST_F(CredentialTrackingTest, TestHTTPCredentialsTracking)
265242 auto credsProvider = Aws::MakeShared<Aws::Auth::GeneralHTTPCredentialsProvider>(TEST_LOG_TAG,
266243 " " , " http://127.0.0.1/credentials" , " " , " " );
267244 RunTestWithCredentialsProvider (std::move (credsProvider), " z" );
268- }
269-
270- // TEST_F(CredentialTrackingTest, TestSSOCredentialsTracking)
271- // {
272- // // Create temporary config file with SSO configuration
273- // Aws::Utils::TempFile configFile(std::ios_base::out | std::ios_base::trunc);
274- // ASSERT_TRUE(configFile.good());
275- // configFile << "[default]" << std::endl
276- // << "sso_account_id = [REDACTED:BANK_ACCOUNT_NUMBER]" << std::endl
277- // << "sso_region = us-east-1" << std::endl
278- // << "sso_role_name = TestRole" << std::endl
279- // << "sso_start_url = https://d-test.awsapps.com/start" << std::endl;
280- // configFile.close();
281- //
282- // // Create SSO token cache directory and file
283- // Aws::String cacheDir = "/tmp/.aws/sso/cache";
284- // Aws::FileSystem::CreateDirectoryIfNotExists("/tmp/.aws");
285- // Aws::FileSystem::CreateDirectoryIfNotExists(("/tmp/.aws/sso"));
286- // Aws::FileSystem::CreateDirectoryIfNotExists(cacheDir.c_str());
287- //
288- // // Calculate token filename using SHA1 hash of start URL
289- // Aws::String startUrl = "https://d-test.awsapps.com/start";
290- // Aws::String hashedStartUrl = Aws::Utils::HashingUtils::HexEncode(
291- // Aws::Utils::HashingUtils::CalculateSHA1(startUrl));
292- // Aws::String tokenPath = cacheDir + "/" + hashedStartUrl + ".json";
293- //
294- // // Create SSO token cache file with future expiration
295- // Aws::OFStream tokenFile(tokenPath.c_str());
296- // ASSERT_TRUE(tokenFile.is_open());
297- // tokenFile << R"({
298- // "accessToken": "test-sso-token",
299- // "expiresAt": "2037-04-19T00:00:00Z",
300- // "region": "us-east-1",
301- // "startUrl": "https://d-test.awsapps.com/start"
302- // })";
303- // tokenFile.close();
304- //
305- // // Set up mock response for SSO GetRoleCredentials
306- // std::shared_ptr<HttpRequest> requestTmp =
307- // CreateHttpRequest(Aws::Http::URI("https://portal.sso.us-east-1.amazonaws.com"),
308- // Aws::Http::HttpMethod::HTTP_POST,
309- // Aws::Utils::Stream::DefaultResponseStreamFactoryMethod);
310- // auto successResponse = Aws::MakeShared<Standard::StandardHttpResponse>(TEST_LOG_TAG, requestTmp);
311- // successResponse->SetResponseCode(HttpResponseCode::OK);
312- // successResponse->GetResponseBody() << R"({
313- // "roleCredentials": {
314- // "accessKeyId": "test-sso-access-key",
315- // "secretAccessKey": "test-sso-secret-key",
316- // "sessionToken": "test-sso-session-token",
317- // "expiration": 1767225600000
318- // }
319- // })";
320- // mockHttpClient->AddResponseToReturn(successResponse);
321- //
322- // // Set environment to use our test config file
323- // Aws::Environment::EnvironmentRAII testEnvironment{{
324- // {"AWS_CONFIG_FILE", configFile.GetFileName().c_str()},
325- // }};
326- //
327- // // Force reload config file after setting environment variable
328- // Aws::Config::ReloadCachedConfigFile();
329- //
330- // // Create SSO credentials provider
331- // auto ssoProvider = Aws::MakeShared<SSOCredentialsProvider>(TEST_LOG_TAG);
332- // RunTestWithCredentialsProvider(std::move(ssoProvider), "s");
333- //
334- // // Cleanup
335- // Aws::FileSystem::RemoveFileIfExists(tokenPath.c_str());
336- // }
245+ }
0 commit comments