Skip to content

Commit

Permalink
Merge pull request #97 from folio-org/EDGCOMMON-75-vertx-4.5.4
Browse files Browse the repository at this point in the history
EDGCOMMON-75: Quesnelia deps: Vertx 4.5.4, aws 1.12.671, vault 6.2.0, …
  • Loading branch information
julianladisch authored Mar 11, 2024
2 parents 942852f + 0bfa62d commit 20a350e
Show file tree
Hide file tree
Showing 8 changed files with 48 additions and 50 deletions.
33 changes: 14 additions & 19 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,21 +37,21 @@
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-bom</artifactId>
<version>2.20.0</version>
<version>2.23.0</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>io.vertx</groupId>
<artifactId>vertx-stack-depchain</artifactId>
<version>4.4.6</version>
<version>4.5.4</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>testcontainers-bom</artifactId>
<version>1.19.1</version>
<version>1.19.6</version>
<type>pom</type>
<scope>import</scope>
</dependency>
Expand All @@ -63,13 +63,13 @@
<dependency>
<groupId>nl.jqno.equalsverifier</groupId>
<artifactId>equalsverifier</artifactId>
<version>3.15.2</version>
<version>3.15.8</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.rest-assured</groupId>
<artifactId>rest-assured</artifactId>
<version>5.3.2</version>
<version>5.4.0</version>
<scope>test</scope>
</dependency>
<dependency>
Expand All @@ -86,7 +86,7 @@
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>5.5.0</version>
<version>5.11.0</version>
<scope>test</scope>
</dependency>

Expand Down Expand Up @@ -119,7 +119,7 @@
<dependency>
<groupId>org.folio.okapi</groupId>
<artifactId>okapi-common</artifactId>
<version>5.1.0</version>
<version>6.0.0</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
Expand All @@ -139,19 +139,14 @@
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk-ssm</artifactId>
<version>1.12.645</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpcore</artifactId>
<version>4.4.16</version>
<version>1.12.671</version>
</dependency>

<!-- Only needed for VaultStore -->
<dependency>
<groupId>com.bettercloud</groupId>
<groupId>io.github.jopenlibs</groupId>
<artifactId>vault-java-driver</artifactId>
<version>5.1.0</version>
<version>6.2.0</version>
</dependency>

<!-- we use log4j as our logging implementation -->
Expand All @@ -176,7 +171,7 @@
Java 17 -->
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.11.0</version>
<version>3.12.1</version>
<configuration>
<release>17</release>
</configuration>
Expand All @@ -197,7 +192,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.1.2</version>
<version>3.2.5</version>
</plugin>

<plugin>
Expand Down Expand Up @@ -242,11 +237,11 @@

