Skip to content

Commit b01627c

Browse files
committed
Remove legacy properties.
1 parent cdbfc17 commit b01627c

File tree

13 files changed

+65
-183
lines changed

13 files changed

+65
-183
lines changed

CHANGELOG.md

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -129,15 +129,9 @@ Running S3Mock in unit tests is still supported by using [TestContainers](https:
129129
* Features and fixes
130130
* TBD
131131
* Refactorings
132-
* Removal of legacy-style Spring properties in favor of current environment variables.
133-
* AWS has deprecated SDK for Java v1, and will remove support EOY 2025.
134-
* S3Mock will remove bundled support for Java SDK v1 in late 2025.
135-
* JUnit 4.x deprecation
136-
* S3Mock will remove bundled support for JUnit 4.x in late 2025.
137132
* Looking to Remove unit test modules. This enables
138133
* Refactoring S3Mock to a "standard" Spring Boot application.
139134
* Removal of workarounds to use `S3MockApplication#start` from a static context
140-
* Removal of properties workarounds
141135
* Migration to `Kotlin` - the IntegrationTests and unit tests were migrated already.
142136
* Version updates
143137
* TBD
@@ -151,27 +145,14 @@ Running S3Mock in unit tests is still supported by using [TestContainers](https:
151145
* Remove Java SDK v1.
152146
* JUnit 4.x deprecation
153147
* Remove JUnit 4.x support.
148+
* Remove legacy properties for S3Mock configuration.
154149
* Version updates
155150
* Bump Spring Boot version to 4.x
156151
* Bump Spring Framework version to 7.x
157152
* Bump java version from 17 to 25
158153
* S3Mock will use the baseline Spring chooses to support.
159154
* The Docker container will run Java 25 LTS.
160155

161-
## 5.0.0 - PLANNED
162-
163-
* Features and fixes
164-
* TBD
165-
* Refactorings
166-
* AWS has deprecated SDK for Java v1, and will remove support EOY 2025.
167-
* Remove Java v1.
168-
* JUnit 4.x deprecation
169-
* Remove JUnit 4.x support.
170-
* Version updates
171-
* Bump Spring Boot version to 4.x
172-
* Bump Spring Framework version to 7.x
173-
* Bump java version from 17 to 25
174-
175156
# CURRENT - 4.x - THIS VERSION IS UNDER ACTIVE DEVELOPMENT
176157
Version 4.x is JDK17 LTS bytecode compatible, with Docker and JUnit / direct Java integration.
177158

README.md

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@
6363
* [Contributing](#contributing)
6464
* [Licensing](#licensing)
6565
* [Powered by](#powered-by)
66+
* [Star History](#star-history)
6667
<!-- TOC -->
6768

6869
## S3Mock
@@ -300,7 +301,6 @@ curl --insecure --request GET https://localhost:9191/my-test-bucket/my-file -O
300301
The mock can be configured with the following environment variables:
301302

302303
- `COM_ADOBE_TESTING_S3MOCK_STORE_VALID_KMS_KEYS`: list of KMS Key-Refs that are to be treated as *valid*.
303-
- Legacy name: `validKmsKeys`
304304
- Default: none
305305
- KMS keys must be configured as valid ARNs in the format of "`arn:aws:kms:region:acct-id:key/key-id`", for example "
306306
`arn:aws:kms:us-east-1:1234567890:key/valid-test-key-id`"
@@ -310,20 +310,16 @@ The mock can be configured with the following environment variables:
310310
- *S3Mock does not implement KMS encryption*, if a key ID is passed in a request, S3Mock will just validate if a given
311311
Key was configured during startup and reject the request if the given Key was not configured.
312312
- `COM_ADOBE_TESTING_S3MOCK_STORE_INITIAL_BUCKETS`: list of names for buckets that will be available initially.
313-
- Legacy name: `initialBuckets`
314313
- Default: none
315314
- The list must be comma separated names like `bucketa, bucketb`
316315
- `COM_ADOBE_TESTING_S3MOCK_STORE_REGION`: the region the S3Mock is supposed to mock.
317-
- Legacy name: `COM_ADOBE_TESTING_S3MOCK_REGION`
318-
- Example: `eu-west-1`
319316
- Default: `us-east-1`
317+
- Value must be a valid AWS region identifier like `eu-west-1`
320318
- `COM_ADOBE_TESTING_S3MOCK_STORE_ROOT`: the base directory to place the temporary files exposed by the mock. If S3Mock is started in Docker, a volume
321319
must be mounted as the `root` directory, see examples below.
322-
- Legacy name: `root`
323320
- Default: Java temp directory
324321
- `COM_ADOBE_TESTING_S3MOCK_STORE_RETAIN_FILES_ON_EXIT`: set to `true` to let S3Mock keep all files that were created during its lifetime. Default is
325322
`false`, all files are removed if S3Mock shuts down.
326-
- Legacy name: `retainFilesOnExit`
327323
- Default: false
328324
- `debug`: set to `true` to
329325
enable [Spring Boot's debug output](https://docs.spring.io/spring-boot/docs/current/reference/html/features.html#features.logging.console-output).

integration-tests/pom.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -192,9 +192,9 @@
192192
<time>30000</time>
193193
</wait>
194194
<env>
195-
<COM_ADOBE_TESTING_S3MOCK_DOMAIN_VALID_KMS_KEYS>arn:aws:kms:us-east-1:1234567890:key/valid-test-key-id</COM_ADOBE_TESTING_S3MOCK_DOMAIN_VALID_KMS_KEYS>
196-
<COM_ADOBE_TESTING_S3MOCK_DOMAIN_INITIAL_BUCKETS>bucket-a, bucket-b</COM_ADOBE_TESTING_S3MOCK_DOMAIN_INITIAL_BUCKETS>
197-
<COM_ADOBE_TESTING_S3MOCK_REGION>eu-west-1</COM_ADOBE_TESTING_S3MOCK_REGION>
195+
<COM_ADOBE_TESTING_S3MOCK_STORE_VALID_KMS_KEYS>arn:aws:kms:us-east-1:1234567890:key/valid-test-key-id</COM_ADOBE_TESTING_S3MOCK_STORE_VALID_KMS_KEYS>
196+
<COM_ADOBE_TESTING_S3MOCK_STORE_INITIAL_BUCKETS>bucket-a, bucket-b</COM_ADOBE_TESTING_S3MOCK_STORE_INITIAL_BUCKETS>
197+
<COM_ADOBE_TESTING_S3MOCK_STORE_REGION>eu-west-1</COM_ADOBE_TESTING_S3MOCK_STORE_REGION>
198198
</env>
199199
<memory>256000000</memory>
200200
</run>

server/src/main/java/com/adobe/testing/s3mock/S3MockApplication.java

Lines changed: 2 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -58,18 +58,6 @@ public class S3MockApplication {
5858
public static final String DEFAULT_SERVER_SSL_KEY_ALIAS = "selfsigned";
5959
public static final String DEFAULT_SERVER_SSL_KEY_PASSWORD = "password";
6060

61-
/**
62-
* Property name for passing a comma-separated list of buckets that are to be created at startup.
63-
*/
64-
public static final String PROP_INITIAL_BUCKETS = "com.adobe.testing.s3mock.store.initialBuckets";
65-
private static final String LEGACY_PROP_INITIAL_BUCKETS = "initialBuckets";
66-
67-
/**
68-
* Property name for passing a root directory to use. If omitted a default temp-dir will be used.
69-
*/
70-
public static final String PROP_ROOT_DIRECTORY = "com.adobe.testing.s3mock.store.root";
71-
private static final String LEGACY_PROP_ROOT_DIRECTORY = "root";
72-
7361
/**
7462
* Property name for passing the HTTPS port to use. Defaults to {@value DEFAULT_HTTPS_PORT}. If
7563
* set to {@value RANDOM_PORT}, a random port will be chosen.
@@ -106,11 +94,6 @@ public class S3MockApplication {
10694
*/
10795
public static final String SERVER_SSL_KEY_PASSWORD = "server.ssl.key-password";
10896

109-
/**
110-
* Property name for using either HTTPS or HTTP connections.
111-
*/
112-
public static final String PROP_SECURE_CONNECTION = "secureConnection";
113-
11497
/**
11598
* Property name for enabling the silent mode with logging set at WARN and without banner.
11699
*/
@@ -178,68 +161,14 @@ public static S3MockApplication start(final Map<String, Object> properties,
178161

179162
final var ctx =
180163
new SpringApplicationBuilder(S3MockApplication.class)
181-
.properties(translateLegacyProperties(defaults))
182-
.properties(translateLegacyProperties(properties))
164+
.properties(defaults)
165+
.properties(properties)
183166
.bannerMode(bannerMode)
184167
.run(args);
185168

186169
return ctx.getBean(S3MockApplication.class);
187170
}
188171

189-
/**
190-
* Hack to still support startup of S3Mock from Java, e.g. in a (J)Unit-Test using one of the
191-
* Unit test integration modules.
192-
* -----------
193-
* TODO: Remove ASAP as this breaks Spring's Externalized Configuration
194-
* https://docs.spring.io/spring-boot/docs/current/reference/html/features.html#features.external-config
195-
* -----------
196-
* S3Mock is using @Configuration / @ConfigurationProperties for each package.
197-
* Before this was implemented, all properties were exposed without a package.
198-
* Translation of these properties should be done in "application.properties" as is standard with
199-
* Spring (Boot) applications. However, if S3Mock is used directly in a unit test from within a
200-
* Spring application, S3Mock reads the "application.properties" of the tested application instead
201-
* of its own "application.properties".
202-
* This is equivalent to:
203-
* com.adobe.testing.s3mock.httpPort=${http.port:}
204-
* com.adobe.testing.s3mock.domain.initialBuckets=${initialBuckets:}
205-
* com.adobe.testing.s3mock.domain.retainFilesOnExit=${retainFilesOnExit:}
206-
* com.adobe.testing.s3mock.domain.root=${root:}
207-
* com.adobe.testing.s3mock.domain.validKmsKeys=${validKmsKeys:}
208-
*/
209-
private static Map<String, Object> translateLegacyProperties(Map<String, Object> properties) {
210-
// make incoming map mutable
211-
var translated = new HashMap<>(properties);
212-
translateLegacyProperty(translated, PROP_ROOT_DIRECTORY, LEGACY_PROP_ROOT_DIRECTORY);
213-
translateLegacyProperty(translated, PROP_INITIAL_BUCKETS, LEGACY_PROP_INITIAL_BUCKETS);
214-
translateLegacyProperty(translated,
215-
"com.adobe.testing.s3mock.store.retainFilesOnExit", "retainFilesOnExit");
216-
translateLegacyProperty(translated,
217-
"com.adobe.testing.s3mock.store.validKmsKeys", "validKmsKeys");
218-
translateLegacyProperty(translated,
219-
"com.adobe.testing.s3mock.httpPort", "http.port");
220-
return translated;
221-
}
222-
223-
private static void translateLegacyProperty(Map<String, Object> properties, String propertyName,
224-
String legacyPropertyName) {
225-
if (!properties.containsKey(propertyName)) {
226-
// start by looking at incoming properties
227-
if (properties.containsKey(legacyPropertyName)) {
228-
properties.put(propertyName, properties.get(legacyPropertyName));
229-
}
230-
// these may be overwritten by system properties
231-
var legacySystemProperty = System.getProperty(legacyPropertyName);
232-
if (legacySystemProperty != null) {
233-
properties.put(propertyName, legacySystemProperty);
234-
}
235-
// highest precedence to environment variables.
236-
var legacyEnvironmentProperty = System.getenv(legacyPropertyName);
237-
if (legacyEnvironmentProperty != null) {
238-
properties.put(propertyName, legacyEnvironmentProperty);
239-
}
240-
}
241-
}
242-
243172
/**
244173
* Stops the server.
245174
*/

server/src/main/java/com/adobe/testing/s3mock/store/LegacyStoreProperties.java

Lines changed: 0 additions & 40 deletions
This file was deleted.

server/src/main/java/com/adobe/testing/s3mock/store/StoreConfiguration.java

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
import software.amazon.awssdk.regions.Region;
4040

4141
@Configuration
42-
@EnableConfigurationProperties({StoreProperties.class, LegacyStoreProperties.class})
42+
@EnableConfigurationProperties(StoreProperties.class)
4343
public class StoreConfiguration {
4444

4545
private static final Logger LOG = LoggerFactory.getLogger(StoreConfiguration.class);
@@ -63,11 +63,10 @@ ObjectStore objectStore(
6363
@Bean
6464
BucketStore bucketStore(
6565
StoreProperties properties,
66-
LegacyStoreProperties legacyProperties,
6766
File rootFolder,
6867
List<String> bucketNames,
6968
ObjectMapper objectMapper,
70-
@Nullable @Value("${com.adobe.testing.s3mock.region}") Region region) {
69+
@Nullable @Value("${com.adobe.testing.s3mock.store.region}") Region region) {
7170
Region mockRegion = region == null ? properties.region() : region;
7271

7372
var bucketStore = new BucketStore(rootFolder, S3_OBJECT_DATE_FORMAT, mockRegion.id(), objectMapper);
@@ -76,9 +75,7 @@ BucketStore bucketStore(
7675

7776
// load initialBuckets if not part of existing buckets
7877
List<String> initialBuckets = List.of();
79-
if (!legacyProperties.initialBuckets().isEmpty()) {
80-
initialBuckets = legacyProperties.initialBuckets();
81-
} else if (!properties.initialBuckets().isEmpty()) {
78+
if (!properties.initialBuckets().isEmpty()) {
8279
initialBuckets = properties.initialBuckets();
8380
}
8481

@@ -135,26 +132,22 @@ MultipartStore multipartStore(
135132

136133
@Bean
137134
KmsKeyStore kmsKeyStore(
138-
StoreProperties properties,
139-
LegacyStoreProperties legacyProperties) {
135+
StoreProperties properties
136+
) {
140137
if (!properties.validKmsKeys().isEmpty()) {
141138
return new KmsKeyStore(properties.validKmsKeys());
142-
} else if (!legacyProperties.validKmsKeys().isEmpty()) {
143-
return new KmsKeyStore(legacyProperties.validKmsKeys());
144139
}
145140

146141
return new KmsKeyStore(new HashSet<>());
147142
}
148143

149144
@Bean
150145
File rootFolder(
151-
StoreProperties properties,
152-
LegacyStoreProperties legacyProperties) {
146+
StoreProperties properties
147+
) {
153148
File root;
154149
String rootPath = null;
155-
if (legacyProperties.root() != null && !legacyProperties.root().isEmpty()) {
156-
rootPath = legacyProperties.root();
157-
} else if (properties.root() != null && !properties.root().isEmpty()) {
150+
if (properties.root() != null && !properties.root().isEmpty()) {
158151
rootPath = properties.root();
159152
}
160153

@@ -192,9 +185,9 @@ File rootFolder(
192185
@Bean
193186
StoreCleaner storeCleaner(
194187
File rootFolder,
195-
StoreProperties properties,
196-
LegacyStoreProperties legacyProperties) {
197-
if (legacyProperties.retainFilesOnExit() || properties.retainFilesOnExit()) {
188+
StoreProperties properties
189+
) {
190+
if (properties.retainFilesOnExit()) {
198191
return new StoreCleaner(rootFolder, true);
199192
} else {
200193
return new StoreCleaner(rootFolder, false);

server/src/main/resources/application.properties

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,13 @@ logging.level.org.springframework.web.servlet.mvc.method.annotation.ExceptionHan
2222
# deactivate JMX to save resources and startup time
2323
spring.jmx.enabled=false
2424

25-
com.adobe.testing.s3mock.region=us-east-1
25+
com.adobe.testing.s3mock.store.region=us-east-1
2626

2727
# allow S3Mock to consume larger payloads
2828
server.tomcat.max-swallow-size=10MB
2929

3030
management.endpoints.web.discovery.enabled=false
3131

3232
spring.main.lazy-initialization=true
33+
34+
com.adobe.testing.s3mock.httpPort=${http.port:}

server/src/test/kotlin/com/adobe/testing/s3mock/BucketControllerTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ import java.nio.file.Path
7979
import java.time.Instant
8080

8181
@MockitoBean(types = [KmsKeyStore::class, ObjectService::class, MultipartService::class, ObjectController::class, MultipartController::class])
82-
@WebMvcTest(properties = ["com.adobe.testing.s3mock.region=us-east-1"])
82+
@WebMvcTest(properties = ["com.adobe.testing.s3mock.store.region=us-east-1"])
8383
internal class BucketControllerTest : BaseControllerTest() {
8484
@MockitoBean
8585
private lateinit var bucketService: BucketService

server/src/test/kotlin/com/adobe/testing/s3mock/ObjectControllerTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ import java.time.Instant
8282
import java.util.UUID
8383

8484
@MockitoBean(types = [KmsKeyStore::class, MultipartService::class, BucketController::class, MultipartController::class])
85-
@WebMvcTest(properties = ["com.adobe.testing.s3mock.region=us-east-1"])
85+
@WebMvcTest(properties = ["com.adobe.testing.s3mock.store.region=us-east-1"])
8686
internal class ObjectControllerTest : BaseControllerTest() {
8787
@MockitoBean
8888
private lateinit var objectService: ObjectService

server/src/test/kotlin/com/adobe/testing/s3mock/store/StoreConfigurationTest.kt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,9 @@ internal class StoreConfigurationTest {
3636
val initialBucketName = "initialBucketName"
3737

3838
val properties = StoreProperties(false, null, setOf(), listOf(initialBucketName), Region.EU_CENTRAL_1)
39-
val legacyStoreProperties = LegacyStoreProperties(false, null, setOf(), listOf())
4039
val iut = StoreConfiguration()
4140
val bucketStore = iut.bucketStore(
4241
properties,
43-
legacyStoreProperties,
4442
tempDir.toFile(),
4543
listOf(),
4644
OBJECT_MAPPER,
@@ -83,12 +81,10 @@ internal class StoreConfigurationTest {
8381
val initialBucketName = "initialBucketName"
8482

8583
val properties = StoreProperties(false, null, setOf(), listOf(initialBucketName), Region.EU_CENTRAL_1)
86-
val legacyStoreProperties = LegacyStoreProperties(false, null, setOf(), listOf())
8784
val iut = StoreConfiguration()
8885
val bucketStore =
8986
iut.bucketStore(
9087
properties,
91-
legacyStoreProperties,
9288
tempDir.toFile(),
9389
listOf(existingBucketName),
9490
OBJECT_MAPPER,

0 commit comments

Comments
 (0)