Skip to content

Commit

Permalink
Merge pull request #6 from rnc/NCL8976
Browse files Browse the repository at this point in the history
NCL-8976 Add roles
  • Loading branch information
rnc authored Dec 18, 2024
2 parents d5cdf42 + aeebbb8 commit 26ff0cc
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 2 deletions.
9 changes: 7 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -137,15 +137,20 @@
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.rest-assured</groupId>
<artifactId>rest-assured</artifactId>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-test-security</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-test-kubernetes-client</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.rest-assured</groupId>
<artifactId>rest-assured</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.wiremock</groupId>
<artifactId>wiremock</artifactId>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.jboss.pnc.konfluxbuilddriver.endpoints;

import jakarta.annotation.security.RolesAllowed;
import jakarta.inject.Inject;
import jakarta.ws.rs.Consumes;
import jakarta.ws.rs.PUT;
Expand Down Expand Up @@ -30,6 +31,7 @@ public class Internal {
@PUT
@Path("/completed")
@RunOnVirtualThread
@RolesAllowed({ "pnc-app-konflux-build-driver-user", "pnc-users-admin" })
public void buildExecutionCompleted(PipelineNotification notification) {
logger.info("Build completed, taskId: {}; status: {}.", notification.buildId(), notification.status());
driver.completed(notification);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.jboss.pnc.konfluxbuilddriver.endpoints;

import jakarta.annotation.security.RolesAllowed;
import jakarta.inject.Inject;
import jakarta.ws.rs.Consumes;
import jakarta.ws.rs.GET;
Expand Down Expand Up @@ -39,6 +40,7 @@ public class Public {
@POST
@Path("/build")
@RunOnVirtualThread
@RolesAllowed({ "pnc-app-konflux-build-driver-user", "pnc-users-admin" })
public BuildResponse build(BuildRequest buildRequest) {
logger.info("Requested project build: {}", buildRequest.projectName());
return driver.create(buildRequest);
Expand All @@ -47,6 +49,7 @@ public BuildResponse build(BuildRequest buildRequest) {
@PUT
@Path("/cancel")
@RunOnVirtualThread
@RolesAllowed({ "pnc-app-konflux-build-driver-user", "pnc-users-admin" })
public void cancel(CancelRequest cancelRequest) {
logger.info("Requested cancel: {}", cancelRequest.pipelineId());
driver.cancel(cancelRequest);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import io.quarkus.test.junit.QuarkusTest;
import io.quarkus.test.kubernetes.client.KubernetesTestServer;
import io.quarkus.test.kubernetes.client.WithKubernetesTestServer;
import io.quarkus.test.security.TestSecurity;
import io.restassured.RestAssured;
import io.restassured.http.ContentType;
import io.restassured.response.Response;
Expand All @@ -41,6 +42,7 @@ public void setup() {
}

@Test
@TestSecurity(user = "testUser", roles = { "pnc-users-admin" })
void verify() {
BuildRequest request = BuildRequest.builder().namespace("default").podMemoryOverride("1Gi").build();
Response res = RestAssured.given().contentType(ContentType.JSON)
Expand Down

0 comments on commit 26ff0cc

Please sign in to comment.