-
Notifications
You must be signed in to change notification settings - Fork 189
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
jdbc-db2: fails in fips environment #5993
- Loading branch information
1 parent
dfe70e0
commit 24a206b
Showing
6 changed files
with
133 additions
and
3 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
43 changes: 43 additions & 0 deletions
43
...-support/test-support/src/main/java/org/apache/camel/quarkus/test/DisabledIfFipsMode.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,43 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.apache.camel.quarkus.test; | ||
|
||
import java.lang.annotation.Documented; | ||
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.extension.ExtendWith; | ||
|
||
/** | ||
* Advertises that a test should be disabled if the JDK has FIPS enabled security providers present. | ||
*/ | ||
@Target({ ElementType.TYPE, ElementType.METHOD }) | ||
@Retention(RetentionPolicy.RUNTIME) | ||
@Documented | ||
@ExtendWith(DisabledIfFipsModeCondition.class) | ||
public @interface DisabledIfFipsMode { | ||
/** | ||
* The list of FIPS security provider names to match against for enabling the test. | ||
* If no providers are specified, the default behaviour is to try to match any provider that has | ||
* FIPS in its name. | ||
* | ||
* @return The list of security provider names. | ||
*/ | ||
String[] providers() default {}; | ||
} |
54 changes: 54 additions & 0 deletions
54
...test-support/src/main/java/org/apache/camel/quarkus/test/DisabledIfFipsModeCondition.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,54 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.apache.camel.quarkus.test; | ||
|
||
import java.util.List; | ||
import java.util.Optional; | ||
|
||
import org.junit.jupiter.api.extension.ConditionEvaluationResult; | ||
import org.junit.jupiter.api.extension.ExtensionContext; | ||
|
||
import static org.junit.jupiter.api.extension.ConditionEvaluationResult.disabled; | ||
import static org.junit.jupiter.api.extension.ConditionEvaluationResult.enabled; | ||
import static org.junit.platform.commons.util.AnnotationUtils.findAnnotation; | ||
|
||
/** | ||
* Opposite of EnabledIfInFipsModeCondition. | ||
*/ | ||
public class DisabledIfFipsModeCondition extends EnabledIfFipsModeCondition { | ||
private static final ConditionEvaluationResult ENABLED_BY_DEFAULT = enabled("@DisabledIfFipsMode is not present"); | ||
|
||
@Override | ||
public ConditionEvaluationResult evaluateExecutionCondition(ExtensionContext context) { | ||
return findAnnotation(context.getElement(), DisabledIfFipsMode.class).map(this::map).orElse(ENABLED_BY_DEFAULT); | ||
} | ||
|
||
private ConditionEvaluationResult map(DisabledIfFipsMode annotation) { | ||
List<String> providersToMatch = List.of(annotation.providers()); | ||
Optional<String> fipsProviders = findFipsProvider(providersToMatch); | ||
|
||
if (fipsProviders == null) { | ||
return enabled("No FIPS security providers were detected"); | ||
} | ||
if (fipsProviders.isEmpty()) { | ||
return disabled("Detected FIPS security providers"); | ||
} | ||
|
||
return disabled("Detected FIPS security provider " + fipsProviders.get()); | ||
} | ||
|
||
} |
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