Coding the test class

Our test class is composed of two blocks. In the first block, we retrieve a token for the test user and the admin user. Then, we use both tokens to test the application. More specifically, the test token, which belongs to the user role, will be used for GET requests. On the other hand, the admin token will be used to authorize POST, PUT, and DELETE requests.

Here is the first block of the test class:

@ConfigProperty(name = "keycloak.url")String keycloakURL;    @Test    public void testHelloEndpoint() {        RestAssured.baseURI = keycloakURL;        Response response = given().urlEncodingEnabled(true)                .auth().preemptive().basic("quarkus-client",                   "mysecret")                .param("grant_type", "password")                .param("client_id", "quarkus-client") .param("username", ...

Get Hands-On Cloud-Native Applications with Java and Quarkus now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.