This is an automated email from the ASF dual-hosted git repository. zbendhiba pushed a commit to branch 3.20.x in repository https://gitbox.apache.org/repos/asf/camel-quarkus.git
commit 22437a9f881a71a509a5ccd59d2963e9510b4aa8 Author: Jiri Ondrusek <ondrusek.j...@gmail.com> AuthorDate: Wed Apr 2 10:35:33 2025 +0200 fixes #7211: disable SshTest#testProducerWithEdDSAKeyType for RHEL8(9) --- .../apache/camel/quarkus/test/DisabledOnRhel.java | 37 +++++++++++++ .../quarkus/test/DisabledOnRhelCondition.java | 61 ++++++++++++++++++++++ .../quarkus/test/DisabledOnRhelConditionTest.java | 46 ++++++++++++++++ .../camel/quarkus/component/ssh/it/SshTest.java | 2 + 4 files changed, 146 insertions(+) diff --git a/integration-tests-support/test-support/src/main/java/org/apache/camel/quarkus/test/DisabledOnRhel.java b/integration-tests-support/test-support/src/main/java/org/apache/camel/quarkus/test/DisabledOnRhel.java new file mode 100644 index 0000000000..0434b84f57 --- /dev/null +++ b/integration-tests-support/test-support/src/main/java/org/apache/camel/quarkus/test/DisabledOnRhel.java @@ -0,0 +1,37 @@ +/* + * 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; + +/** + * Skip test on RHEL linux. + */ +@Target({ ElementType.TYPE, ElementType.METHOD }) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@ExtendWith(DisabledOnRhelCondition.class) +public @interface DisabledOnRhel { + + int since() default 0; +} diff --git a/integration-tests-support/test-support/src/main/java/org/apache/camel/quarkus/test/DisabledOnRhelCondition.java b/integration-tests-support/test-support/src/main/java/org/apache/camel/quarkus/test/DisabledOnRhelCondition.java new file mode 100644 index 0000000000..cb2d54f929 --- /dev/null +++ b/integration-tests-support/test-support/src/main/java/org/apache/camel/quarkus/test/DisabledOnRhelCondition.java @@ -0,0 +1,61 @@ +/* + * 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.Optional; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import org.junit.jupiter.api.extension.ConditionEvaluationResult; +import org.junit.jupiter.api.extension.ExecutionCondition; +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; + +public class DisabledOnRhelCondition implements ExecutionCondition { + private static final ConditionEvaluationResult ENABLED_BY_DEFAULT = enabled( + "@DisabledOnRhel: enabled - annotation not present"); + + @Override + public ConditionEvaluationResult evaluateExecutionCondition(ExtensionContext context) { + Optional<DisabledOnRhel> annotation = findAnnotation(context.getElement(), DisabledOnRhel.class); + return annotation.isPresent() ? evaluate(annotation.get().since()) : ENABLED_BY_DEFAULT; + } + + private ConditionEvaluationResult evaluate(int since) { + return evaluate(System.getProperty("os.name").toLowerCase(), System.getProperty("os.version").toLowerCase(), since); + } + + ConditionEvaluationResult evaluate(String osName, String osVersion, int since) { + Pattern r = Pattern.compile(".+el(\\d+).+"); + Matcher m = r.matcher(osVersion.toLowerCase()); + if (osName.toLowerCase().contains("linux") && m.matches()) { + if (since == 0) { + return disabled("@DisabledOnRhel: disable - RHEL"); + } else { + Integer version = Integer.parseInt(m.group(1)); + if (version.compareTo(since) <= 0) { + return disabled("@DisabledOnRhel(since " + since + ") : disable - RHEL"); + } + } + } + + return enabled("@DisabledOnRhel: enabled - not a RHEL"); + } +} diff --git a/integration-tests-support/test-support/src/test/java/org/apache/camel/quarkus/test/DisabledOnRhelConditionTest.java b/integration-tests-support/test-support/src/test/java/org/apache/camel/quarkus/test/DisabledOnRhelConditionTest.java new file mode 100644 index 0000000000..b8e4e27fc9 --- /dev/null +++ b/integration-tests-support/test-support/src/test/java/org/apache/camel/quarkus/test/DisabledOnRhelConditionTest.java @@ -0,0 +1,46 @@ +/* + * 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 org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +public class DisabledOnRhelConditionTest { + + @Test + public void testEvaluate() { + DisabledOnRhelCondition condition = new DisabledOnRhelCondition(); + + //rhel 8 + Assertions.assertEquals(true, condition.evaluate("linux", "4.18.0-553.el8_10", 0).isDisabled()); + Assertions.assertEquals(true, condition.evaluate("linux", "4.18.0-553.el8_10", 8).isDisabled()); + Assertions.assertEquals(true, condition.evaluate("linux", "4.18.0-553.el8_10", 9).isDisabled()); + Assertions.assertEquals(true, condition.evaluate("linux", "4.18.0-553.el8_10", 10).isDisabled()); + + //rhel 9 + Assertions.assertEquals(true, condition.evaluate("linux", "5.14.0-503.11.1.el9_5", 0).isDisabled()); + Assertions.assertEquals(false, condition.evaluate("linux", "5.14.0-503.11.1.el9_5", 8).isDisabled()); + Assertions.assertEquals(true, condition.evaluate("linux", "5.14.0-503.11.1.el9_5", 9).isDisabled()); + Assertions.assertEquals(true, condition.evaluate("linux", "5.14.0-503.11.1.el9_5", 10).isDisabled()); + + //rhel 10 + Assertions.assertEquals(true, condition.evaluate("linux", "5.14.0-503.11.1.el10_5", 0).isDisabled()); + Assertions.assertEquals(false, condition.evaluate("linux", "5.14.0-503.11.1.el10_5", 8).isDisabled()); + Assertions.assertEquals(false, condition.evaluate("linux", "5.14.0-503.11.1.el10_5", 9).isDisabled()); + Assertions.assertEquals(true, condition.evaluate("linux", "5.14.0-503.11.1.el9_5", 10).isDisabled()); + } +} diff --git a/integration-tests/ssh/src/test/java/org/apache/camel/quarkus/component/ssh/it/SshTest.java b/integration-tests/ssh/src/test/java/org/apache/camel/quarkus/component/ssh/it/SshTest.java index 30da31ee8d..2789a15c7d 100644 --- a/integration-tests/ssh/src/test/java/org/apache/camel/quarkus/component/ssh/it/SshTest.java +++ b/integration-tests/ssh/src/test/java/org/apache/camel/quarkus/component/ssh/it/SshTest.java @@ -26,6 +26,7 @@ import io.smallrye.certs.Format; import io.smallrye.certs.junit5.Certificate; import org.apache.camel.component.ssh.SshConstants; import org.apache.camel.quarkus.test.DisabledIfFipsMode; +import org.apache.camel.quarkus.test.DisabledOnRhel; import org.apache.camel.quarkus.test.support.certificate.TestCertificates; import org.hamcrest.Matchers; import org.junit.jupiter.api.Test; @@ -115,6 +116,7 @@ class SshTest { } @DisabledIfFipsMode //ED25519 keys are not allowed in FIPS mode + @DisabledOnRhel(since = 8) //DSA is deprecated on RHEL8+, see https://docs.redhat.com/en/documentation/red_hat_enterprise_linux/8/html/8.4_release_notes/deprecated_functionality#deprecated-functionality_security @Test public void testProducerWithEdDSAKeyType() { RestAssured.given()