Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
cgendreau committed Oct 17, 2024
1 parent 5c4fc04 commit ff1b694
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 14 deletions.
35 changes: 33 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
<asciidoctor-maven-plugin.version>2.0.0</asciidoctor-maven-plugin.version>
<asciidoctorj.diagram.version>2.0.2</asciidoctorj.diagram.version>
<dina-base-api.version>0.128</dina-base-api.version>
<keycloak-admin-client.version>21.1.0</keycloak-admin-client.version>
<keycloak-admin-client.version>22.0.5</keycloak-admin-client.version>

<!-- versions override -->
<spring-framework.version>5.3.38</spring-framework.version>
Expand All @@ -44,7 +44,7 @@

<spring-boot-maven-plugin.fork>false</spring-boot-maven-plugin.fork>

<testcontainers-keycloak.version>2.3.0</testcontainers-keycloak.version>
<testcontainers-keycloak.version>3.1.0</testcontainers-keycloak.version>
<testcontainers.version>1.17.3</testcontainers.version>
</properties>

Expand All @@ -54,6 +54,37 @@
<artifactId>dina-base-api</artifactId>
<version>${dina-base-api.version}</version>
</dependency>
<dependency>
<groupId>jakarta.ws.rs</groupId>
<artifactId>jakarta.ws.rs-api</artifactId>
<version>3.1.0</version>
</dependency>
<dependency>
<groupId>jakarta.xml.bind</groupId>
<artifactId>jakarta.xml.bind-api</artifactId>
<version>3.0.1</version>
</dependency>
<dependency>
<groupId>jakarta.annotation</groupId>
<artifactId>jakarta.annotation-api</artifactId>
<version>3.0.0</version>
</dependency>
<dependency>
<groupId>jakarta.activation</groupId>
<artifactId>jakarta.activation-api</artifactId>
<version>2.1.3</version>
</dependency>
<dependency>
<groupId>jakarta.mail</groupId>
<artifactId>jakarta.mail-api</artifactId>
<version>2.1.3</version>
</dependency>
<dependency>
<groupId>javax.annotation</groupId>
<artifactId>javax.annotation-api</artifactId>
<version>1.3.2</version>
</dependency>

<!-- Spring -->
<dependency>
<groupId>org.springframework.boot</groupId>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package ca.gc.aafc.dinauser.api.service;

import jakarta.ws.rs.NotFoundException;
import jakarta.ws.rs.core.Response;
import java.util.EnumSet;
import java.util.List;
import java.util.Map;
Expand All @@ -25,8 +27,6 @@
import ca.gc.aafc.dinauser.api.dto.DinaGroupMembershipDto;
import ca.gc.aafc.dinauser.api.dto.DinaUserSummaryDto;

import javax.ws.rs.NotFoundException;
import javax.ws.rs.core.Response;
import lombok.extern.log4j.Log4j2;

import static org.keycloak.admin.client.CreatedResponseUtil.getCreatedId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
import ca.gc.aafc.dinauser.api.dto.DinaUserDto;
import io.crnk.core.engine.document.ErrorData;
import io.crnk.core.exception.CrnkMappableException;
import jakarta.ws.rs.NotFoundException;
import jakarta.ws.rs.core.Response;
import lombok.NonNull;
import lombok.extern.log4j.Log4j2;
import org.keycloak.admin.client.Keycloak;
Expand All @@ -25,9 +27,7 @@
import javax.persistence.criteria.Predicate;
import javax.persistence.criteria.Root;
import javax.validation.groups.Default;
import javax.ws.rs.NotFoundException;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.Response.Status.Family;

import java.util.Arrays;
import java.util.Collection;
import java.util.HashSet;
Expand Down Expand Up @@ -337,7 +337,7 @@ public DinaUserDto createUser(final DinaUserDto user) {

log.debug("response status: {}", response.getStatus());

if (response.getStatusInfo().getFamily() == Family.SUCCESSFUL) {
if (response.getStatusInfo().getFamily() == Response.Status.Family.SUCCESSFUL) {
final String newUserUrl = response.getHeaderString(LOCATION_HTTP_HEADER_KEY);
final Matcher m = UUID_REGEX.matcher(newUserUrl);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Service;

import javax.ws.rs.client.ClientBuilder;
import jakarta.ws.rs.client.ClientBuilder;
import jakarta.ws.rs.client.ClientRequestContext;
import jakarta.ws.rs.client.ClientRequestFilter;
import lombok.extern.log4j.Log4j2;

import javax.ws.rs.client.ClientRequestContext;
import javax.ws.rs.client.ClientRequestFilter;
import java.io.IOException;

@Service
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,17 @@
import dasniko.testcontainers.keycloak.KeycloakContainer;

public class DinaKeycloakTestContainer extends KeycloakContainer {
private static final String IMAGE_VERSION = UserModuleTestConfiguration.KEYCLOAK_DOCKER_IMAGE;

private static final String REALM_FILE_NAME = "keycloak-dina-starter-realm.json";
private static final String ADMIN_USER_NAME = "admin";
private static final String ADMIN_PASS_WORD = "admin";
private static DinaKeycloakTestContainer container;

private DinaKeycloakTestContainer() {
super(IMAGE_VERSION);
}

private DinaKeycloakTestContainer(String imageName) {
super(imageName);
}

public static DinaKeycloakTestContainer getInstance() {
Expand All @@ -19,6 +22,13 @@ public static DinaKeycloakTestContainer getInstance() {
}
return container;
}

public static DinaKeycloakTestContainer getInstance(String imageTag) {
if (container == null) {
container = new DinaKeycloakTestContainer();
}
return container;
}

@Override
public void start() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@
import org.springframework.test.context.TestPropertySource;
import org.testcontainers.junit.jupiter.Container;

import jakarta.ws.rs.NotFoundException;
import javax.inject.Inject;
import javax.ws.rs.NotFoundException;
import java.util.List;
import java.util.Map;
import java.util.Optional;
Expand Down

0 comments on commit ff1b694

Please sign in to comment.