diff --git a/.gitignore b/.gitignore index ecb0601..133dac7 100644 --- a/.gitignore +++ b/.gitignore @@ -35,3 +35,7 @@ build/ ### Local secrets and generated files ### .env effective-pom + +### Local dev config, never committed ### +application-dev.yml +application-dev.yaml diff --git a/src/test/java/auth_service/shared/test/AbstractIntegrationTest.java b/src/test/java/auth_service/shared/test/AbstractIntegrationTest.java index 4740a25..dcf78cb 100644 --- a/src/test/java/auth_service/shared/test/AbstractIntegrationTest.java +++ b/src/test/java/auth_service/shared/test/AbstractIntegrationTest.java @@ -4,8 +4,15 @@ import org.junit.jupiter.api.Tag; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.ActiveProfiles; import org.springframework.boot.testcontainers.service.connection.ServiceConnection; +import org.springframework.test.context.DynamicPropertyRegistry; +import org.springframework.test.context.DynamicPropertySource; import org.testcontainers.containers.PostgreSQLContainer; +import java.security.KeyPair; +import java.security.KeyPairGenerator; +import java.security.NoSuchAlgorithmException; +import java.util.Base64; + /** * Base class for integration tests. * Full Spring context with Testcontainers. @@ -23,5 +30,23 @@ public abstract class AbstractIntegrationTest { static { postgres.start(); } + + // No key is committed: a fresh one per JVM. + private static final KeyPair KEYS = generateKeys(); + + @DynamicPropertySource + static void secrets(DynamicPropertyRegistry registry) { + registry.add("security.jwt.private-key", () -> Base64.getEncoder().encodeToString(KEYS.getPrivate().getEncoded())); + registry.add("security.jwt.public-key", () -> Base64.getEncoder().encodeToString(KEYS.getPublic().getEncoded())); + registry.add("auth.registration.invitation-code", () -> "test-invite-code"); + } + + private static KeyPair generateKeys() { + try { + return KeyPairGenerator.getInstance("Ed25519").generateKeyPair(); + } catch (NoSuchAlgorithmException e) { + throw new IllegalStateException(e); + } + } }