<plugin>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.4.1</version>
<version>3.6.3</version>
<executions>
<execution>
<id>attach-javadocs</id>
<phase>deploy</phase>
<phase>verify</phase>
<goals>
<goal>jar</goal>
</goals>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ public class EphemeralStore extends SecureStore {

public EphemeralStore(Properties properties) {
super(properties);
logger.info("Initializing...");

if (properties != null) {
String tenants = properties.getProperty(PROP_TENANTS);
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/org/folio/edge/core/security/VaultStore.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
import java.io.File;
import java.util.Properties;

import com.bettercloud.vault.SslConfig;
import com.bettercloud.vault.Vault;
import com.bettercloud.vault.VaultConfig;
import com.bettercloud.vault.VaultException;
import io.github.jopenlibs.vault.SslConfig;
import io.github.jopenlibs.vault.Vault;
import io.github.jopenlibs.vault.VaultConfig;
import io.github.jopenlibs.vault.VaultException;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

Expand Down Expand Up @@ -64,7 +64,7 @@ public VaultStore(Properties properties) {
config.sslConfig(sslConfig);
}

vault = new Vault(config.build());
vault = Vault.create(config.build());
} catch (VaultException e) {
logger.error("Failed to initialize: ", e);
}
Expand Down
7 changes: 3 additions & 4 deletions src/main/java/org/folio/edge/core/utils/test/TestUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import org.apache.logging.log4j.core.LogEvent;
import org.apache.logging.log4j.Level;
import org.apache.logging.log4j.core.appender.AbstractAppender;

import org.junit.Assert;

public class TestUtils {
Expand Down Expand Up @@ -75,7 +74,7 @@ static boolean isLocalPortFree(int port) {
* @param logger that is used in test code
* @param minTimes minimum number of log events
* @param maxTimes maximum number of log events
* @param logLevel level to test against (not working, so not checked)
* @param logLevel expected level for first message
* @param expectedMsg expected message for first message
* @param t expected Throwable (not working, pass null always)
* @param func function to execute which presumably logs
Expand Down Expand Up @@ -103,7 +102,7 @@ private static void assertLogMessage(org.apache.logging.log4j.core.Logger logger
if (logLevel != null) {
Assert.assertFalse(appender.events.isEmpty());
Level gotLevel = appender.events.get(0).getLevel();
Assert.assertTrue(gotLevel == Level.OFF || gotLevel == logLevel);
Assert.assertEquals("log level", logLevel, gotLevel);
}

if (expectedMsg != null) {
Expand All @@ -124,7 +123,7 @@ protected AppenderCapture() {

@Override
public void append(LogEvent event) {
events.add(event);
events.add(event.toImmutable());
}

}
Expand Down
18 changes: 13 additions & 5 deletions src/test/java/org/folio/edge/core/security/VaultStoreTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,17 @@
import java.util.Properties;

import org.folio.edge.core.security.SecureStore.NotFoundException;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;

import com.bettercloud.vault.Vault;
import com.bettercloud.vault.api.Logical;
import com.bettercloud.vault.response.LogicalResponse;
import com.bettercloud.vault.rest.RestResponse;
import io.github.jopenlibs.vault.Vault;
import io.github.jopenlibs.vault.api.Logical;
import io.github.jopenlibs.vault.response.LogicalResponse;
import io.github.jopenlibs.vault.rest.RestResponse;

public class VaultStoreTest {

Expand All @@ -27,14 +28,21 @@ public class VaultStoreTest {
@InjectMocks
VaultStore secureStore;

private AutoCloseable mocks;

@Before
public void setUp() throws Exception {

Properties props = new Properties();

secureStore = new VaultStore(props);

MockitoAnnotations.initMocks(this);
mocks = MockitoAnnotations.openMocks(this);
}

@After
public void tearDown() throws Exception {
mocks.close();
}

@Test(expected = NotFoundException.class)
Expand Down
11 changes: 5 additions & 6 deletions src/test/java/org/folio/edge/core/utils/test/MockOkapiTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import java.util.ArrayList;
import java.util.List;

import org.apache.http.HttpHeaders;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.junit.AfterClass;
Expand Down Expand Up @@ -88,7 +87,7 @@ public void testLogin() {
.body(json.getBytes())
.contentType(APPLICATION_JSON)
.header(X_OKAPI_TENANT, tenant)
.header(HttpHeaders.ACCEPT, JSON_OR_TEXT)
.accept(JSON_OR_TEXT)
.when()
.post("/authn/login")
.then()
Expand Down Expand Up @@ -123,7 +122,7 @@ public void testLoginNoPassword() {
.body(json.getBytes())
.contentType(APPLICATION_JSON)
.header(X_OKAPI_TENANT, tenant)
.header(HttpHeaders.ACCEPT, JSON_OR_TEXT)
.accept(JSON_OR_TEXT)
.when()
.post("/authn/login")
.then()
Expand All @@ -148,7 +147,7 @@ public void testLoginUnknownTenant() {
.body(json.getBytes())
.contentType(APPLICATION_JSON)
.header(X_OKAPI_TENANT, unknownTenant)
.header(HttpHeaders.ACCEPT, JSON_OR_TEXT)
.accept(JSON_OR_TEXT)
.when()
.post("/authn/login")
.then()
Expand Down Expand Up @@ -262,7 +261,7 @@ public void testLoginMissingUserName() {
.body(json)
.contentType(APPLICATION_JSON)
.header(X_OKAPI_TENANT, tenant)
.header(HttpHeaders.ACCEPT, JSON_OR_TEXT)
.accept(JSON_OR_TEXT)
.when()
.post("/authn/login")
.then()
Expand All @@ -281,7 +280,7 @@ public void testLoginBadJson() {
.body(json)
.contentType(APPLICATION_JSON)
.header(X_OKAPI_TENANT, tenant)
.header(HttpHeaders.ACCEPT, JSON_OR_TEXT)
.accept(JSON_OR_TEXT)
.when()
.post("/authn/login")
.then()
Expand Down
10 changes: 8 additions & 2 deletions src/test/java/org/folio/edge/core/utils/test/TestUtilsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ public void testAssertLogMessageSingleMessage() {
@Test(expected = AssertionError.class)
public void testAssertLogThrown() {
Logger log = LogManager.getLogger("testAssertLogThrown");
String msg = "hello world";
Level lvl = Level.INFO;
Throwable t = new IllegalArgumentException("il");
TestUtils.assertLogMessage(log, 1, 1, lvl, "x", t, () -> {
Expand All @@ -80,10 +79,17 @@ public void testAssertLogThrown() {
}

@Test
public void testAssertLogMessageCorrectLevel() {
Logger log = LogManager.getLogger("testAssertLogMessageWrongLevel");
String msg = "hello world";
TestUtils.assertLogMessage(log, 1, 1, Level.ERROR, msg, null,
() -> logMessages(log, msg, 1, Level.ERROR));
}

@Test(expected = AssertionError.class)
public void testAssertLogMessageWrongLevel() {
Logger log = LogManager.getLogger("testAssertLogMessageWrongLevel");
String msg = "hello world";
// logLevel not really checked, so this succeeds
TestUtils.assertLogMessage(log, 1, 1, Level.ERROR, msg, null,
() -> logMessages(log, msg, 1, Level.INFO));
}
Expand Down
8 changes: 0 additions & 8 deletions src/test/resources/log4j.properties

This file was deleted.

0 comments on commit 20a350e

Please sign in to comment.