Skip to content
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
8 changes: 4 additions & 4 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
types: [opened, synchronize, ready_for_review]

env:
AWS_DEFAULT_REGION: us-west-2
AWS_REGION: us-west-2
Comment thread
simonmarty marked this conversation as resolved.

jobs:
build:
Expand All @@ -16,11 +16,11 @@ jobs:
steps:
- uses: actions/checkout@v5

- name: Set up JDK 11
- name: Set up JDK 17
uses: actions/setup-java@v5
with:
java-version: 11
distribution: adopt
java-version: 17
distribution: corretto

- name: Build with Maven
run: mvn --batch-mode --update-snapshots package
Expand Down
63 changes: 36 additions & 27 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -70,73 +70,80 @@
<dependency>
<groupId>software.amazon.awssdk</groupId>
<artifactId>secretsmanager</artifactId>
<version>2.31.7</version>
<version>2.34.2</version>
</dependency>

<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.36</version>
<version>1.18.42</version>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.18.3</version>
<version>2.20.0</version>
</dependency>

<dependency>
<groupId>com.github.spotbugs</groupId>
<artifactId>spotbugs-annotations</artifactId>
<version>4.9.3</version>
<version>4.9.6</version>
</dependency>

<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13.2</version>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.12.2</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>com.github.stefanbirkner</groupId>
<artifactId>system-rules</artifactId>
<version>1.19.0</version>
<groupId>uk.org.webcompere</groupId>
<artifactId>system-stubs-jupiter</artifactId>
<version>2.1.8</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-inline</artifactId>
<version>3.12.4</version>
<artifactId>mockito-core</artifactId>
<version>5.18.0</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-module-junit4</artifactId>
<version>2.0.9</version>
<groupId>org.mockito</groupId>
<artifactId>mockito-junit-jupiter</artifactId>
<version>5.18.0</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-api-mockito2</artifactId>
<version>2.0.9</version>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>2.0.17</version>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.5.4</version>
<configuration>
<argLine>-XX:+EnableDynamicAgentLoading -Xshare:off</argLine>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.14.0</version>
<version>3.14.1</version>
<configuration>
<source>11</source>
<target>11</target>
<release>8</release>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
Expand All @@ -156,7 +163,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.11.2</version>
<version>3.12.0</version>
<executions>
<execution>
<id>attach-javadocs</id>
Expand Down Expand Up @@ -190,7 +197,7 @@
<plugin>
<groupId>com.github.spotbugs</groupId>
<artifactId>spotbugs-maven-plugin</artifactId>
<version>4.9.3.0</version>
<version>4.9.6.0</version>
<configuration>
<effort>Max</effort>
<threshold>Low</threshold>
Expand All @@ -209,7 +216,7 @@
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.12</version>
<version>0.8.13</version>
<executions>
<execution>
<goals>
Expand All @@ -236,7 +243,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<version>3.2.7</version>
<version>3.2.8</version>
<executions>
<execution>
<id>sign-artifacts</id>
Expand All @@ -250,10 +257,12 @@
<plugin>
<groupId>org.sonatype.central</groupId>
<artifactId>central-publishing-maven-plugin</artifactId>
<version>0.7.0</version>
<version>0.9.0</version>
<extensions>true</extensions>
<configuration>
<publishingServerId>central</publishingServerId>
<autoPublish>true</autoPublish>
<waitUntil>published</waitUntil>
</configuration>
</plugin>
</plugins>
Expand All @@ -266,7 +275,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.6.0</version>
<version>3.6.1</version>
<executions>
<execution>
<id>shade</id>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ protected AWSSecretsManagerDriver() {
*
* @param cache Secret cache to use to retrieve secrets
*/
@SuppressFBWarnings({"MC_OVERRIDABLE_METHOD_CALL_IN_CONSTRUCTOR", "CT_CONSTRUCTOR_THROW"})
@SuppressFBWarnings("CT_CONSTRUCTOR_THROW")
protected AWSSecretsManagerDriver(SecretCache cache) {
this.secretCache = cache;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ public final class AWSSecretsManagerRedshiftDriver extends AWSSecretsManagerDriv
*/
public static final String ACCESS_DENIED_FOR_USER_USING_PASSWORD_TO_DATABASE = "28P01";

/**
* The Redshift JDBC sub-prefix.
*/
public static final String SUBPREFIX = "redshift";

static {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,17 @@ public class JDBCSecretCacheBuilderProvider {

private Config configFile;

/**
* Constructs the provider with the default configuration.
*/
public JDBCSecretCacheBuilderProvider() {
this(Config.loadMainConfig());
}

/**
* Constructs the provider with the provided configuration.
* @param config Config to use for provider
*/
public JDBCSecretCacheBuilderProvider(Config config) {
configFile = config;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
import java.util.ArrayList;
import java.util.List;

/**
* SQL Exception Utilities
*/
public class SQLExceptionUtils {

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,38 +14,31 @@

import com.amazonaws.secretsmanager.caching.SecretCache;
import com.amazonaws.secretsmanager.util.TestClass;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.powermock.core.classloader.annotations.PowerMockIgnore;
import org.powermock.core.classloader.annotations.SuppressStaticInitializationFor;
import org.powermock.modules.junit4.PowerMockRunner;

import java.sql.SQLException;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;

/**
* Tests for the Db2 Driver.
*/
@RunWith(PowerMockRunner.class)
@SuppressStaticInitializationFor("com.amazonaws.secretsmanager.sql.AWSSecretsManagerDb2Driver")
@PowerMockIgnore("jdk.internal.reflect.*")
public class AWSSecretsManagerDb2DriverTest extends TestClass {

private AWSSecretsManagerDb2Driver sut;

@Mock
private SecretCache cache;

@Before
@BeforeEach
public void setup() {
System.setProperty("drivers.db2.realDriverClass", "com.amazonaws.secretsmanager.sql.DummyDriver");
MockitoAnnotations.initMocks(this);
MockitoAnnotations.openMocks(this);
try {
sut = new AWSSecretsManagerDb2Driver(cache);
} catch (Exception e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,28 +12,24 @@
*/
package com.amazonaws.secretsmanager.sql;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertSame;
import static org.junit.jupiter.api.Assertions.assertTrue;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.Properties;

import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
import org.powermock.core.classloader.annotations.PowerMockIgnore;
import org.powermock.core.classloader.annotations.SuppressStaticInitializationFor;
import org.powermock.modules.junit4.PowerMockRunner;

import com.amazonaws.secretsmanager.caching.SecretCache;
import com.amazonaws.secretsmanager.caching.SecretCacheConfiguration;
Expand All @@ -46,9 +42,6 @@
* Tests for AWSSecretsManagerDriver. Uses a config file in the resources folder just to make sure it can read from
* the file.
*/
@RunWith(PowerMockRunner.class)
@SuppressStaticInitializationFor({"com.amazonaws.secretsmanager.sql.*"})
@PowerMockIgnore("jdk.internal.reflect.*")
public class AWSSecretsManagerDriverTest extends TestClass {

private AWSSecretsManagerDummyDriver sut;
Expand All @@ -64,13 +57,13 @@ public class AWSSecretsManagerDriverTest extends TestClass {

boolean hasRefreshed;

@Before
@BeforeEach
public void setup() throws InterruptedException {
System.clearProperty("drivers.dummy.realDriverClass");

// Instantiate mocks
hasRefreshed = false;
MockitoAnnotations.initMocks(this);
MockitoAnnotations.openMocks(this);
Mockito.when(cache.getSecretString(Mockito.any(String.class))).thenAnswer(new Answer<String>() {
@Override
public String answer(InvocationOnMock invocation) throws Throwable {
Expand Down Expand Up @@ -347,7 +340,7 @@ public void test_getParentLogger_propagatesToRealDriver() {
public void test_getPropertyInfo_propagatesToRealDriver() {
String param1 = "jdbc-secretsmanager:expectedUrl";
Properties param2 = new Properties();
assertNotThrows(() -> Assert.assertNull(sut.getPropertyInfo(param1, param2)));
assertNotThrows(() -> Assertions.assertNull(sut.getPropertyInfo(param1, param2)));
assertEquals(1, DummyDriver.getPropertyInfoCallCount);
String param1Expected = "jdbc:expectedUrl";
assertEquals(param1Expected, DummyDriver.getPropertyInfoParam1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,41 +12,34 @@
*/
package com.amazonaws.secretsmanager.sql;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;

import java.sql.SQLException;

import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.powermock.core.classloader.annotations.PowerMockIgnore;
import org.powermock.core.classloader.annotations.SuppressStaticInitializationFor;
import org.powermock.modules.junit4.PowerMockRunner;

import com.amazonaws.secretsmanager.caching.SecretCache;
import com.amazonaws.secretsmanager.util.TestClass;

/**
* Tests for the MSSQL Driver.
*/
@RunWith(PowerMockRunner.class)
@SuppressStaticInitializationFor("com.amazonaws.secretsmanager.sql.AWSSecretsManagerMSSQLServerDriver")
@PowerMockIgnore("jdk.internal.reflect.*")
public class AWSSecretsManagerMSSQLServerDriverTest extends TestClass {

private AWSSecretsManagerMSSQLServerDriver sut;

@Mock
private SecretCache cache;

@Before
@BeforeEach
public void setup() {
System.setProperty("drivers.sqlserver.realDriverClass", "com.amazonaws.secretsmanager.sql.DummyDriver");
MockitoAnnotations.initMocks(this);
MockitoAnnotations.openMocks(this);
try {
sut = new AWSSecretsManagerMSSQLServerDriver(cache);
} catch (Exception e) {
Expand Down
Loading