@@ -378,6 +378,37 @@ TEST_F(S3UnitTest, PutObjectShouldHaveCorrectUserAgent) {
378378 EXPECT_TRUE (archMetadata < businessMetrics);
379379}
380380
381+ TEST_F (S3UnitTest, PutObjectS3ExpressShouldHaveJMetric) {
382+ auto request = PutObjectRequest ()
383+ .WithBucket (" o-worthy-heart--usw2-az1--x-s3" ) // S3Express bucket pattern
384+ .WithKey (" who-tempers-anxiety-into-strength" );
385+
386+ std::shared_ptr<IOStream> body = Aws::MakeShared<StringStream>(ALLOCATION_TAG, " time marches on, and the age of a new king draws nearer" );
387+ request.SetBody (body);
388+
389+ auto mockRequest = Aws::MakeShared<Standard::StandardHttpRequest>(ALLOCATION_TAG, " alonzo.com/faker" , HttpMethod::HTTP_PUT);
390+ mockRequest->SetResponseStreamFactory ([]() -> IOStream* {
391+ return Aws::New<StringStream>(ALLOCATION_TAG, " " , std::ios_base::in | std::ios_base::binary);
392+ });
393+ auto mockResponse = Aws::MakeShared<Standard::StandardHttpResponse>(ALLOCATION_TAG, mockRequest);
394+ mockResponse->SetResponseCode (HttpResponseCode::OK);
395+
396+ _mockHttpClient->AddResponseToReturn (mockResponse);
397+
398+ const auto response = _s3Client->PutObject (request);
399+
400+ const auto requestSeen = _mockHttpClient->GetMostRecentHttpRequest ();
401+ EXPECT_TRUE (requestSeen.HasUserAgent ());
402+ const auto & userAgent = requestSeen.GetUserAgent ();
403+ EXPECT_TRUE (!userAgent.empty ());
404+ const auto userAgentParsed = Utils::StringUtils::Split (userAgent, ' ' );
405+
406+ // Check for S3Express business metric (J) in user agent
407+ auto businessMetrics = std::find_if (userAgentParsed.begin (), userAgentParsed.end (),
408+ [](const Aws::String & value) { return value.find (" m/" ) != Aws::String::npos && value.find (" J" ) != Aws::String::npos; });
409+ EXPECT_TRUE (businessMetrics != userAgentParsed.end ());
410+ }
411+
381412TEST_F (S3UnitTest, RequestShouldNotIncludeAChecksumIfNotRequired) {
382413 S3ClientConfiguration configuration{};
383414 configuration.checksumConfig .requestChecksumCalculation = RequestChecksumCalculation::WHEN_REQUIRED;
0 commit comments