Skip to content

Commit

Permalink
build: #16 add integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
brunopacheco1 committed Mar 6, 2024
1 parent 001da2f commit 29fa9ba
Show file tree
Hide file tree
Showing 32 changed files with 2,268 additions and 85 deletions.
15 changes: 11 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,13 @@ Ensure you have [Maven](https://maven.apache.org/) and [GraalVM](https://www.gra
sdk install java 21.0.2-graal
sdk install maven 3.9.6
echo -e "\nexport GRAALVM_HOME="$HOME/.sdkman/candidates/java/21.0.2-graal/" >> $HOME/.zprofile
echo -e "\nryuk.container.privileged=true" >> $HOME/.testcontainers.properties
```
## Running the application in dev mode
You can run your application in dev mode that enables live coding using:
```shell script
cp .env.example .env
docker compose build
docker compose run --rm -e CMD="migrate;test-data" rems
docker compose up -d
mvn compile quarkus:dev
```
Expand Down Expand Up @@ -81,6 +78,16 @@ If you want to learn more about building native executables, please consult http
All tests are automatically executed when you build a new package.
## Running locally all the components
Execute the commands below, if you want to test all the components, their integration and the native build.
```shell script
docker compose build
docker compose run --rm -e CMD="migrate;test-data" rems
docker compose up -d
```
## License
- All original source code is licensed under [Apache-2.0](./LICENSES/Apache-2.0.txt).
Expand Down
2 changes: 1 addition & 1 deletion _http/rems/01_create_application.http
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ POST http://localhost:3000/api/applications/create
Accept: application/json
Content-Type: application/json
x-rems-api-key: 42
x-rems-user-id: 52cacbab-c440-4385-9d5f-46aa4930b0e4
x-rems-user-id: eb4123a3-b722-4798-9af5-8957f823657a

{
"catalogue-item-ids": [9]
Expand Down
2 changes: 1 addition & 1 deletion _http/rems/02_retrieve_application.http
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
GET http://rems:3000/api/applications/25
Accept: application/json
x-rems-api-key: 42
x-rems-user-id: 52cacbab-c440-4385-9d5f-46aa4930b0e4
x-rems-user-id: eb4123a3-b722-4798-9af5-8957f823657a
2 changes: 1 addition & 1 deletion _http/rems/03_accept_terms.http
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ POST http://rems:3000/api/applications/accept-licenses
Accept: application/json
Content-Type: application/json
x-rems-api-key: 42
x-rems-user-id: 52cacbab-c440-4385-9d5f-46aa4930b0e4
x-rems-user-id: eb4123a3-b722-4798-9af5-8957f823657a

{
"application-id": 28
Expand Down
2 changes: 1 addition & 1 deletion _http/rems/04_add_member.http
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ POST http://rems:3000/api/applications/invite-member
Accept: application/json
Content-Type: application/json
x-rems-api-key: 42
x-rems-user-id: 52cacbab-c440-4385-9d5f-46aa4930b0e4
x-rems-user-id: eb4123a3-b722-4798-9af5-8957f823657a

{
"application-id": 28
Expand Down
2 changes: 1 addition & 1 deletion _http/rems/05_remove_member.http
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ POST http://rems:3000/api/applications/uninvite-member
Accept: application/json
Content-Type: application/json
x-rems-api-key: 42
x-rems-user-id: 52cacbab-c440-4385-9d5f-46aa4930b0e4
x-rems-user-id: eb4123a3-b722-4798-9af5-8957f823657a

{
"application-id": 28
Expand Down
2 changes: 1 addition & 1 deletion _http/rems/06_attach_file.http
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ POST http://rems:3000/api/applications/add-attachment?application-id=28
Accept: application/json
Content-Type: multipart/form-data; boundary=MfnBoundry
x-rems-api-key: 42
x-rems-user-id: 52cacbab-c440-4385-9d5f-46aa4930b0e4
x-rems-user-id: eb4123a3-b722-4798-9af5-8957f823657a

--MfnBoundry
Content-Disposition: form-data; name="file"; filename="06_dummy_attachment.txt"
Expand Down
2 changes: 1 addition & 1 deletion _http/rems/07_remove_attachment.http
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ POST http://rems:3000/api/applications/save-draft
Accept: application/json
Content-Type: application/json
x-rems-api-key: 42
x-rems-user-id: 52cacbab-c440-4385-9d5f-46aa4930b0e4
x-rems-user-id: eb4123a3-b722-4798-9af5-8957f823657a

{
"application-id": 28
Expand Down
2 changes: 1 addition & 1 deletion _http/rems/08_update_duos.http
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ POST http://rems:3000/api/applications/save-draft
Accept: application/json
Content-Type: application/json
x-rems-api-key: 42
x-rems-user-id: 52cacbab-c440-4385-9d5f-46aa4930b0e4
x-rems-user-id: eb4123a3-b722-4798-9af5-8957f823657a

{
"application-id": 28
Expand Down
2 changes: 1 addition & 1 deletion _http/rems/09_save_forms.http
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ POST http://rems:3000/api/applications/save-draft
Accept: application/json
Content-Type: application/json
x-rems-api-key: 42
x-rems-user-id: 52cacbab-c440-4385-9d5f-46aa4930b0e4
x-rems-user-id: eb4123a3-b722-4798-9af5-8957f823657a

{
"application-id": 28
Expand Down
2 changes: 1 addition & 1 deletion _http/rems/10_submit_application.http
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ POST http://rems:3000/api/applications/submit
Accept: application/json
Content-Type: application/json
x-rems-api-key: 42
x-rems-user-id: 52cacbab-c440-4385-9d5f-46aa4930b0e4
x-rems-user-id: eb4123a3-b722-4798-9af5-8957f823657a

{
"application-id" : 25
Expand Down
2 changes: 1 addition & 1 deletion _http/rems/11_copy_as_new_application.http
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ POST http://localhost:3000/api/applications/copy-as-new
Accept: application/json
Content-Type: application/json
x-rems-api-key: 42
x-rems-user-id: 52cacbab-c440-4385-9d5f-46aa4930b0e4
x-rems-user-id: eb4123a3-b722-4798-9af5-8957f823657a

{
"application-id" : 25
Expand Down
2 changes: 1 addition & 1 deletion _http/rems/12_my_applications.http
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
GET http://rems:3000/api/my-applications
Accept: application/json
x-rems-api-key: 42
x-rems-user-id: 52cacbab-c440-4385-9d5f-46aa4930b0e4
x-rems-user-id: eb4123a3-b722-4798-9af5-8957f823657a
2 changes: 1 addition & 1 deletion _http/rems/13_create_user.http
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ x-rems-api-key: 42
x-rems-user-id: owner

{
"userid": "52cacbab-c440-4385-9d5f-46aa4930b0e4",
"userid": "eb4123a3-b722-4798-9af5-8957f823657a",
"name": "CKAN Admin",
"email": "[email protected]"
}
Expand Down
2 changes: 1 addition & 1 deletion keycloak/realms/ckan-realm.json
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@
"webAuthnPolicyPasswordlessAcceptableAaguids" : [ ],
"webAuthnPolicyPasswordlessExtraOrigins" : [ ],
"users" : [ {
"id" : "52cacbab-c440-4385-9d5f-46aa4930b0e4",
"id" : "eb4123a3-b722-4798-9af5-8957f823657a",
"createdTimestamp" : 1703107576892,
"username" : "ckan_admin",
"enabled" : true,
Expand Down
43 changes: 33 additions & 10 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<groupId>lu.lnds.daam</groupId>
<groupId>io.github.genomicdatainfrastructure</groupId>
<artifactId>gdi-userportal-access-management-service</artifactId>
<version>0.0.0</version>
<name>gdi-userportal-access-management-service</name>
Expand All @@ -22,6 +22,8 @@
<quarkus.platform.version>3.8.1</quarkus.platform.version>
<skipITs>true</skipITs>
<surefire-plugin.version>3.2.5</surefire-plugin.version>
<surefire.version>3.0.0-M7</surefire.version>
<quarkus-wiremock.version>1.3.0</quarkus-wiremock.version>
</properties>
<dependencyManagement>
<dependencies>
Expand Down Expand Up @@ -69,14 +71,6 @@
<groupId>io.quarkus</groupId>
<artifactId>quarkus-rest-client-reactive-jackson</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-oidc-client-reactive-filter</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-security</artifactId>
</dependency>
<dependency>
<groupId>io.quarkiverse.openapi.generator</groupId>
<artifactId>quarkus-openapi-generator</artifactId>
Expand Down Expand Up @@ -105,10 +99,38 @@
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-junit5-mockito</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-test-keycloak-server</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.quarkiverse.wiremock</groupId>
<artifactId>quarkus-wiremock</artifactId>
<version>${quarkus-wiremock.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>io.quarkiverse.wiremock</groupId>
<artifactId>quarkus-wiremock-test</artifactId>
<version>${quarkus-wiremock.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>${surefire.version}</version>
<configuration>
<systemPropertyVariables>
<java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager>
<maven.home>${maven.home}</maven.home>
</systemPropertyVariables>
</configuration>
</plugin>
<plugin>
<groupId>${quarkus.platform.group-id}</groupId>
<artifactId>quarkus-maven-plugin</artifactId>
Expand Down Expand Up @@ -156,7 +178,8 @@
</executions>
<configuration>
<systemPropertyVariables>
<native.image.path>${project.build.directory}/${project.build.finalName}-runner</native.image.path>
<native.image.path>${project.build.directory}/${project.build.finalName}-runner
</native.image.path>
<java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager>
<maven.home>${maven.home}</maven.home>
</systemPropertyVariables>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,18 @@
// SPDX-FileCopyrightText: 2024 PNED G.I.E.
//
// SPDX-License-Identifier: Apache-2.0
package lu.lnds.daam.api;

import static lu.lnds.daam.security.PostAuthenticationFilter.USER_ID_CLAIM;
package io.github.genomicdatainfrastructure.daam.api;

import io.github.genomicdatainfrastructure.daam.model.ListedApplication;
import io.github.genomicdatainfrastructure.daam.model.RetrievedApplication;
import io.github.genomicdatainfrastructure.daam.security.PostAuthenticationFilter;
import io.github.genomicdatainfrastructure.daam.services.ListApplicationsService;
import io.quarkus.oidc.runtime.OidcJwtCallerPrincipal;
import io.quarkus.security.Authenticated;
import io.quarkus.security.identity.SecurityIdentity;
import java.io.File;
import java.util.List;
import lombok.RequiredArgsConstructor;
import lu.lnds.daam.model.ListedApplication;
import lu.lnds.daam.model.RetrievedApplication;
import lu.lnds.daam.services.ListApplicationsService;

@Authenticated
@RequiredArgsConstructor
public class ApplicationQueryApiImpl implements ApplicationQueryApi {

Expand All @@ -25,7 +22,8 @@ public class ApplicationQueryApiImpl implements ApplicationQueryApi {
@Override
public List<ListedApplication> listApplicationsV1() {
var principal = (OidcJwtCallerPrincipal) identity.getPrincipal();
return listApplicationsService.listApplications(principal.getClaim(USER_ID_CLAIM));
return listApplicationsService.listApplications(principal.getClaim(
PostAuthenticationFilter.USER_ID_CLAIM));
}

@Override
Expand All @@ -36,6 +34,7 @@ public RetrievedApplication retrieveApplicationV1(String id) {
@Override
public File retrieveAttachmentFromApplicationV1(String id, String attachmentId) {
throw new UnsupportedOperationException(
"Unimplemented method 'retrieveAttachmentFromApplicationV1'");
"Unimplemented method 'retrieveAttachmentFromApplicationV1'"
);
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
// SPDX-FileCopyrightText: 2024 PNED G.I.E.
//
// SPDX-License-Identifier: Apache-2.0
package lu.lnds.daam.security;
package io.github.genomicdatainfrastructure.daam.security;

import io.github.genomicdatainfrastructure.daam.services.CreateRemsUserService;
import io.quarkus.oidc.runtime.OidcJwtCallerPrincipal;
import io.quarkus.security.identity.SecurityIdentity;
import jakarta.annotation.Priority;
Expand All @@ -11,7 +12,6 @@
import jakarta.ws.rs.container.ContainerRequestContext;
import jakarta.ws.rs.container.ContainerRequestFilter;
import jakarta.ws.rs.ext.Provider;
import lu.lnds.daam.services.CreateRemsUserService;

@Provider
@Priority(Priorities.AUTHENTICATION)
Expand All @@ -25,8 +25,9 @@ public class PostAuthenticationFilter implements ContainerRequestFilter {
private final CreateRemsUserService createRemsUserService;

@Inject
public PostAuthenticationFilter(
SecurityIdentity identity, CreateRemsUserService createRemsUserService) {
public PostAuthenticationFilter(SecurityIdentity identity,
CreateRemsUserService createRemsUserService
) {
this.identity = identity;
this.createRemsUserService = createRemsUserService;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
// SPDX-FileCopyrightText: 2024 PNED G.I.E.
//
// SPDX-License-Identifier: Apache-2.0
package lu.lnds.daam.services;
package io.github.genomicdatainfrastructure.daam.services;

import io.github.genomicdatainfrastructure.daam.remote.rems.api.RemsUsersApi;
import io.github.genomicdatainfrastructure.daam.remote.rems.model.CreateUserCommand;
import jakarta.enterprise.context.ApplicationScoped;
import jakarta.inject.Inject;
import lu.lnds.daam.remote.rems.api.RemsUsersApi;
import lu.lnds.daam.remote.rems.model.CreateUserCommand;
import org.eclipse.microprofile.config.inject.ConfigProperty;
import org.eclipse.microprofile.rest.client.inject.RestClient;

Expand All @@ -21,7 +21,8 @@ public class CreateRemsUserService {
public CreateRemsUserService(
@ConfigProperty(name = "quarkus.rest-client.rems_yaml.api-key") String remsApiKey,
@ConfigProperty(name = "quarkus.rest-client.rems_yaml.bot-user") String remsBotUser,
@RestClient RemsUsersApi usersApi) {
@RestClient RemsUsersApi usersApi
) {
this.remsApiKey = remsApiKey;
this.remsBotUser = remsBotUser;
this.usersApi = usersApi;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
// SPDX-FileCopyrightText: 2024 PNED G.I.E.
//
// SPDX-License-Identifier: Apache-2.0
package lu.lnds.daam.services;
package io.github.genomicdatainfrastructure.daam.services;

import io.github.genomicdatainfrastructure.daam.model.ListedApplication;
import io.github.genomicdatainfrastructure.daam.remote.rems.api.RemsApplicationsApi;
import io.github.genomicdatainfrastructure.daam.remote.rems.model.ApplicationOverview;
import jakarta.enterprise.context.ApplicationScoped;
import jakarta.inject.Inject;
import java.util.List;
import lu.lnds.daam.model.ListedApplication;
import lu.lnds.daam.remote.rems.api.RemsApplicationsApi;
import lu.lnds.daam.remote.rems.model.ApplicationOverview;
import org.eclipse.microprofile.config.inject.ConfigProperty;
import org.eclipse.microprofile.rest.client.inject.RestClient;

Expand All @@ -21,7 +21,8 @@ public class ListApplicationsService {
@Inject
public ListApplicationsService(
@ConfigProperty(name = "quarkus.rest-client.rems_yaml.api-key") String remsApiKey,
@RestClient RemsApplicationsApi applicationsApi) {
@RestClient RemsApplicationsApi applicationsApi
) {
this.remsApiKey = remsApiKey;
this.applicationsApi = applicationsApi;
}
Expand Down
15 changes: 0 additions & 15 deletions src/main/java/lu/lnds/daam/services/CreateApplicationService.java

This file was deleted.

Loading

0 comments on commit 29fa9ba

Please sign in to comment.