46
46
#include < aws/sts/STSClient.h>
47
47
#include < aws/sts/model/AssumeRoleRequest.h>
48
48
#include < thread>
49
+ #include < aws/testing/mocks/http/MockHttpClient.h>
50
+ #include < aws/core/http/standard/StandardHttpResponse.h>
51
+
49
52
50
53
using namespace Aws ;
51
54
using namespace Aws ::Http;
@@ -732,6 +735,11 @@ namespace
732
735
733
736
TEST_F (S3ControlTest, TestRemoveHostPrefix)
734
737
{
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
+
735
743
ClientConfiguration config;
736
744
config.region = Aws::Region::US_EAST_1;
737
745
auto s3controlClient = S3ControlClient (config);
@@ -742,10 +750,18 @@ TEST_F(S3ControlTest, TestRemoveHostPrefix)
742
750
.WithBucket (bucket)
743
751
.WithAccountId (m_accountId)
744
752
.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);
748
759
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 ();
750
766
}
751
767
}
0 commit comments