feat: remove bootstrap_token from EnvironmentEntity — API keys managed separately

Remove bootstrapToken field/getter/setter from EnvironmentEntity and drop
the RuntimeConfig dependency from EnvironmentService. DeploymentService and
AgentStatusService now use a TODO-api-key placeholder until the ApiKeyService
wiring is complete. All test references to setBootstrapToken removed.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
hsiegeln
2026-04-05 12:42:47 +02:00
parent ec1ec2e65f
commit 5326102443
9 changed files with 4 additions and 26 deletions

View File

@@ -54,7 +54,6 @@ public class BootstrapDataSeeder implements ApplicationRunner {
String orgId = getField(config, "organizationId"); String orgId = getField(config, "organizationId");
String tenantName = getField(config, "tenantName"); String tenantName = getField(config, "tenantName");
String tenantSlug = getField(config, "tenantSlug"); String tenantSlug = getField(config, "tenantSlug");
String bootstrapToken = getField(config, "bootstrapToken");
if (orgId == null || tenantSlug == null) { if (orgId == null || tenantSlug == null) {
log.info("Bootstrap file missing organizationId or tenantSlug — skipping"); log.info("Bootstrap file missing organizationId or tenantSlug — skipping");
@@ -84,7 +83,6 @@ public class BootstrapDataSeeder implements ApplicationRunner {
env.setTenantId(tenant.getId()); env.setTenantId(tenant.getId());
env.setSlug("default"); env.setSlug("default");
env.setDisplayName("Default"); env.setDisplayName("Default");
env.setBootstrapToken(bootstrapToken != null ? bootstrapToken : "default-bootstrap-token");
env.setStatus(EnvironmentStatus.ACTIVE); env.setStatus(EnvironmentStatus.ACTIVE);
environmentRepository.save(env); environmentRepository.save(env);
log.info("Created default environment for tenant '{}'", tenantSlug); log.info("Created default environment for tenant '{}'", tenantSlug);

View File

@@ -142,7 +142,7 @@ public class DeploymentService {
containerName, containerName,
runtimeConfig.getDockerNetwork(), runtimeConfig.getDockerNetwork(),
Map.of( Map.of(
"CAMELEER_AUTH_TOKEN", env.getBootstrapToken(), "CAMELEER_AUTH_TOKEN", "TODO-api-key",
"CAMELEER_EXPORT_TYPE", "HTTP", "CAMELEER_EXPORT_TYPE", "HTTP",
"CAMELEER_EXPORT_ENDPOINT", runtimeConfig.getCameleer3ServerEndpoint(), "CAMELEER_EXPORT_ENDPOINT", runtimeConfig.getCameleer3ServerEndpoint(),
"CAMELEER_APPLICATION_ID", app.getSlug(), "CAMELEER_APPLICATION_ID", app.getSlug(),

View File

@@ -21,9 +21,6 @@ public class EnvironmentEntity {
@Column(name = "display_name", nullable = false) @Column(name = "display_name", nullable = false)
private String displayName; private String displayName;
@Column(name = "bootstrap_token", nullable = false, columnDefinition = "TEXT")
private String bootstrapToken;
@Enumerated(EnumType.STRING) @Enumerated(EnumType.STRING)
@Column(nullable = false, length = 20) @Column(nullable = false, length = 20)
private EnvironmentStatus status = EnvironmentStatus.ACTIVE; private EnvironmentStatus status = EnvironmentStatus.ACTIVE;
@@ -53,8 +50,6 @@ public class EnvironmentEntity {
public void setSlug(String slug) { this.slug = slug; } public void setSlug(String slug) { this.slug = slug; }
public String getDisplayName() { return displayName; } public String getDisplayName() { return displayName; }
public void setDisplayName(String displayName) { this.displayName = displayName; } public void setDisplayName(String displayName) { this.displayName = displayName; }
public String getBootstrapToken() { return bootstrapToken; }
public void setBootstrapToken(String bootstrapToken) { this.bootstrapToken = bootstrapToken; }
public EnvironmentStatus getStatus() { return status; } public EnvironmentStatus getStatus() { return status; }
public void setStatus(EnvironmentStatus status) { this.status = status; } public void setStatus(EnvironmentStatus status) { this.status = status; }
public Instant getCreatedAt() { return createdAt; } public Instant getCreatedAt() { return createdAt; }

View File

@@ -4,7 +4,6 @@ import net.siegeln.cameleer.saas.audit.AuditAction;
import net.siegeln.cameleer.saas.audit.AuditService; import net.siegeln.cameleer.saas.audit.AuditService;
import net.siegeln.cameleer.saas.license.LicenseDefaults; import net.siegeln.cameleer.saas.license.LicenseDefaults;
import net.siegeln.cameleer.saas.license.LicenseRepository; import net.siegeln.cameleer.saas.license.LicenseRepository;
import net.siegeln.cameleer.saas.runtime.RuntimeConfig;
import net.siegeln.cameleer.saas.tenant.Tier; import net.siegeln.cameleer.saas.tenant.Tier;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@@ -18,16 +17,13 @@ public class EnvironmentService {
private final EnvironmentRepository environmentRepository; private final EnvironmentRepository environmentRepository;
private final LicenseRepository licenseRepository; private final LicenseRepository licenseRepository;
private final AuditService auditService; private final AuditService auditService;
private final RuntimeConfig runtimeConfig;
public EnvironmentService(EnvironmentRepository environmentRepository, public EnvironmentService(EnvironmentRepository environmentRepository,
LicenseRepository licenseRepository, LicenseRepository licenseRepository,
AuditService auditService, AuditService auditService) {
RuntimeConfig runtimeConfig) {
this.environmentRepository = environmentRepository; this.environmentRepository = environmentRepository;
this.licenseRepository = licenseRepository; this.licenseRepository = licenseRepository;
this.auditService = auditService; this.auditService = auditService;
this.runtimeConfig = runtimeConfig;
} }
public EnvironmentEntity create(UUID tenantId, String slug, String displayName, UUID actorId) { public EnvironmentEntity create(UUID tenantId, String slug, String displayName, UUID actorId) {
@@ -41,7 +37,6 @@ public class EnvironmentService {
entity.setTenantId(tenantId); entity.setTenantId(tenantId);
entity.setSlug(slug); entity.setSlug(slug);
entity.setDisplayName(displayName); entity.setDisplayName(displayName);
entity.setBootstrapToken(runtimeConfig.getBootstrapToken());
var saved = environmentRepository.save(entity); var saved = environmentRepository.save(entity);

View File

@@ -55,7 +55,7 @@ public class AgentStatusService {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
List<Map<String, Object>> agents = restClient.get() List<Map<String, Object>> agents = restClient.get()
.uri("/api/v1/agents") .uri("/api/v1/agents")
.header("Authorization", "Bearer " + runtimeConfig.getBootstrapToken()) .header("Authorization", "Bearer " + "TODO-api-key")
.retrieve() .retrieve()
.body(List.class); .body(List.class);

View File

@@ -83,7 +83,6 @@ class AppControllerTest {
env.setTenantId(tenantId); env.setTenantId(tenantId);
env.setSlug("default"); env.setSlug("default");
env.setDisplayName("Default"); env.setDisplayName("Default");
env.setBootstrapToken("test-bootstrap-token");
var savedEnv = environmentRepository.save(env); var savedEnv = environmentRepository.save(env);
environmentId = savedEnv.getId(); environmentId = savedEnv.getId();
} }

View File

@@ -84,7 +84,6 @@ class DeploymentControllerTest {
env.setTenantId(tenantId); env.setTenantId(tenantId);
env.setSlug("default"); env.setSlug("default");
env.setDisplayName("Default"); env.setDisplayName("Default");
env.setBootstrapToken("test-bootstrap-token");
var savedEnv = environmentRepository.save(env); var savedEnv = environmentRepository.save(env);
var app = new AppEntity(); var app = new AppEntity();

View File

@@ -92,7 +92,6 @@ class DeploymentServiceTest {
env.setId(envId); env.setId(envId);
env.setTenantId(tenantId); env.setTenantId(tenantId);
env.setSlug("prod"); env.setSlug("prod");
env.setBootstrapToken("tok-abc");
tenant = new TenantEntity(); tenant = new TenantEntity();
tenant.setSlug("acme"); tenant.setSlug("acme");

View File

@@ -4,7 +4,6 @@ import net.siegeln.cameleer.saas.audit.AuditAction;
import net.siegeln.cameleer.saas.audit.AuditService; import net.siegeln.cameleer.saas.audit.AuditService;
import net.siegeln.cameleer.saas.license.LicenseEntity; import net.siegeln.cameleer.saas.license.LicenseEntity;
import net.siegeln.cameleer.saas.license.LicenseRepository; import net.siegeln.cameleer.saas.license.LicenseRepository;
import net.siegeln.cameleer.saas.runtime.RuntimeConfig;
import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith; import org.junit.jupiter.api.extension.ExtendWith;
@@ -34,14 +33,11 @@ class EnvironmentServiceTest {
@Mock @Mock
private AuditService auditService; private AuditService auditService;
@Mock
private RuntimeConfig runtimeConfig;
private EnvironmentService environmentService; private EnvironmentService environmentService;
@BeforeEach @BeforeEach
void setUp() { void setUp() {
environmentService = new EnvironmentService(environmentRepository, licenseRepository, auditService, runtimeConfig); environmentService = new EnvironmentService(environmentRepository, licenseRepository, auditService);
} }
@Test @Test
@@ -56,7 +52,6 @@ class EnvironmentServiceTest {
when(licenseRepository.findFirstByTenantIdAndRevokedAtIsNullOrderByCreatedAtDesc(tenantId)) when(licenseRepository.findFirstByTenantIdAndRevokedAtIsNullOrderByCreatedAtDesc(tenantId))
.thenReturn(Optional.of(license)); .thenReturn(Optional.of(license));
when(environmentRepository.countByTenantId(tenantId)).thenReturn(0L); when(environmentRepository.countByTenantId(tenantId)).thenReturn(0L);
when(runtimeConfig.getBootstrapToken()).thenReturn("test-token");
when(environmentRepository.save(any(EnvironmentEntity.class))).thenAnswer(inv -> inv.getArgument(0)); when(environmentRepository.save(any(EnvironmentEntity.class))).thenAnswer(inv -> inv.getArgument(0));
var result = environmentService.create(tenantId, "prod", "Production", actorId); var result = environmentService.create(tenantId, "prod", "Production", actorId);
@@ -64,7 +59,6 @@ class EnvironmentServiceTest {
assertThat(result.getSlug()).isEqualTo("prod"); assertThat(result.getSlug()).isEqualTo("prod");
assertThat(result.getDisplayName()).isEqualTo("Production"); assertThat(result.getDisplayName()).isEqualTo("Production");
assertThat(result.getTenantId()).isEqualTo(tenantId); assertThat(result.getTenantId()).isEqualTo(tenantId);
assertThat(result.getBootstrapToken()).isEqualTo("test-token");
var actionCaptor = ArgumentCaptor.forClass(AuditAction.class); var actionCaptor = ArgumentCaptor.forClass(AuditAction.class);
verify(auditService).log(any(), any(), any(), actionCaptor.capture(), any(), any(), any(), any(), any()); verify(auditService).log(any(), any(), any(), actionCaptor.capture(), any(), any(), any(), any(), any());
@@ -175,7 +169,6 @@ class EnvironmentServiceTest {
when(licenseRepository.findFirstByTenantIdAndRevokedAtIsNullOrderByCreatedAtDesc(tenantId)) when(licenseRepository.findFirstByTenantIdAndRevokedAtIsNullOrderByCreatedAtDesc(tenantId))
.thenReturn(Optional.of(license)); .thenReturn(Optional.of(license));
when(environmentRepository.countByTenantId(tenantId)).thenReturn(0L); when(environmentRepository.countByTenantId(tenantId)).thenReturn(0L);
when(runtimeConfig.getBootstrapToken()).thenReturn("test-token");
when(environmentRepository.save(any(EnvironmentEntity.class))).thenAnswer(inv -> inv.getArgument(0)); when(environmentRepository.save(any(EnvironmentEntity.class))).thenAnswer(inv -> inv.getArgument(0));
var result = environmentService.createDefaultForTenant(tenantId); var result = environmentService.createDefaultForTenant(tenantId);