Skip to content

Commit

Permalink
Fixed FIPS folder
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-astachowski committed Oct 11, 2024
1 parent af01a07 commit 7461ef5
Show file tree
Hide file tree
Showing 10 changed files with 38 additions and 166 deletions.
2 changes: 0 additions & 2 deletions FIPS/src/test/java/net/snowflake/client/AbstractDriverIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,10 @@
import java.util.TimeZone;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.junit.Rule;

/** Base test class with common constants, data structures and methods */
public class AbstractDriverIT {
// This is required to use ConditionalIgnore annotation.
@Rule public ConditionalIgnoreRule rule = new ConditionalIgnoreRule();

public static final String DRIVER_CLASS = "net.snowflake.client.jdbc.SnowflakeDriver";
public static final String DRIVER_CLASS_COM = "com.snowflake.client.jdbc.SnowflakeDriver";
Expand Down
125 changes: 0 additions & 125 deletions FIPS/src/test/java/net/snowflake/client/ConditionalIgnoreRule.java

This file was deleted.

12 changes: 12 additions & 0 deletions FIPS/src/test/java/net/snowflake/client/DontRunOnGCP.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package net.snowflake.client.annotations;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import org.junit.jupiter.api.condition.DisabledIfEnvironmentVariable;

@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
@DisabledIfEnvironmentVariable(named = "CLOUD_PROVIDER", matches = "(?i)GCP(?-i)")
public @interface DontRunOnGCP {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package net.snowflake.client.annotations;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import org.junit.jupiter.api.condition.DisabledIfEnvironmentVariable;

@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
@DisabledIfEnvironmentVariable(named = "GITHUB_ACTIONS", matches = ".*")
public @interface DontRunOnGithubActions {}
12 changes: 0 additions & 12 deletions FIPS/src/test/java/net/snowflake/client/RunningOnGCP.java

This file was deleted.

This file was deleted.

Empty file.
22 changes: 10 additions & 12 deletions FIPS/src/test/java/net/snowflake/client/jdbc/ConnectionFipsIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
*/
package net.snowflake.client.jdbc;

import static org.junit.Assert.*;

import java.net.URL;
import java.nio.file.Files;
import java.nio.file.Paths;
Expand All @@ -29,9 +27,9 @@
import org.bouncycastle.crypto.CryptoServicesRegistrar;
import org.bouncycastle.crypto.fips.FipsStatus;
import org.bouncycastle.jcajce.provider.BouncyCastleFipsProvider;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.Test;


//@Category(TestCategoryFips.class)
Expand Down Expand Up @@ -106,7 +104,7 @@ public class ConnectionFipsIT extends AbstractDriverIT {
private static int JCE_PROVIDER_SUN_JCE_PROVIDER_POSITION;
private static int JCE_PROVIDER_SUN_RSA_SIGN_PROVIDER_POSITION;

@BeforeClass
@BeforeAll
public static void setup() throws Exception {
System.setProperty("javax.net.debug", "ssl");
// get keystore types for BouncyCastle libraries
Expand Down Expand Up @@ -166,7 +164,7 @@ public static void setup() throws Exception {
// connectToGoogle();
}

@AfterClass
@AfterAll
public static void teardown() throws Exception {
// Remove BouncyCastle FIPS Provider
Security.removeProvider(JCE_PROVIDER_BOUNCY_CASTLE_FIPS);
Expand Down Expand Up @@ -227,7 +225,7 @@ public void connectWithFips() throws SQLException {
}

@Test
@ConditionalIgnoreRule.ConditionalIgnore(condition = RunningOnGithubActions.class)
@DontRunOnGithubActions
public void connectWithFipsKeyPair() throws Exception {
Map<String, String> parameters = getConnectionParameters();
String testUser = parameters.get("user");
Expand Down Expand Up @@ -256,7 +254,7 @@ public void connectWithFipsKeyPair() throws Exception {
}

@Test
@ConditionalIgnoreRule.ConditionalIgnore(condition = RunningOnGithubActions.class)
@DontRunOnGithubActions
public void testConnectUsingKeyPair() throws Exception {
Map<String, String> parameters = getConnectionParameters();
String testUser = parameters.get("user");
Expand Down Expand Up @@ -295,7 +293,7 @@ public void testConnectUsingKeyPair() throws Exception {
* Currently ignored execution on GCP due to exception thrown "SSlException Could not generate XDH keypair"
*/
@Test
@ConditionalIgnoreRule.ConditionalIgnore(condition = RunningOnGCP.class)
@DontRunOnGCP
public void connectWithFipsAndQuery() throws SQLException {
try (Connection con = getConnection()) {
Statement statement = con.createStatement();
Expand Down Expand Up @@ -329,15 +327,15 @@ public void connectWithFipsAndPut() throws Exception {

/** Added in > 3.15.1 */
@Test
@ConditionalIgnoreRule.ConditionalIgnore(condition = RunningOnGithubActions.class)
@DontRunOnGithubActions
public void connectWithFipsKeyPairWithBouncyCastle() throws Exception {
System.setProperty(SecurityUtil.ENABLE_BOUNCYCASTLE_PROVIDER_JVM, "true");
connectWithFipsKeyPair();
}

/** Added in > 3.15.1 */
@Test
@ConditionalIgnoreRule.ConditionalIgnore(condition = RunningOnGithubActions.class)
@DontRunOnGithubActions
public void testConnectUsingKeyPairWithBouncyCastle() throws Exception {
System.setProperty(SecurityUtil.ENABLE_BOUNCYCASTLE_PROVIDER_JVM, "true");
testConnectUsingKeyPair();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import org.junit.jupiter.api.condition.DisabledIfEnvironmentVariable;
import org.junit.jupiter.api.condition.EnabledIfEnvironmentVariable;

@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
@DisabledIfEnvironmentVariable(named = "CLOUD_PROVIDER", matches = "(?i)Azure(?-i)")
@EnabledIfEnvironmentVariable(named = "CLOUD_PROVIDER", matches = "(?i)Azure(?-i)")
public @interface RunOnAzure {}
4 changes: 2 additions & 2 deletions src/test/java/net/snowflake/client/annotations/RunOnGCP.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import org.junit.jupiter.api.condition.DisabledIfEnvironmentVariable;
import org.junit.jupiter.api.condition.EnabledIfEnvironmentVariable;

@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
@DisabledIfEnvironmentVariable(named = "CLOUD_PROVIDER", matches = "(?i)GCP(?-i)")
@EnabledIfEnvironmentVariable(named = "CLOUD_PROVIDER", matches = "(?i)GCP(?-i)")
public @interface RunOnGCP {}

0 comments on commit 7461ef5

Please sign in to comment.