diff --git a/e2e/src/main/java/org/dependencytrack/apiserver/ApiServerClient.java b/e2e/src/main/java/org/dependencytrack/apiserver/ApiServerClient.java index b07d88260..96c46d369 100644 --- a/e2e/src/main/java/org/dependencytrack/apiserver/ApiServerClient.java +++ b/e2e/src/main/java/org/dependencytrack/apiserver/ApiServerClient.java @@ -29,6 +29,7 @@ import jakarta.ws.rs.QueryParam; import jakarta.ws.rs.core.MediaType; import org.dependencytrack.apiserver.model.Analysis; +import org.dependencytrack.apiserver.model.ApiKey; import org.dependencytrack.apiserver.model.BomProcessingResponse; import org.dependencytrack.apiserver.model.BomUploadRequest; import org.dependencytrack.apiserver.model.ConfigProperty; @@ -74,6 +75,12 @@ String login(@FormParam("username") final String username, @Consumes(MediaType.APPLICATION_JSON) Team createTeam(final CreateTeamRequest request); + @PUT + @Path("/team/{uuid}/key") + @Produces(MediaType.APPLICATION_JSON) + @Consumes(MediaType.WILDCARD) + ApiKey createApiKey(@PathParam("uuid") final UUID teamUuid); + @POST @Path("/permission/{permission}/team/{uuid}") @Produces(MediaType.WILDCARD) diff --git a/e2e/src/test/java/org/dependencytrack/e2e/AbstractE2ET.java b/e2e/src/test/java/org/dependencytrack/e2e/AbstractE2ET.java index db970507f..216fd6793 100644 --- a/e2e/src/test/java/org/dependencytrack/e2e/AbstractE2ET.java +++ b/e2e/src/test/java/org/dependencytrack/e2e/AbstractE2ET.java @@ -24,6 +24,7 @@ import org.dependencytrack.apiserver.ApiServerClient; import org.dependencytrack.apiserver.CompositeDecoder; import org.dependencytrack.apiserver.CompositeEncoder; +import org.dependencytrack.apiserver.model.ApiKey; import org.dependencytrack.apiserver.model.CreateTeamRequest; import org.dependencytrack.apiserver.model.Team; import org.junit.jupiter.api.AfterEach; @@ -286,6 +287,9 @@ private ApiServerClient initializeApiServerClient() { logger.info("Creating e2e team"); final Team team = client.createTeam(new CreateTeamRequest("e2e")); + logger.info("Creating API key for e2e team"); + final ApiKey apiKey = client.createApiKey(team.uuid()); + // TODO: Should assigned permissions be configurable per test case? logger.info("Assigning permissions to e2e team"); for (final String permission : Set.of( @@ -302,7 +306,7 @@ private ApiServerClient initializeApiServerClient() { } logger.info("Authenticating as e2e team"); - ApiServerAuthInterceptor.setApiKey(team.apiKeys().getFirst().key()); + ApiServerAuthInterceptor.setApiKey(apiKey.key()); return client; }