Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #196: Enable encryption in unit tests #197

Merged
merged 1 commit into from
Jun 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,15 @@
import com.wultra.security.userdatastore.client.model.response.AttachmentCreateResponse;
import com.wultra.security.userdatastore.client.model.response.AttachmentResponse;
import com.wultra.security.userdatastore.client.model.response.DocumentCreateResponse;
import org.bouncycastle.jce.provider.BouncyCastleProvider;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestInstance;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.web.server.LocalServerPort;
import org.springframework.test.context.ActiveProfiles;

import java.security.Security;
import java.util.Collections;

import static org.junit.jupiter.api.Assertions.*;
Expand All @@ -56,7 +58,8 @@ class AttachmentRestClientTest {
private UserDataStoreRestClient restClient;

@BeforeAll
void initRestClient() throws Exception {
void initTests() throws Exception {
Security.addProvider(new BouncyCastleProvider());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We may move the initialization of the provider into a static constructor in the SpringBootApplication class.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, let's handle this separately, if required.

RestClientConfiguration config = new RestClientConfiguration();
config.setHttpBasicAuthEnabled(true);
config.setHttpBasicAuthUsername("admin");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,15 @@
import com.wultra.core.rest.client.base.RestClientConfiguration;
import com.wultra.security.userdatastore.UserDataStoreRestClient;
import com.wultra.security.userdatastore.client.model.error.UserDataStoreClientException;
import org.bouncycastle.jce.provider.BouncyCastleProvider;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestInstance;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.web.server.LocalServerPort;
import org.springframework.test.context.ActiveProfiles;

import java.security.Security;
import java.util.LinkedHashMap;
import java.util.Map;

Expand All @@ -51,7 +53,8 @@ class ClaimsRestClientTest {
private UserDataStoreRestClient restClient;

@BeforeAll
void initRestClient() throws Exception {
void initTests() throws Exception {
Security.addProvider(new BouncyCastleProvider());
RestClientConfiguration config = new RestClientConfiguration();
config.setHttpBasicAuthEnabled(true);
config.setHttpBasicAuthUsername("admin");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,15 @@
import com.wultra.security.userdatastore.client.model.request.*;
import com.wultra.security.userdatastore.client.model.response.DocumentCreateResponse;
import com.wultra.security.userdatastore.client.model.response.DocumentResponse;
import org.bouncycastle.jce.provider.BouncyCastleProvider;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestInstance;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.web.server.LocalServerPort;
import org.springframework.test.context.ActiveProfiles;

import java.security.Security;
import java.util.*;

import static org.junit.jupiter.api.Assertions.*;
Expand All @@ -53,7 +55,8 @@ class DocumentRestClientTest {
private UserDataStoreRestClient restClient;

@BeforeAll
void initRestClient() throws Exception {
void initTests() throws Exception {
Security.addProvider(new BouncyCastleProvider());
RestClientConfiguration config = new RestClientConfiguration();
config.setHttpBasicAuthEnabled(true);
config.setHttpBasicAuthUsername("admin");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,15 @@
import com.wultra.security.userdatastore.client.model.response.DocumentCreateResponse;
import com.wultra.security.userdatastore.client.model.response.PhotoCreateResponse;
import com.wultra.security.userdatastore.client.model.response.PhotoResponse;
import org.bouncycastle.jce.provider.BouncyCastleProvider;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestInstance;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.web.server.LocalServerPort;
import org.springframework.test.context.ActiveProfiles;

import java.security.Security;
import java.util.Collections;
import java.util.List;

Expand All @@ -59,7 +61,8 @@ class PhotoRestClientTest {
private UserDataStoreRestClient restClient;

@BeforeAll
void initRestClient() throws Exception {
void initTests() throws Exception {
Security.addProvider(new BouncyCastleProvider());
RestClientConfiguration config = new RestClientConfiguration();
config.setHttpBasicAuthEnabled(true);
config.setHttpBasicAuthUsername("admin");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,15 @@
import com.wultra.core.rest.client.base.RestClientConfiguration;
import com.wultra.security.userdatastore.UserDataStoreRestClient;
import com.wultra.security.userdatastore.client.model.error.UserDataStoreClientException;
import org.bouncycastle.jce.provider.BouncyCastleProvider;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestInstance;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.web.server.LocalServerPort;
import org.springframework.test.context.ActiveProfiles;

import java.security.Security;
import java.util.LinkedHashMap;
import java.util.Map;

Expand All @@ -50,7 +52,8 @@ class UserClaimsRestClientTest {
private UserDataStoreRestClient restClient;

@BeforeAll
void initRestClient() throws Exception {
void initTests() throws Exception {
Security.addProvider(new BouncyCastleProvider());
RestClientConfiguration config = new RestClientConfiguration();
config.setHttpBasicAuthEnabled(true);
config.setHttpBasicAuthUsername("admin");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,6 @@ spring.datasource.password=
# Hibernate Configuration
spring.jpa.hibernate.ddl-auto=create-drop

spring.liquibase.enabled=false
spring.liquibase.enabled=false

user-data-store.db.master.encryption.key=L5PaAACAoW2+t0DLkVN9diTCJDAxBxFOLZcILp6JfKM=
Loading