Skip to content

Commit 4c39477

Browse files
committed
updated to use a real AWSClient
1 parent aee0ecb commit 4c39477

File tree

1 file changed

+24
-18
lines changed

1 file changed

+24
-18
lines changed

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

Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -37,24 +37,26 @@ Aws::String computeHashedStartUrl(const Aws::String& startUrl) {
3737
return HashingUtils::HexEncode(sha1); // lower-case hex the same as provider
3838
}
3939

40-
// Minimal AWSClient wrapper so we can make a signed call and inspect User-Agent
41-
class CredentialTestingClient : public AWSClient {
40+
class CredentialTestingClient : public AWSClient
41+
{
4242
public:
43-
explicit CredentialTestingClient(const ClientConfiguration& config,
44-
const std::shared_ptr<AWSCredentialsProvider>& provider)
45-
: AWSClient(config,
46-
Aws::MakeShared<Aws::Client::AWSAuthV4Signer>(TEST_LOG_TAG, provider, "service", config.region),
47-
Aws::MakeShared<MockAWSErrorMarshaller>(TEST_LOG_TAG)) {}
48-
49-
HttpResponseOutcome MakeRequest(const Aws::AmazonWebServiceRequest& request) {
50-
URI uri("https://test.com");
51-
return AttemptExhaustively(uri, request, HttpMethod::HTTP_POST, Aws::Auth::SIGV4_SIGNER);
43+
CredentialTestingClient() : AWSClient(ClientConfiguration(), Aws::MakeShared<AWSAuthV4Signer>(TEST_LOG_TAG, Aws::MakeShared<DefaultAWSCredentialsProviderChain>(TEST_LOG_TAG),
44+
"rds", Aws::Region::US_EAST_1), Aws::MakeShared<XmlErrorMarshaller>(TEST_LOG_TAG)) {}
45+
CredentialTestingClient(const Aws::Client::ClientConfiguration& configuration, const std::shared_ptr<Aws::Client::AWSAuthSigner>& signer) :
46+
AWSClient(configuration, signer, Aws::MakeShared<XmlErrorMarshaller>(TEST_LOG_TAG)) {}
47+
48+
Aws::Client::HttpResponseOutcome PublicAttemptExhaustively(
49+
const Aws::Http::URI& uri,
50+
const Aws::AmazonWebServiceRequest& request,
51+
Http::HttpMethod method,
52+
const char* signerName) {
53+
return AttemptExhaustively(uri.GetURIString(), request, method, signerName);
5254
}
53-
const char* GetServiceClientName() const override { return "CredentialTestingClient"; }
5455

55-
protected:
56-
AWSError<CoreErrors> BuildAWSError(const std::shared_ptr<HttpResponse>&) const override {
57-
return {CoreErrors::UNKNOWN, false};
56+
Aws::Client::AWSError<Aws::Client::CoreErrors> BuildAWSError(const std::shared_ptr<Aws::Http::HttpResponse>&) const override
57+
{
58+
Aws::Client::AWSError<Aws::Client::CoreErrors> error;
59+
return error;
5860
}
5961
};
6062

@@ -159,7 +161,7 @@ class SSOCredentialsProviderTrackingTest : public Aws::Testing::AwsCppSdkGTestSu
159161

160162
void RunTestWithCredentialsProvider(const std::shared_ptr<AWSCredentialsProvider>& provider, const Aws::String& marker) {
161163
// 200 OK dummy response for the signed call
162-
auto req = CreateHttpRequest(URI("dummy"), HttpMethod::HTTP_POST, Aws::Utils::Stream::DefaultResponseStreamFactoryMethod);
164+
auto req = CreateHttpRequest(URI("https://test-service.us-east-1.amazonaws.com/"), HttpMethod::HTTP_POST, Aws::Utils::Stream::DefaultResponseStreamFactoryMethod);
163165
auto ok = Aws::MakeShared<StandardHttpResponse>(TEST_LOG_TAG, req);
164166
ok->SetResponseCode(HttpResponseCode::OK);
165167
ok->GetResponseBody() << "{}";
@@ -169,9 +171,13 @@ class SSOCredentialsProviderTrackingTest : public Aws::Testing::AwsCppSdkGTestSu
169171
ClientConfiguration cfg(initVals);
170172
cfg.region = Aws::Region::US_EAST_1;
171173

172-
CredentialTestingClient client(cfg, provider);
174+
auto signer = Aws::MakeShared<Aws::Client::AWSAuthV4Signer>(TEST_LOG_TAG, provider, "test-service", cfg.region);
175+
CredentialTestingClient client(cfg, signer);
173176
AmazonWebServiceRequestMock mockReq;
174-
auto outcome = client.MakeRequest(mockReq);
177+
178+
// Use public AWS client method to make a request
179+
URI uri("https://test-service.us-east-1.amazonaws.com/");
180+
auto outcome = client.PublicAttemptExhaustively(uri, mockReq, HttpMethod::HTTP_POST, Aws::Auth::SIGV4_SIGNER);
175181
ASSERT_TRUE(outcome.IsSuccess());
176182

177183
auto last = mockHttpClient->GetMostRecentHttpRequest();

0 commit comments

Comments
 (0)