2424#include < aws/testing/TestingEnvironment.h>
2525#include < aws/core/platform/Environment.h>
2626#include < openssl/srp.h>
27+ #include < openssl/sha.h>
28+ #include < openssl/evp.h>
29+ #include < openssl/hmac.h>
30+
31+
2732using namespace Aws ::CognitoIdentityProvider;
2833using namespace Aws ::CognitoIdentityProvider::Model;
2934using namespace Aws ::Client;
@@ -55,7 +60,6 @@ class IdentityProviderOperationTest : public ::testing::Test
5560 Aws::Client::ClientConfiguration config;
5661 config.region = AWS_TEST_REGION;
5762
58- // TODO: move this over to profile config file.
5963 client = Aws::MakeShared<Aws::CognitoIdentityProvider::CognitoIdentityProviderClient>(ALLOCATION_TAG, config);
6064 }
6165
@@ -102,8 +106,8 @@ class IdentityProviderOperationTest : public ::testing::Test
102106 request.SetExplicitAuthFlows (authFlows);
103107
104108 // Make the call to create the user pool client
105- auto outcome = client->CreateUserPoolClient (request);
106- ASSERT_TRUE (outcome.IsSuccess ());
109+ Aws::CognitoIdentityProvider::Model::CreateUserPoolClientOutcome outcome = client->CreateUserPoolClient (request);
110+ /* ASSERT_TRUE(outcome.IsSuccess());
107111 if (outcome.IsSuccess())
108112 {
109113 std::cout << "User Pool Client created successfully." << std::endl;
@@ -112,7 +116,7 @@ class IdentityProviderOperationTest : public ::testing::Test
112116 {
113117 std::cout << "Client Secret: " << outcome.GetResult().GetUserPoolClient().GetClientSecret() << std::endl;
114118 }
115- }
119+ }*/
116120 return outcome;
117121 }
118122
@@ -135,7 +139,25 @@ class IdentityProviderOperationTest : public ::testing::Test
135139
136140};
137141
142+ Aws::String ComputeSecretHash (const Aws::String &userPoolClientId, const Aws::String &userPoolClientSecret, const Aws::String &userName)
143+ {
144+ const auto secret = userPoolClientSecret;
145+ const auto message = userName + userPoolClientId;
146+
147+ unsigned char * digest = HMAC (EVP_sha256 (),
148+ secret.c_str (), static_cast <int >(secret.length ()),
149+ reinterpret_cast <const unsigned char *>(message.c_str ()),
150+ static_cast <int >(message.length ()),
151+ NULL , NULL );
152+
153+ char mdString[SHA256_DIGEST_LENGTH * 2 + 1 ];
154+ for (int i = 0 ; i < SHA256_DIGEST_LENGTH; ++i)
155+ sprintf (&mdString[i*2 ], " %02x" , (unsigned int )digest[i]);
138156
157+ mdString[64 ] = ' \0 ' ; // null-terminate the string
158+
159+ return Aws::String (mdString);
160+ }
139161
140162
141163
@@ -144,28 +166,6 @@ TEST_F(IdentityProviderOperationTest, testSecret)
144166{
145167 auto outcome = createPoolClient ();
146168
147-
148- Aws::String ComputeSecretHash (const Aws::String &userPoolClientId, const Aws::String &userPoolClientSecret, const Aws::String &userName)
149- {
150- const auto secret = userPoolClientSecret;
151- const auto message = userName + userPoolClientId;
152-
153- unsigned char * digest = HMAC (EVP_sha256 (),
154- secret.c_str (), static_cast <int >(secret.length ()),
155- reinterpret_cast <const unsigned char *>(message.c_str ()),
156- static_cast <int >(message.length ()),
157- NULL , NULL );
158-
159- char mdString[SHA256_DIGEST_LENGTH * 2 + 1 ];
160- for (int i = 0 ; i < SHA256_DIGEST_LENGTH; ++i)
161- sprintf (&mdString[i*2 ], " %02x" , (unsigned int )digest[i]);
162-
163- mdString[64 ] = ' \0 ' ; // null-terminate the string
164-
165- return Aws::String (mdString);
166- }
167-
168-
169169 Aws::Map<Aws::String, Aws::String> authParameters;
170170 authParameters[" USERNAME" ] = " dummyuser" ; // Replace with actual username
171171
0 commit comments