Skip to content

Commit

Permalink
tests: update bearer token test
Browse files Browse the repository at this point in the history
  • Loading branch information
andrejpetras committed Feb 13, 2024
1 parent cfa2c98 commit 858a6fc
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import java.util.List;

import io.quarkus.oidc.common.runtime.OidcConstants;
import jakarta.enterprise.context.ApplicationScoped;
import jakarta.inject.Inject;

Expand All @@ -11,6 +10,7 @@
import org.tkit.quarkus.rs.context.token.TokenParserRequest;
import org.tkit.quarkus.rs.context.token.TokenParserService;

import io.quarkus.oidc.common.runtime.OidcConstants;
import lombok.extern.slf4j.Slf4j;

@Slf4j
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,9 @@
import static org.assertj.core.api.Assertions.assertThat;
import static org.jboss.resteasy.reactive.RestResponse.Status.*;

import java.net.URI;
import java.util.List;
import java.util.stream.Stream;

import org.eclipse.microprofile.config.ConfigProvider;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
Expand All @@ -31,6 +29,7 @@ class PermissionRestControllerTest extends AbstractTest {
@Test
void getApplicationPermissionsTest() {

// bearer prefix
var accessToken = createTokenBearer(List.of("n3"));

var dto = given()
Expand All @@ -46,6 +45,22 @@ void getApplicationPermissionsTest() {
assertThat(dto.getPermissions()).isNotNull().hasSize(1);
assertThat(dto.getPermissions().get("o1")).isNotNull().hasSize(1).containsExactly("a3");

// without bearer prefix
accessToken = createToken(null, List.of("n3"));

dto = given()
.contentType(APPLICATION_JSON)
.body(new PermissionRequestDTOV1().token(accessToken))
.post("app1")
.then()
.statusCode(OK.getStatusCode())
.extract()
.body().as(ApplicationPermissionsDTOV1.class);

assertThat(dto).isNotNull();
assertThat(dto.getPermissions()).isNotNull().hasSize(1);
assertThat(dto.getPermissions().get("o1")).isNotNull().hasSize(1).containsExactly("a3");

}

private static Stream<Arguments> badRequestData() {
Expand Down

0 comments on commit 858a6fc

Please sign in to comment.