Skip to content

Commit b9319bc

Browse files
committed
updates to test
1 parent 46db669 commit b9319bc

File tree

2 files changed

+21
-7
lines changed

2 files changed

+21
-7
lines changed

tests/aws-cpp-sdk-s3control-integration-tests/S3ControlTest.cpp

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@
4646
#include <aws/sts/STSClient.h>
4747
#include <aws/sts/model/AssumeRoleRequest.h>
4848
#include <thread>
49+
#include <aws/testing/mocks/http/MockHttpClient.h>
50+
#include <aws/core/http/standard/StandardHttpResponse.h>
51+
4952

5053
using namespace Aws;
5154
using namespace Aws::Http;
@@ -732,6 +735,11 @@ namespace
732735

733736
TEST_F(S3ControlTest, TestRemoveHostPrefix)
734737
{
738+
auto mock_client_factory= Aws::MakeShared<MockHttpClientFactory>(ALLOCATION_TAG);
739+
auto mock_http_client = Aws::MakeShared<MockHttpClient>(ALLOCATION_TAG);
740+
mock_client_factory->SetClient(mock_http_client);
741+
SetHttpClientFactory(mock_client_factory);
742+
735743
ClientConfiguration config;
736744
config.region = Aws::Region::US_EAST_1;
737745
auto s3controlClient = S3ControlClient(config);
@@ -742,10 +750,18 @@ TEST_F(S3ControlTest, TestRemoveHostPrefix)
742750
.WithBucket(bucket)
743751
.WithAccountId(m_accountId)
744752
.WithBucketAccountId(m_accountId);
745-
auto resolveEndpointOutcome = s3controlClient.accessEndpointProvider()->ResolveEndpoint(request.GetEndpointContextParams());
746-
EXPECT_TRUE(resolveEndpointOutcome.IsSuccess());
747-
EXPECT_EQ(resolveEndpointOutcome.GetResult().GetURL(), "https://s3express-control.us-east-1.amazonaws.com");
753+
//create dummy request and response
754+
std::shared_ptr<HttpRequest> dummyReq = CreateHttpRequest(URI("www.uri.com"), HttpMethod::HTTP_GET, Aws::Utils::Stream::DefaultResponseStreamFactoryMethod);
755+
std::shared_ptr<Aws::Http::Standard::StandardHttpResponse> dummyResponse = Aws::MakeShared<Aws::Http::Standard::StandardHttpResponse>(ALLOCATION_TAG, dummyReq);
756+
dummyResponse->SetResponseCode(HttpResponseCode::OK);
757+
758+
mock_http_client->AddResponseToReturn(dummyResponse);
748759
auto createAccessPointOutcome = s3controlClient.CreateAccessPoint(request);
749-
EXPECT_FALSE(createAccessPointOutcome.IsSuccess());
760+
EXPECT_TRUE(createAccessPointOutcome.IsSuccess());
761+
const auto requestSeen = mock_http_client->GetMostRecentHttpRequest();
762+
EXPECT_EQ("https://s3express-control.us-east-1.amazonaws.com/v20180820/accesspoint/test-ap--use2-az1--xa-s3", requestSeen.GetUri().GetURIString());
763+
764+
mock_client_factory.reset();
765+
mock_http_client.reset();
750766
}
751767
}

tools/code-generation/generator/src/main/resources/com/amazonaws/util/awsclientgenerator/velocity/cpp/common/UriRequestQueryParams.vm

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,10 @@ ${indent} }
2525
#end
2626
#if(!$operation.request.shape.hasEventStreamMembers() && !($serviceNamespace == "S3Crt" && $operation.s3CrtEnabled))
2727
${indent} AWS_OPERATION_CHECK_SUCCESS(endpointResolutionOutcome, ${operation.name}, CoreErrors, CoreErrors::ENDPOINT_RESOLUTION_FAILURE, endpointResolutionOutcome.GetError().GetMessage());
28-
#if($operation.hasEndpointTrait)## Note: EndpointDiscovery Trait is not Endpoint Trait
29-
#if(!($serviceNamespace == "S3Control" && $serviceModel.rawEndpointRules))
28+
#if($operation.hasEndpointTrait && !($serviceNamespace == "S3Control" && $serviceModel.rawEndpointRules) )## Note: EndpointDiscovery Trait is not Endpoint Trait
3029
${indent} auto addPrefixErr = endpointResolutionOutcome.GetResult().AddPrefixIfMissing(${operation.endpoint.constructHostPrefixString("request")});
3130
${indent} AWS_CHECK(SERVICE_NAME, !addPrefixErr, addPrefixErr->GetMessage(), ${operation.name}Outcome(addPrefixErr.value()));
3231
#end
33-
#end
3432
#else
3533
${indent} if (!endpointResolutionOutcome.IsSuccess()) {
3634
${indent} handler(this, request, ${operation.name}Outcome(Aws::Client::AWSError<CoreErrors>(

0 commit comments

Comments
 (0)