@@ -163,6 +163,9 @@ BucketMetadata CreateBucketMetadataForTest() {
163163 "website": {
164164 "mainPageSuffix": "index.html",
165165 "notFoundPage": "404.html"
166+ },
167+ "customPlacementConfig": {
168+ "dataLocations": ["us-central1", "us-east1"]
166169 }
167170})""" ;
168171 return internal::BucketMetadataParser::FromString (text).value ();
@@ -277,6 +280,14 @@ TEST(BucketMetadataTest, Parse) {
277280 ASSERT_TRUE (actual.has_website ());
278281 EXPECT_EQ (" index.html" , actual.website ().main_page_suffix );
279282 EXPECT_EQ (" 404.html" , actual.website ().not_found_page );
283+
284+ // custom placement config
285+ ASSERT_TRUE (actual.has_custom_placement_config ());
286+ EXPECT_THAT (actual.custom_placement_config ().data_locations ,
287+ ElementsAre (" us-central1" , " us-east1" ));
288+ ASSERT_TRUE (actual.custom_placement_config_as_optional ().has_value ());
289+ EXPECT_THAT (actual.custom_placement_config_as_optional ()->data_locations ,
290+ ElementsAre (" us-central1" , " us-east1" ));
280291}
281292
282293// / @test Verify that the IOStream operator works as expected.
@@ -350,6 +361,12 @@ TEST(BucketMetadataTest, IOStream) {
350361 // website()
351362 EXPECT_THAT (actual, HasSubstr (" index.html" ));
352363 EXPECT_THAT (actual, HasSubstr (" 404.html" ));
364+
365+ // custom_placement_config()
366+ EXPECT_THAT (
367+ actual,
368+ HasSubstr (
369+ " custom_placement_config.data_locations=[us-central1, us-east1]" ));
353370}
354371
355372// / @test Verify we can convert a BucketMetadata object to a JSON string.
@@ -476,6 +493,13 @@ TEST(BucketMetadataTest, ToJsonString) {
476493 ASSERT_TRUE (actual[" website" ].is_object ()) << actual;
477494 EXPECT_EQ (" index.html" , actual[" website" ].value (" mainPageSuffix" , " " ));
478495 EXPECT_EQ (" 404.html" , actual[" website" ].value (" notFoundPage" , " " ));
496+
497+ // custom_placement_config()
498+ ASSERT_TRUE (actual.contains (" customPlacementConfig" )) << actual;
499+ auto expected_custom_placement_config = nlohmann::json{
500+ {" dataLocations" , std::vector<std::string>{" us-central1" , " us-east1" }},
501+ };
502+ EXPECT_EQ (actual[" customPlacementConfig" ], expected_custom_placement_config);
479503}
480504
481505TEST (BucketMetadataTest, ToJsonLifecycleRoundtrip) {
@@ -863,6 +887,39 @@ TEST(BucketMetadataTest, ResetWebsite) {
863887 EXPECT_THAT (os.str (), Not (HasSubstr (" website." )));
864888}
865889
890+ // / @test Verify we can set the custom_placement_config field in BucketMetadata.
891+ TEST (BucketMetadataTest, SetCustomPlacementConfig) {
892+ auto expected = CreateBucketMetadataForTest ();
893+ auto copy = expected;
894+ copy.set_custom_placement_config (
895+ BucketCustomPlacementConfig{{" test-location-1" , " test-location-2" }});
896+ ASSERT_TRUE (copy.has_custom_placement_config ());
897+ EXPECT_THAT (copy.custom_placement_config ().data_locations ,
898+ ElementsAre (" test-location-1" , " test-location-2" ));
899+ ASSERT_TRUE (copy.custom_placement_config_as_optional ().has_value ());
900+ EXPECT_THAT (copy.custom_placement_config_as_optional ()->data_locations ,
901+ ElementsAre (" test-location-1" , " test-location-2" ));
902+ EXPECT_NE (copy, expected);
903+ std::ostringstream os;
904+ os << copy;
905+ EXPECT_THAT (os.str (), HasSubstr (" custom_placement_config" ));
906+ }
907+
908+ // / @test Verify we can set the custom_placement_config field in BucketMetadata.
909+ TEST (BucketMetadataTest, ResetCustomPlacementConfig) {
910+ auto expected = CreateBucketMetadataForTest ();
911+ EXPECT_TRUE (expected.has_custom_placement_config ());
912+ EXPECT_TRUE (expected.custom_placement_config_as_optional ().has_value ());
913+ auto copy = expected;
914+ copy.reset_custom_placement_config ();
915+ EXPECT_FALSE (copy.has_custom_placement_config ());
916+ EXPECT_FALSE (copy.custom_placement_config_as_optional ().has_value ());
917+ EXPECT_NE (copy, expected);
918+ std::ostringstream os;
919+ os << copy;
920+ EXPECT_THAT (os.str (), Not (HasSubstr (" custom_placement_config" )));
921+ }
922+
866923TEST (BucketMetadataPatchBuilder, SetAcl) {
867924 BucketMetadataPatchBuilder builder;
868925 builder.SetAcl ({internal::BucketAccessControlParser::FromString (
0 commit comments