Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add @DisabledOnFipsAndNative annotation and drop @DisabledOnFipsAndJava17 #1380

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
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
@Inherited
@Target({ ElementType.TYPE, ElementType.METHOD })
michalvavrik marked this conversation as resolved.
Show resolved Hide resolved
@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();
}
}