-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add opt encrypted communication for MSSQL
- Loading branch information
1 parent
36560af
commit 1e28035
Showing
17 changed files
with
429 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
...est-core/src/main/java/io/quarkus/test/scenarios/annotations/DisabledOnFipsAndJava17.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package io.quarkus.test.scenarios.annotations; | ||
|
||
import java.lang.annotation.ElementType; | ||
import java.lang.annotation.Inherited; | ||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.RetentionPolicy; | ||
import java.lang.annotation.Target; | ||
|
||
import org.junit.jupiter.api.extension.ExtendWith; | ||
|
||
@Inherited | ||
@Target({ ElementType.TYPE, ElementType.METHOD }) | ||
@Retention(RetentionPolicy.RUNTIME) | ||
@ExtendWith(DisabledOnFipsAndJava17Condition.class) | ||
public @interface DisabledOnFipsAndJava17 { | ||
/** | ||
* Why is the annotated test class or test method disabled. | ||
*/ | ||
String reason() default ""; | ||
} |
30 changes: 30 additions & 0 deletions
30
...src/main/java/io/quarkus/test/scenarios/annotations/DisabledOnFipsAndJava17Condition.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package io.quarkus.test.scenarios.annotations; | ||
|
||
import org.junit.jupiter.api.extension.ConditionEvaluationResult; | ||
import org.junit.jupiter.api.extension.ExecutionCondition; | ||
import org.junit.jupiter.api.extension.ExtensionContext; | ||
|
||
public class DisabledOnFipsAndJava17Condition implements ExecutionCondition { | ||
|
||
/** | ||
* We set environment variable "FIPS" to "fips" in our Jenkins jobs when FIPS are enabled. | ||
*/ | ||
private static final String FIPS_ENABLED = "fips"; | ||
|
||
@Override | ||
public ConditionEvaluationResult evaluateExecutionCondition(ExtensionContext context) { | ||
if (isFipsEnabledEnvironment() && isJava17()) { | ||
return ConditionEvaluationResult.disabled("The test is running in FIPS enabled environment with Java 17"); | ||
} | ||
|
||
return ConditionEvaluationResult.enabled("The test is not running in FIPS enabled environment with Java 17"); | ||
} | ||
|
||
private static boolean isFipsEnabledEnvironment() { | ||
return FIPS_ENABLED.equals(System.getenv().get("FIPS")); | ||
} | ||
|
||
private static boolean isJava17() { | ||
return 17 == Runtime.version().feature(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
...t-core/src/main/java/io/quarkus/test/security/certificate/ContainerMountPathStrategy.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package io.quarkus.test.security.certificate; | ||
|
||
public interface ContainerMountPathStrategy { | ||
|
||
String truststorePath(String currentLocation); | ||
|
||
String keystorePath(String currentLocation); | ||
|
||
String keyPath(String currentLocation); | ||
|
||
String certPath(String currentLocation); | ||
|
||
/** | ||
* Whether container destination path is also path used by Quarkus application when accessing these certs. | ||
* Simply put it, if 'yes' is returned, we are probably mounting certs to the Quarkus application pod. | ||
*/ | ||
boolean containerShareMountPathWithApp(); | ||
} |
49 changes: 49 additions & 0 deletions
49
...src/main/java/io/quarkus/test/security/certificate/DefaultContainerMountPathStrategy.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package io.quarkus.test.security.certificate; | ||
|
||
import static io.quarkus.test.security.certificate.Certificate.createCertsTempDir; | ||
|
||
import java.nio.file.Path; | ||
|
||
import io.quarkus.test.utils.FileUtils; | ||
|
||
class DefaultContainerMountPathStrategy implements ContainerMountPathStrategy { | ||
|
||
private final String prefix; | ||
|
||
DefaultContainerMountPathStrategy(String prefix) { | ||
this.prefix = prefix; | ||
} | ||
|
||
@Override | ||
public String truststorePath(String currentLocation) { | ||
// no point of making both keystore and truststore unique, one of them is enough | ||
return currentLocation; | ||
} | ||
|
||
@Override | ||
public String keystorePath(String currentLocation) { | ||
return makeFileMountPathUnique(prefix, currentLocation); | ||
} | ||
|
||
@Override | ||
public String keyPath(String currentLocation) { | ||
return makeFileMountPathUnique(prefix, currentLocation); | ||
} | ||
|
||
@Override | ||
public String certPath(String currentLocation) { | ||
return makeFileMountPathUnique(prefix, currentLocation); | ||
} | ||
|
||
@Override | ||
public boolean containerShareMountPathWithApp() { | ||
return true; | ||
} | ||
|
||
private static String makeFileMountPathUnique(String prefix, String storeLocation) { | ||
var newTempCertDir = createCertsTempDir(prefix); | ||
var storeFile = Path.of(storeLocation).toFile(); | ||
FileUtils.copyFileTo(storeFile, newTempCertDir); | ||
return newTempCertDir.resolve(storeFile.getName()).toAbsolutePath().toString(); | ||
} | ||
} |
Oops, something went wrong.