|
24 | 24 | #include <aws/core/utils/logging/LogMacros.h> |
25 | 25 | #include <aws/core/client/AWSErrorMarshaller.h> |
26 | 26 | #include <aws/core/utils/xml/XmlSerializer.h> |
| 27 | +#include <aws/core/AmazonSerializableWebServiceRequest.h> |
27 | 28 |
|
28 | 29 |
|
29 | 30 | using namespace Aws; |
@@ -519,6 +520,30 @@ TEST_F(AWSClientTestSuite, TestRecursionDetection) |
519 | 520 | mockHttpClient->Reset(); |
520 | 521 | } |
521 | 522 | } |
| 523 | + |
| 524 | +TEST_F(AWSClientTestSuite, TestCborUserAgent) |
| 525 | +{ |
| 526 | + HeaderValueCollection responseHeaders; |
| 527 | + AmazonWebServiceRequestMock request; |
| 528 | + request.SetAdditionalCustomHeaderValue(Aws::Http::SMITHY_PROTOCOL_HEADER, Aws::RPC_V2_CBOR); |
| 529 | + QueueMockResponse(HttpResponseCode::OK, responseHeaders); |
| 530 | + auto outcome = client->MakeRequest(request); |
| 531 | + |
| 532 | + auto lastRequest = mockHttpClient->GetMostRecentHttpRequest(); |
| 533 | + EXPECT_TRUE(lastRequest.HasUserAgent()); |
| 534 | + const auto& userAgent = lastRequest.GetUserAgent(); |
| 535 | + EXPECT_TRUE(!userAgent.empty()); |
| 536 | + |
| 537 | + const auto userAgentParsed = Aws::Utils::StringUtils::Split(userAgent, ' '); |
| 538 | + |
| 539 | + EXPECT_TRUE(!Aws::Client::UserAgent::BusinessMetricForFeature(UserAgentFeature::PROTOCOL_RPC_V2_CBOR).empty()); |
| 540 | + // Check for CBOR protocol business metric (M) in user agent |
| 541 | + auto businessMetrics = std::find_if(userAgentParsed.begin(), userAgentParsed.end(), |
| 542 | + [](const Aws::String& value) { return value.find("m/") != Aws::String::npos && value.find(Aws::Client::UserAgent::BusinessMetricForFeature(UserAgentFeature::PROTOCOL_RPC_V2_CBOR)) != Aws::String::npos; }); |
| 543 | + |
| 544 | + EXPECT_TRUE(businessMetrics != userAgentParsed.end()); |
| 545 | + |
| 546 | +} |
522 | 547 | using namespace Aws::Utils::Xml; |
523 | 548 | TEST_F(XMLClientTestSuite, TestErrorInBodyOfResponse) |
524 | 549 | { |
|
0 commit comments