test: generate the JWT test keys, drop application-dev.yml
Build, Test & Push Auth Service / quality-check (push) Successful in 28s
Build, Test & Push Auth Service / docker (push) Successful in 1m20s

The dev config held real keys. Local dev config now lives outside the repo; integration tests create a fresh Ed25519 keypair per run.
This commit is contained in:
lobo committed 2026-09-25 08:37:55 +02:00
1 parent 9df7389fab
commit c63b7e6aaa
2 files changed
+29

No files matched your search

@@ -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);
}
}
}