Skip to content

Commit

Permalink
Introduce new micrometer and security integration test module
Browse files Browse the repository at this point in the history
  • Loading branch information
geoand committed Apr 29, 2024
1 parent 8694c5c commit dcbcdbd
Show file tree
Hide file tree
Showing 5 changed files with 162 additions and 0 deletions.
107 changes: 107 additions & 0 deletions integration-tests/micrometer-security/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-integration-tests-parent</artifactId>
<version>999-SNAPSHOT</version>
</parent>

<artifactId>quarkus-integration-test-micrometer-security</artifactId>
<name>Quarkus - Integration Tests - Micrometer Security</name>

<dependencies>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-micrometer-registry-prometheus</artifactId>
</dependency>

<!-- JAX-RS -->
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-rest-jackson</artifactId>
</dependency>

<!-- Security -->
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-security</artifactId>
</dependency>

<!-- Test Dependencies -->
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-junit5</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.rest-assured</groupId>
<artifactId>rest-assured</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-micrometer-registry-prometheus-deployment</artifactId>
<version>${project.version}</version>
<type>pom</type>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>*</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-rest-jackson-deployment</artifactId>
<version>${project.version}</version>
<type>pom</type>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>*</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-security-deployment</artifactId>
<version>${project.version}</version>
<type>pom</type>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>*</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.awaitility</groupId>
<artifactId>awaitility</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>build</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package io.quarkus.it.micrometer.security;

import jakarta.ws.rs.GET;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.PathParam;
import jakarta.ws.rs.Produces;
import jakarta.ws.rs.core.MediaType;

import io.smallrye.mutiny.Uni;

@Path("/secured")
public class SecuredResource {

@GET
@Path("/{message}")
@Produces(MediaType.TEXT_PLAIN)
public Uni<String> message(@PathParam("message") String message) {
return Uni.createFrom().item(message);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
quarkus.http.auth.permission.default.paths=/secured/*
quarkus.http.auth.permission.default.policy=authenticated
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package io.quarkus.it.micrometer.security;

import static io.restassured.RestAssured.when;
import static org.hamcrest.CoreMatchers.containsString;
import static org.hamcrest.Matchers.allOf;
import static org.hamcrest.Matchers.not;

import org.junit.jupiter.api.Test;

import io.quarkus.test.junit.QuarkusTest;

@QuarkusTest
class SecuredResourceTest {

@Test
void testMetricsForUnauthorizedRequest() {
when().get("/secured/foo")
.then()
.statusCode(403);

when().get("/q/metrics")
.then()
.statusCode(200)
.body(
allOf(
not(containsString("/secured/foo")),
containsString("/secured/{message}"))

);
}

}
1 change: 1 addition & 0 deletions integration-tests/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,7 @@
<module>elasticsearch-java-client</module>
<module>micrometer-mp-metrics</module>
<module>micrometer-prometheus</module>
<module>micrometer-security</module>
<module>opentelemetry</module>
<module>opentelemetry-quickstart</module>
<module>opentelemetry-spi</module>
Expand Down

0 comments on commit dcbcdbd

Please sign in to comment.