Writing Component/Integration Tests. Using Quarkus 2.0 with rest-assured, quarkus-junit5-mockito and quarkus-test-security-oidc
I want to test a Resource Method with a precondtion (create) because i want to test GET.
The problem is the calls work fine seperately, or don't end up in an error.
With both calls ending up with: Expected status code <200> but was <403>.
Injected the Resource, but it is a pain to deal with the cdi, espacially when the test annotations would take care about this.
Any ideas?
import static io.restassured.RestAssured.given;
...
@QuarkusTest
@TestHTTPEndpoint(MyResource.class)
class MyResourceTest {
private static final String AUTHTOKEN = "Foo Bar.eyJmb28iOiJiYXIifQ==";
@Test
@TestSecurity(user = "user",
roles = "user",
attributes = { @SecurityAttribute(key = "username",
value = "testuser") })
void testGetProducts() {
final UUID id = given().header(AUTHORIZATION, AUTHTOKEN).when().post("/something").then().statusCode(200).extract().as(UUID.class);
given().header(AUTHORIZATION, AUTHTOKEN).when().get("/something/all").then().statusCode(200);
//...
}