Skip to content

Commit b857038

Browse files
committed
Bug in LocationConstraint: fix us-east-1 handling
Serialization would always fail.
1 parent 4fc120c commit b857038

File tree

3 files changed

+29
-1
lines changed

3 files changed

+29
-1
lines changed

server/src/main/java/com/adobe/testing/s3mock/dto/RegionSerializer.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ public void serialize(Region value, JsonGenerator gen, SerializerProvider serial
3333
//API doc says to return "null" for the us-east-1 region.
3434
if ("us-east-1".equals(regionString)) {
3535
gen.writeString("null");
36+
} else {
37+
gen.writeString(regionString);
3638
}
37-
gen.writeString(regionString);
3839
}
3940
}

server/src/test/kotlin/com/adobe/testing/s3mock/dto/LocationConstraintTest.kt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,12 @@ internal class LocationConstraintTest {
3030
assertThat(iut).isNotNull()
3131
serializeAndAssert(iut, testInfo)
3232
}
33+
34+
@Test
35+
@Throws(IOException::class)
36+
fun testSerialization_usEastOne(testInfo: TestInfo) {
37+
val iut = LocationConstraint(Region.fromValue("us-east-1"))
38+
assertThat(iut).isNotNull()
39+
serializeAndAssert(iut, testInfo)
40+
}
3341
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
4+
Copyright 2017-2024 Adobe.
5+
6+
Licensed under the Apache License, Version 2.0 (the "License");
7+
you may not use this file except in compliance with the License.
8+
You may obtain a copy of the License at
9+
10+
http://www.apache.org/licenses/LICENSE-2.0
11+
12+
Unless required by applicable law or agreed to in writing, software
13+
distributed under the License is distributed on an "AS IS" BASIS,
14+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
See the License for the specific language governing permissions and
16+
limitations under the License.
17+
18+
-->
19+
<LocationConstraint xmlns="http://s3.amazonaws.com/doc/2006-03-01/">null</LocationConstraint>

0 commit comments

Comments
 (0)