Skip to content

Commit

Permalink
Refactor FederatedAuthPlugin and add unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronchung-bitquill committed Nov 23, 2023
1 parent 91aae4a commit 2419f9e
Show file tree
Hide file tree
Showing 22 changed files with 1,754 additions and 489 deletions.
4 changes: 0 additions & 4 deletions config/checkstyle/checkstyle-suppressions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,4 @@
<suppress files="[\\/]PgDataSourceHelper\.java" checks="IllegalImport"/>
<suppress files="[\\/]test[\\/]" checks="IllegalImport"/>
<suppress files="[\\/]ExtendedFormatter\.java" checks="Header"/>
<suppress files="[\\/]NonValidatingFactory\.java" checks="Header"/>
<suppress files="[\\/]WrappedFactory\.java" checks="Header"/>
<suppress files="[\\/]FederatedAuthConnectionPluginFactory\.java" checks="Header"/>
<suppress files="[\\/]FederatedAuthConnectionPlugin\.java" checks="Header"/>
</suppressions>

This file was deleted.

4 changes: 2 additions & 2 deletions examples/AWSDriverExample/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ dependencies {
implementation("org.postgresql:postgresql:42.6.0")
implementation("mysql:mysql-connector-java:8.0.33")
implementation("software.amazon.awssdk:rds:2.21.11")
implementation("software.amazon.awssdk:secretsmanager:2.21.11")
implementation("software.amazon.awssdk:sts:2.21.11")
implementation("software.amazon.awssdk:secretsmanager:2.21.21")
implementation("software.amazon.awssdk:sts:2.21.21")
implementation("com.fasterxml.jackson.core:jackson-databind:2.15.3")
implementation(project(":aws-advanced-jdbc-wrapper"))
implementation("io.opentelemetry:opentelemetry-api:1.31.0")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
package software.amazon;

import software.amazon.jdbc.PropertyDefinition;
import software.amazon.jdbc.plugin.FederatedAuthConnectionPlugin;
import software.amazon.jdbc.plugin.federatedauth.FederatedAuthConnectionPlugin;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
Expand All @@ -35,15 +35,15 @@ public static void main(String[] args) throws SQLException {

// Enable the AWS Federated Authentication Connection Plugin.
properties.setProperty(PropertyDefinition.PLUGINS.name, "federatedAuth");
properties.setProperty(FederatedAuthConnectionPlugin.IDP_HOST.name, "ec2amaz-ab3cdef.example.com");
properties.setProperty(FederatedAuthConnectionPlugin.IDP_NAME.name, "adfs");
properties.setProperty(FederatedAuthConnectionPlugin.IDP_ENDPOINT.name, "ec2amaz-ab3cdef.example.com");
properties.setProperty(FederatedAuthConnectionPlugin.IAM_ROLE_ARN.name, "arn:aws:iam::123456789012:role/adfs_example_iam_role");
properties.setProperty(FederatedAuthConnectionPlugin.IAM_IDP_ARN.name, "arn:aws:iam::123456789012:saml-provider/adfs_example");
properties.setProperty(FederatedAuthConnectionPlugin.IAM_REGION.name, "us-east-2");
properties.setProperty(FederatedAuthConnectionPlugin.IDP_USER_NAME.name, "[email protected]");
properties.setProperty(FederatedAuthConnectionPlugin.IDP_USER_PASSWORD.name, "somePassword");
properties.setProperty(FederatedAuthConnectionPlugin.IDP_USERNAME.name, "[email protected]");
properties.setProperty(FederatedAuthConnectionPlugin.IDP_PASSWORD.name, "somePassword");
properties.setProperty(PropertyDefinition.USER.name, "someIamUser");


// Try and make a connection:
try (final Connection conn = DriverManager.getConnection(CONNECTION_STRING, properties);
final Statement statement = conn.createStatement();
Expand Down
3 changes: 2 additions & 1 deletion wrapper/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,10 @@ dependencies {
testImplementation("com.zaxxer:HikariCP:4.0.3") // Version 4.+ is compatible with Java 8
testImplementation("org.springframework.boot:spring-boot-starter-jdbc:2.7.13") // 2.7.13 is the last version compatible with Java 8
testImplementation("org.mockito:mockito-inline:4.11.0") // 4.11.0 is the last version compatible with Java 8
testImplementation("software.amazon.awssdk:rds:2.21.11")
testImplementation("software.amazon.awssdk:ec2:2.21.12")
testImplementation("software.amazon.awssdk:rds:2.21.11")
testImplementation("software.amazon.awssdk:secretsmanager:2.21.21")
testImplementation("software.amazon.awssdk:sts:2.21.11")
testImplementation("org.testcontainers:testcontainers:1.19.1")
testImplementation("org.testcontainers:mysql:1.19.1")
testImplementation("org.testcontainers:postgresql:1.19.2")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@
import software.amazon.jdbc.plugin.DefaultConnectionPlugin;
import software.amazon.jdbc.plugin.DriverMetaDataConnectionPluginFactory;
import software.amazon.jdbc.plugin.ExecutionTimeConnectionPluginFactory;
import software.amazon.jdbc.plugin.FederatedAuthConnectionPluginFactory;
import software.amazon.jdbc.plugin.IamAuthConnectionPluginFactory;
import software.amazon.jdbc.plugin.LogQueryConnectionPluginFactory;
import software.amazon.jdbc.plugin.dev.DeveloperConnectionPluginFactory;
import software.amazon.jdbc.plugin.efm.HostMonitoringConnectionPluginFactory;
import software.amazon.jdbc.plugin.failover.FailoverConnectionPluginFactory;
import software.amazon.jdbc.plugin.federatedauth.FederatedAuthConnectionPluginFactory;
import software.amazon.jdbc.plugin.readwritesplitting.ReadWriteSplittingPluginFactory;
import software.amazon.jdbc.plugin.staledns.AuroraStaleDnsPluginFactory;
import software.amazon.jdbc.profile.ConfigurationProfile;
Expand Down
Loading

0 comments on commit 2419f9e

Please sign in to comment.