Skip to content

Commit

Permalink
Add @DisabledOnFipsAndNative & drop version with Java 17
Browse files Browse the repository at this point in the history
  • Loading branch information
michalvavrik authored and fedinskiy committed Oct 23, 2024
1 parent d1fea78 commit 528f205
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
@Inherited
@Target({ ElementType.TYPE, ElementType.METHOD })
@Retention(RetentionPolicy.RUNTIME)
@ExtendWith(DisabledOnFipsAndJava17Condition.class)
public @interface DisabledOnFipsAndJava17 {
@ExtendWith(DisabledOnFipsAndNativeCondition.class)
public @interface DisabledOnFipsAndNative {
/**
* Why is the annotated test class or test method disabled.
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,31 +1,29 @@
package io.quarkus.test.scenarios.annotations;

import static io.quarkus.test.services.quarkus.model.QuarkusProperties.isNativeEnabled;

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 {
public class DisabledOnFipsAndNativeCondition implements ExecutionCondition {

/**
* We set environment variable "FIPS" to "fips" in our Jenkins jobs when FIPS are enabled.
*/
private static final String FIPS_ENABLED = "fips";
private static final int JAVA_17 = 17;

@Override
public ConditionEvaluationResult evaluateExecutionCondition(ExtensionContext context) {
if (isFipsEnabledEnvironment() && isJava17()) {
return ConditionEvaluationResult.disabled("The test is running in FIPS enabled environment with Java 17");
if (isFipsEnabledEnvironment() && isNativeEnabled()) {
return ConditionEvaluationResult.disabled("The test is running in FIPS enabled environment in native mode");
}

return ConditionEvaluationResult.enabled("The test is not running in FIPS enabled environment with Java 17");
return ConditionEvaluationResult.enabled("The test is not running in FIPS enabled environment in native mode");
}

private static boolean isFipsEnabledEnvironment() {
return FIPS_ENABLED.equals(System.getenv().get("FIPS"));
return FIPS_ENABLED.equalsIgnoreCase(System.getenv().get("FIPS"));
}

private static boolean isJava17() {
return JAVA_17 == Runtime.version().feature();
}
}

0 comments on commit 528f205

Please sign in to comment.