diff --git a/.github/workflows/build-common.yml b/.github/workflows/build-common.yml
index ae90c46..0c22f2c 100644
--- a/.github/workflows/build-common.yml
+++ b/.github/workflows/build-common.yml
@@ -5,9 +5,6 @@ on:
branches-ignore:
- 'sprint'
- 'main'
- paths:
- - '${{ github.workspace }}/**'
- - '.github/workflows/**'
pull_request:
types: [ opened, reopened ]
diff --git a/RELEASENOTES.md b/RELEASENOTES.md
index 7615373..531b14f 100644
--- a/RELEASENOTES.md
+++ b/RELEASENOTES.md
@@ -1,4 +1,8 @@
# Release-Notes
+## Sprint 20 (12.11.2024 - 03.12.2024)
+- Maven groupid an LHM Standard angepasst.
+- S3CredentialProvider und EnvironmentReader als Bean.
+
## Sprint 18 (1.10.2024 - 22.10.2024)
### Hinzugefügt
- S3 Bucket Authorisierung.
diff --git a/mobidam-eai-commons-lib/pom.xml b/mobidam-eai-commons-lib/pom.xml
index a6d9504..b0f6ba5 100644
--- a/mobidam-eai-commons-lib/pom.xml
+++ b/mobidam-eai-commons-lib/pom.xml
@@ -26,7 +26,7 @@
4.0.0
- de.muenchen.mobidam
+ de.muenchen.oss.mobidam
mobidam-eai-commons
0.0.2-SNAPSHOT
@@ -72,10 +72,10 @@
junit-jupiter
test
-
+
org.mockito
mockito-core
test
-
+
\ No newline at end of file
diff --git a/mobidam-eai-commons-lib/src/main/java/de/muenchen/mobidam/eai/common/config/EnvironmentReader.java b/mobidam-eai-commons-lib/src/main/java/de/muenchen/mobidam/eai/common/config/EnvironmentReader.java
index d0b4f1d..9453cdc 100644
--- a/mobidam-eai-commons-lib/src/main/java/de/muenchen/mobidam/eai/common/config/EnvironmentReader.java
+++ b/mobidam-eai-commons-lib/src/main/java/de/muenchen/mobidam/eai/common/config/EnvironmentReader.java
@@ -22,9 +22,12 @@
*/
package de.muenchen.mobidam.eai.common.config;
+import lombok.AllArgsConstructor;
+
+@AllArgsConstructor
public class EnvironmentReader {
- public static String getEnvironmentVariable(final String key) {
+ public String getEnvironmentVariable(final String key) {
return System.getenv().get(key);
}
}
diff --git a/mobidam-eai-commons-lib/src/main/java/de/muenchen/mobidam/eai/common/s3/S3CredentialProvider.java b/mobidam-eai-commons-lib/src/main/java/de/muenchen/mobidam/eai/common/s3/S3CredentialProvider.java
index a974523..219201b 100644
--- a/mobidam-eai-commons-lib/src/main/java/de/muenchen/mobidam/eai/common/s3/S3CredentialProvider.java
+++ b/mobidam-eai-commons-lib/src/main/java/de/muenchen/mobidam/eai/common/s3/S3CredentialProvider.java
@@ -47,13 +47,14 @@ public class S3CredentialProvider implements Processor {
@NonNull
private final S3BucketCredentialConfig properties;
+ private final EnvironmentReader environmentReader;
@Override
public void process(Exchange exchange) throws Exception {
String bucketName = verifyBucket(exchange);
S3BucketCredentialConfig.BucketCredentialConfig credentials = verifyCredentials(bucketName, exchange);
- String accessKey = EnvironmentReader.getEnvironmentVariable(credentials.getAccessKeyEnvVar());
- String secretKey = EnvironmentReader.getEnvironmentVariable(credentials.getSecretKeyEnvVar());
+ String accessKey = environmentReader.getEnvironmentVariable(credentials.getAccessKeyEnvVar());
+ String secretKey = environmentReader.getEnvironmentVariable(credentials.getSecretKeyEnvVar());
if (Strings.isNullOrEmpty(accessKey) || Strings.isNullOrEmpty(secretKey)) {
exchange.getMessage()
.setBody(ErrorResponseBuilder.build(HttpStatus.SC_INTERNAL_SERVER_ERROR, "Bucket not configured: " + bucketName));
diff --git a/mobidam-eai-commons-lib/src/test/java/de/muenchen/mobidam/eai/S3CredentialProviderTest.java b/mobidam-eai-commons-lib/src/test/java/de/muenchen/mobidam/eai/S3CredentialProviderTest.java
index a2dbfad..fc28f31 100644
--- a/mobidam-eai-commons-lib/src/test/java/de/muenchen/mobidam/eai/S3CredentialProviderTest.java
+++ b/mobidam-eai-commons-lib/src/test/java/de/muenchen/mobidam/eai/S3CredentialProviderTest.java
@@ -27,47 +27,49 @@
import de.muenchen.mobidam.eai.common.config.S3BucketCredentialConfig;
import de.muenchen.mobidam.eai.common.exception.MobidamException;
import de.muenchen.mobidam.eai.common.s3.S3CredentialProvider;
+import java.util.HashMap;
+import java.util.Map;
import org.apache.camel.CamelContext;
import org.apache.camel.Exchange;
import org.apache.camel.impl.DefaultCamelContext;
import org.apache.camel.support.DefaultExchange;
import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
-import org.mockito.MockedStatic;
import org.mockito.Mockito;
-import java.util.HashMap;
-import java.util.Map;
-
public class S3CredentialProviderTest {
+ private EnvironmentReader environmentReader;
+ private S3BucketCredentialConfig s3CredentialProperties;
private S3CredentialProvider s3CredentialProvider;
private final CamelContext camelContext = new DefaultCamelContext();
+ @BeforeEach
+ void setup() {
+ environmentReader = Mockito.mock(EnvironmentReader.class);
+ s3CredentialProperties = Mockito.mock(S3BucketCredentialConfig.class);
+ s3CredentialProvider = new S3CredentialProvider(s3CredentialProperties, environmentReader);
+ }
+
@Test
public void test_processWithValidConfiguration() throws Exception {
+ // Given
+ String bucketName = "x-itmkm82k";
+ String envVar = "FOO";
+ String value = "BAR";
- try (MockedStatic environmentReader = Mockito.mockStatic(EnvironmentReader.class)) {
-
- // Given
- String bucketName = "x-itmkm82k";
- String envVar = "FOO";
- String value = "BAR";
-
- configureEnvironment(bucketName, envVar, value);
-
- Exchange exchange = new DefaultExchange(camelContext);
- exchange.getMessage().setHeader(CommonConstants.HEADER_BUCKET_NAME, bucketName);
+ configureEnvironment(bucketName, envVar, value);
- environmentReader.when(() -> EnvironmentReader.getEnvironmentVariable(envVar)).thenReturn(value);
+ Exchange exchange = new DefaultExchange(camelContext);
+ exchange.getMessage().setHeader(CommonConstants.HEADER_BUCKET_NAME, bucketName);
- // When
- s3CredentialProvider.process(exchange);
+ // When
+ s3CredentialProvider.process(exchange);
- // Then
- Assertions.assertEquals(value, exchange.getMessage().getHeader(CommonConstants.HEADER_ACCESS_KEY));
- Assertions.assertEquals(value, exchange.getMessage().getHeader(CommonConstants.HEADER_SECRET_KEY));
- }
+ // Then
+ Assertions.assertEquals(value, exchange.getMessage().getHeader(CommonConstants.HEADER_ACCESS_KEY));
+ Assertions.assertEquals(value, exchange.getMessage().getHeader(CommonConstants.HEADER_SECRET_KEY));
}
@Test
@@ -77,7 +79,8 @@ public void test_processWithMissingEnvVars() {
String envVar = "FOO";
String value = "BAR";
- configureEnvironment(bucketName, envVar, value);
+ Mockito.when(environmentReader.getEnvironmentVariable(Mockito.anyString())).thenReturn(null);
+
Exchange exchange = new DefaultExchange(camelContext);
exchange.getMessage().setHeader(CommonConstants.HEADER_BUCKET_NAME, bucketName);
@@ -96,6 +99,7 @@ public void test_processWithMissingBucketConfiguration() {
String value = "BAR";
configureEnvironment(bucketName, envVar, value);
+
Exchange exchange = new DefaultExchange(camelContext);
exchange.getMessage().setHeader(CommonConstants.HEADER_BUCKET_NAME, "invalid_bucket");
@@ -114,6 +118,7 @@ public void test_processWithMissingBucketName() {
String value = "BAR";
configureEnvironment(bucketName, envVar, value);
+
Exchange exchange = new DefaultExchange(camelContext);
// Then
@@ -124,14 +129,12 @@ public void test_processWithMissingBucketName() {
}
private void configureEnvironment(String bucketName, String envVar, String value) {
- S3BucketCredentialConfig properties = Mockito.mock(S3BucketCredentialConfig.class);
- s3CredentialProvider = new S3CredentialProvider(properties);
-
+ Mockito.when(environmentReader.getEnvironmentVariable(envVar)).thenReturn(value);
S3BucketCredentialConfig.BucketCredentialConfig envVars = new S3BucketCredentialConfig.BucketCredentialConfig();
envVars.setAccessKeyEnvVar(envVar);
envVars.setSecretKeyEnvVar(envVar);
Map map = new HashMap<>();
map.put(bucketName, envVars);
- Mockito.when(properties.getBucketCredentialConfigs()).thenReturn(map);
+ Mockito.when(s3CredentialProperties.getBucketCredentialConfigs()).thenReturn(map);
}
}
diff --git a/mobidam-eai-commons-starter/pom.xml b/mobidam-eai-commons-starter/pom.xml
index ba0cd42..0bc9ba1 100644
--- a/mobidam-eai-commons-starter/pom.xml
+++ b/mobidam-eai-commons-starter/pom.xml
@@ -26,7 +26,7 @@
4.0.0
- de.muenchen.mobidam
+ de.muenchen.oss.mobidam
mobidam-eai-commons
0.0.2-SNAPSHOT
@@ -52,7 +52,7 @@
${camel.version}
- de.muenchen.mobidam
+ de.muenchen.oss.mobidam
mobidam-eai-commons-lib
${project.version}
diff --git a/mobidam-eai-commons-starter/src/main/java/de/muenchen/mobidam/eai/integration/configuration/S3BucketCredentialConfigAutoConfiguration.java b/mobidam-eai-commons-starter/src/main/java/de/muenchen/mobidam/eai/integration/configuration/S3BucketCredentialConfigAutoConfiguration.java
index 3619aa2..dd7fce0 100644
--- a/mobidam-eai-commons-starter/src/main/java/de/muenchen/mobidam/eai/integration/configuration/S3BucketCredentialConfigAutoConfiguration.java
+++ b/mobidam-eai-commons-starter/src/main/java/de/muenchen/mobidam/eai/integration/configuration/S3BucketCredentialConfigAutoConfiguration.java
@@ -22,6 +22,7 @@
*/
package de.muenchen.mobidam.eai.integration.configuration;
+import de.muenchen.mobidam.eai.common.config.EnvironmentReader;
import de.muenchen.mobidam.eai.common.config.S3BucketCredentialConfig;
import de.muenchen.mobidam.eai.common.s3.S3CredentialProvider;
import org.apache.camel.component.aws2.s3.AWS2S3Component;
@@ -41,10 +42,16 @@ public S3BucketCredentialConfig s3BucketCredentialConfig() {
return new S3BucketCredentialConfig();
}
+ @Bean
+ @ConditionalOnMissingBean
+ public EnvironmentReader environmentReader() {
+ return new EnvironmentReader();
+ }
+
@Bean
@ConditionalOnClass(AWS2S3Component.class)
@ConditionalOnMissingBean
- public S3CredentialProvider s3CredentialProvider(S3BucketCredentialConfig properties) {
- return new S3CredentialProvider(properties);
+ public S3CredentialProvider s3CredentialProvider(S3BucketCredentialConfig properties, EnvironmentReader environmentReader) {
+ return new S3CredentialProvider(properties, environmentReader);
}
}
diff --git a/pom.xml b/pom.xml
index 9d704f5..7feada0 100644
--- a/pom.xml
+++ b/pom.xml
@@ -26,7 +26,7 @@
4.0.0
- de.muenchen.mobidam
+ de.muenchen.oss.mobidam
mobidam-eai-commons
0.0.2-SNAPSHOT
@@ -51,6 +51,7 @@
sfi2022
Landeshauptstadt München
https://github.com/sfi2022
+ mobidam_devs
@@ -58,9 +59,10 @@
${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}
scm:git:${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}.git
scm:git:${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}.git
- head
+ head
+
17
17
@@ -70,6 +72,8 @@
3.3.4
+ 3.0.0-M5
+
false
@@ -277,6 +281,7 @@
org.springframework.boot
spring-boot-maven-plugin
+ ${spring.boot.version}
@@ -286,6 +291,11 @@
+
+ org.apache.maven.plugins
+ maven-surefire-plugin
+ ${maven-surefire-plugin.version}
+