diff --git a/extensions/camel-k/deployment/src/main/java/org/apache/camel/quarkus/k/deployment/RuntimeProcessor.java b/extensions/camel-k/deployment/src/main/java/org/apache/camel/quarkus/k/deployment/RuntimeProcessor.java index 61bdfde43cb0..8563c7ab255d 100644 --- a/extensions/camel-k/deployment/src/main/java/org/apache/camel/quarkus/k/deployment/RuntimeProcessor.java +++ b/extensions/camel-k/deployment/src/main/java/org/apache/camel/quarkus/k/deployment/RuntimeProcessor.java @@ -44,6 +44,7 @@ import org.apache.camel.quarkus.k.core.SourceDefinition; import org.apache.camel.quarkus.k.runtime.ApplicationProducers; import org.apache.camel.quarkus.k.runtime.ApplicationRecorder; +import org.apache.camel.quarkus.k.runtime.ApplicationRoutes; import org.apache.camel.quarkus.k.support.Constants; import org.apache.camel.quarkus.k.support.RuntimeSupport; import org.apache.camel.spi.CamelContextCustomizer; @@ -88,7 +89,8 @@ CamelRuntimeTaskBuildItem registerRuntime( @BuildStep List unremovableBeans() { return List.of( - AdditionalBeanBuildItem.unremovableOf(ApplicationProducers.class)); + AdditionalBeanBuildItem.unremovableOf(ApplicationProducers.class), + AdditionalBeanBuildItem.unremovableOf(ApplicationRoutes.class)); } @BuildStep diff --git a/extensions/camel-k/runtime/src/main/java/org/apache/camel/quarkus/k/runtime/ApplicationModelReifierFactory.java b/extensions/camel-k/runtime/src/main/java/org/apache/camel/quarkus/k/runtime/ApplicationModelReifierFactory.java index 0c5682ce1f39..5574073070d2 100644 --- a/extensions/camel-k/runtime/src/main/java/org/apache/camel/quarkus/k/runtime/ApplicationModelReifierFactory.java +++ b/extensions/camel-k/runtime/src/main/java/org/apache/camel/quarkus/k/runtime/ApplicationModelReifierFactory.java @@ -16,7 +16,20 @@ */ package org.apache.camel.quarkus.k.runtime; +import org.apache.camel.CamelContext; +import org.apache.camel.Route; import org.apache.camel.impl.DefaultModelReifierFactory; +import org.apache.camel.model.RouteDefinition; public class ApplicationModelReifierFactory extends DefaultModelReifierFactory { + @Override + public Route createRoute(CamelContext camelContext, Object routeDefinition) { + ApplicationRoutes routes = camelContext.getRegistry().findSingleByType(ApplicationRoutes.class); + + if (routeDefinition instanceof RouteDefinition) { + routes.override((RouteDefinition) routeDefinition); + } + + return super.createRoute(camelContext, routeDefinition); + } } diff --git a/extensions/camel-k/runtime/src/main/java/org/apache/camel/quarkus/k/runtime/ApplicationRoutes.java b/extensions/camel-k/runtime/src/main/java/org/apache/camel/quarkus/k/runtime/ApplicationRoutes.java new file mode 100644 index 000000000000..c7ad29ac1a89 --- /dev/null +++ b/extensions/camel-k/runtime/src/main/java/org/apache/camel/quarkus/k/runtime/ApplicationRoutes.java @@ -0,0 +1,75 @@ +/* + * 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.k.runtime; + +import java.util.Objects; + +import jakarta.enterprise.context.ApplicationScoped; +import jakarta.inject.Inject; +import org.apache.camel.CamelContext; +import org.apache.camel.model.FromDefinition; +import org.apache.camel.model.RouteDefinition; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * A bean to hold routes related logic. + */ +@ApplicationScoped +public class ApplicationRoutes { + private static final Logger LOGGER = LoggerFactory.getLogger(ApplicationRoutes.class); + + @Inject + ApplicationRoutesConfig config; + + @Inject + CamelContext context; + + public ApplicationRoutesConfig config() { + return this.config; + } + + public void override(RouteDefinition definition) { + if (config.overrides().isEmpty()) { + return; + } + + final String id = definition.getRouteId(); + final FromDefinition from = definition.getInput(); + + for (ApplicationRoutesConfig.RouteOverride override : config.overrides().get()) { + if (override.id().isEmpty() && override.input().from().isEmpty()) { + continue; + } + if (override.id().isPresent() && !Objects.equals(override.id().get(), id)) { + continue; + } + if (override.input().from().isPresent() && !Objects.equals(from.getEndpointUri(), override.input().from().get())) { + continue; + } + + LOGGER.debug("Replace '{}' --> '{}' for route {}", + from.getEndpointUri(), + override.input().with(), + definition.getRouteId()); + + from.setUri(override.input().with()); + + break; + } + } +} diff --git a/extensions/camel-k/runtime/src/main/java/org/apache/camel/quarkus/k/runtime/ApplicationRoutesConfig.java b/extensions/camel-k/runtime/src/main/java/org/apache/camel/quarkus/k/runtime/ApplicationRoutesConfig.java new file mode 100644 index 000000000000..0169fc12f998 --- /dev/null +++ b/extensions/camel-k/runtime/src/main/java/org/apache/camel/quarkus/k/runtime/ApplicationRoutesConfig.java @@ -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.k.runtime; + +import java.util.List; +import java.util.Optional; + +import io.smallrye.config.ConfigMapping; + +@ConfigMapping(prefix = "camel.k.routes") +public interface ApplicationRoutesConfig { + /** + * A list of {@link RouteOverride} items to override some aspect of a {@link org.apache.camel.model.RouteDefinition}. + */ + Optional> overrides(); + + interface RouteOverride { + /** + * Identifies the route to be amended. + */ + Optional id(); + + /** + * Override for the {@link org.apache.camel.model.FromDefinition} of a {@link org.apache.camel.model.RouteDefinition}. + */ + RouteInputOverride input(); + } + + interface RouteInputOverride { + /** + * The optional endpoint that should be replaced. + */ + Optional from(); + + /** + * The value that should replace the endpoint. + */ + String with(); + } +} diff --git a/extensions/camel-k/runtime/src/test/java/org/apache/camel/quarkus/k/support/RuntimeSupportTest.java b/extensions/camel-k/runtime/src/test/java/org/apache/camel/quarkus/k/support/RuntimeSupportTest.java index 393ba4937048..2843557f0751 100644 --- a/extensions/camel-k/runtime/src/test/java/org/apache/camel/quarkus/k/support/RuntimeSupportTest.java +++ b/extensions/camel-k/runtime/src/test/java/org/apache/camel/quarkus/k/support/RuntimeSupportTest.java @@ -135,7 +135,7 @@ public void testLoadCustomizersFallback() { @Test public void testLoadCustomizerOrder() { DefaultCamelContext context = new DefaultCamelContext(); - context.setName("camel"); + context.getCamelContextExtension().setName("camel"); context.getRegistry().bind("c1", new CamelContextCustomizer() { @Override public int getOrder() { diff --git a/integration-tests-support/test-support/src/main/java/org/apache/camel/quarkus/test/EnabledIfFipsMode.java b/integration-tests-support/test-support/src/main/java/org/apache/camel/quarkus/test/EnabledIfFipsMode.java new file mode 100644 index 000000000000..a916580a9248 --- /dev/null +++ b/integration-tests-support/test-support/src/main/java/org/apache/camel/quarkus/test/EnabledIfFipsMode.java @@ -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 enabled if the JDK has FIPS enabled security providers present. + */ +@Target({ ElementType.TYPE, ElementType.METHOD }) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@ExtendWith(EnabledIfFipsModeCondition.class) +public @interface EnabledIfFipsMode { + /** + * 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 {}; +} diff --git a/integration-tests-support/test-support/src/main/java/org/apache/camel/quarkus/test/EnabledIfFipsModeCondition.java b/integration-tests-support/test-support/src/main/java/org/apache/camel/quarkus/test/EnabledIfFipsModeCondition.java new file mode 100644 index 000000000000..34b8ddb7f7dc --- /dev/null +++ b/integration-tests-support/test-support/src/main/java/org/apache/camel/quarkus/test/EnabledIfFipsModeCondition.java @@ -0,0 +1,58 @@ +/* + * 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.security.Provider; +import java.security.Security; +import java.util.List; + +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 EnabledIfFipsModeCondition implements ExecutionCondition { + private static final ConditionEvaluationResult ENABLED_BY_DEFAULT = enabled("@EnabledIfFipsMode is not present"); + + @Override + public ConditionEvaluationResult evaluateExecutionCondition(ExtensionContext context) { + return findAnnotation(context.getElement(), EnabledIfFipsMode.class).map(this::map).orElse(ENABLED_BY_DEFAULT); + } + + private ConditionEvaluationResult map(EnabledIfFipsMode annotation) { + List providersToMatch = List.of(annotation.providers()); + Provider[] jdkProviders = Security.getProviders(); + int matchCount = 0; + + for (Provider provider : jdkProviders) { + if (providersToMatch.isEmpty() && provider.getName().toLowerCase().contains("fips")) { + return enabled("Detected FIPS security provider " + provider.getName()); + } else if (providersToMatch.contains(provider.getName())) { + matchCount++; + } + } + + if (!providersToMatch.isEmpty() && matchCount == providersToMatch.size()) { + return enabled("Detected FIPS security providers"); + } + + return disabled("No FIPS security providers were detected"); + } +} diff --git a/integration-tests/camel-k-runtime-model-reifier/pom.xml b/integration-tests/camel-k-runtime-model-reifier/pom.xml new file mode 100644 index 000000000000..3c0fe5f173af --- /dev/null +++ b/integration-tests/camel-k-runtime-model-reifier/pom.xml @@ -0,0 +1,297 @@ + + + + + org.apache.camel.quarkus + camel-quarkus-build-parent-it + 3.8.1-SNAPSHOT + ../../poms/build-parent-it/pom.xml + + 4.0.0 + + camel-quarkus-integration-test-camel-k-runtime-model-reifier + Camel Quarkus :: Integration Tests :: Camel K Runtime Model Reifier + Integration tests for Camel Quarkus K Runtime Model Reifier extension + + + + org.apache.camel.quarkus + camel-quarkus-camel-k + + + org.apache.camel.quarkus + camel-quarkus-yaml-dsl + + + org.apache.camel.quarkus + camel-quarkus-xml-io-dsl + + + org.apache.camel.quarkus + camel-quarkus-timer + + + org.apache.camel.quarkus + camel-quarkus-log + + + org.apache.camel.quarkus + camel-quarkus-rest + + + org.apache.camel.quarkus + camel-quarkus-platform-http + + + org.apache.camel.quarkus + camel-quarkus-direct + + + org.apache.camel.quarkus + camel-quarkus-knative + + + + io.quarkus + quarkus-jsonb + + + io.quarkus + quarkus-resteasy + + + io.quarkus + quarkus-resteasy-jsonb + + + + + io.quarkus + quarkus-junit5 + test + + + io.rest-assured + rest-assured + test + + + org.assertj + assertj-core + test + + + + + + + org.apache.maven.plugins + maven-surefire-plugin + + + ${project.build.testOutputDirectory}/camel-k-runtime-model-reifier/conf.properties + ${project.build.testOutputDirectory}/camel-k-runtime-model-reifier/conf.d + + + + + + + + + ci + + 6g + + + + native + + + native + + + + native + + + + + org.apache.maven.plugins + maven-failsafe-plugin + + + + integration-test + verify + + + + ${project.build.testOutputDirectory}/camel-k-runtime-model-reifier/conf.properties + ${project.build.testOutputDirectory}/camel-k-runtime-model-reifier/conf.d + + + + + + + + + + virtualDependencies + + + !noVirtualDependencies + + + + + + org.apache.camel.quarkus + camel-quarkus-camel-k-deployment + ${project.version} + pom + test + + + * + * + + + + + org.apache.camel.quarkus + camel-quarkus-direct-deployment + ${project.version} + pom + test + + + * + * + + + + + org.apache.camel.quarkus + camel-quarkus-knative-deployment + ${project.version} + pom + test + + + * + * + + + + + org.apache.camel.quarkus + camel-quarkus-log-deployment + ${project.version} + pom + test + + + * + * + + + + + org.apache.camel.quarkus + camel-quarkus-platform-http-deployment + ${project.version} + pom + test + + + * + * + + + + + org.apache.camel.quarkus + camel-quarkus-rest-deployment + ${project.version} + pom + test + + + * + * + + + + + org.apache.camel.quarkus + camel-quarkus-timer-deployment + ${project.version} + pom + test + + + * + * + + + + + org.apache.camel.quarkus + camel-quarkus-xml-io-dsl-deployment + ${project.version} + pom + test + + + * + * + + + + + org.apache.camel.quarkus + camel-quarkus-yaml-dsl-deployment + ${project.version} + pom + test + + + * + * + + + + + + + skip-testcontainers-tests + + + skip-testcontainers-tests + + + + true + + + + diff --git a/integration-tests/camel-k-runtime-model-reifier/src/main/java/org/apache/camel/quarkus/k/it/Application.java b/integration-tests/camel-k-runtime-model-reifier/src/main/java/org/apache/camel/quarkus/k/it/Application.java new file mode 100644 index 000000000000..dfa920c4b25f --- /dev/null +++ b/integration-tests/camel-k-runtime-model-reifier/src/main/java/org/apache/camel/quarkus/k/it/Application.java @@ -0,0 +1,50 @@ +/* + * 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.k.it; + +import jakarta.enterprise.context.ApplicationScoped; +import jakarta.inject.Inject; +import jakarta.json.Json; +import jakarta.json.JsonObject; +import jakarta.ws.rs.GET; +import jakarta.ws.rs.Path; +import jakarta.ws.rs.PathParam; +import jakarta.ws.rs.Produces; +import jakarta.ws.rs.core.MediaType; +import org.apache.camel.CamelContext; +import org.apache.camel.Route; + +@Path("/camel-k") +@ApplicationScoped +public class Application { + + @Inject + CamelContext camelContext; + + @GET + @Path("/inspect/route/{id}") + @Produces(MediaType.APPLICATION_JSON) + public JsonObject inspectRoute(@PathParam("id") String id) { + Route route = camelContext.getRoute(id); + route.getEndpoint().getEndpointUri(); + + return Json.createObjectBuilder() + .add("id", route.getRouteId()) + .add("input", route.getEndpoint().getEndpointUri()) + .build(); + } +} diff --git a/integration-tests/camel-k-runtime-model-reifier/src/main/resources/application.properties b/integration-tests/camel-k-runtime-model-reifier/src/main/resources/application.properties new file mode 100644 index 000000000000..4408fe306204 --- /dev/null +++ b/integration-tests/camel-k-runtime-model-reifier/src/main/resources/application.properties @@ -0,0 +1,30 @@ +## --------------------------------------------------------------------------- +## 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. +## --------------------------------------------------------------------------- + +# +# Quarkus +# +quarkus.banner.enabled = false + +# disable kubernetes dev services as none of the test requires it. +quarkus.kubernetes-client.devservices.enabled = false + +# enable logging for ApplicationRoutes so the routes endpoint override will be +# visible in the logs for troubleshooting +quarkus.log.category."org.apache.camel.quarkus.k.runtime.ApplicationRoutes".level = DEBUG + +quarkus.native.resources.includes = routes.yaml \ No newline at end of file diff --git a/integration-tests/camel-k-runtime-model-reifier/src/main/resources/routes.yaml b/integration-tests/camel-k-runtime-model-reifier/src/main/resources/routes.yaml new file mode 100644 index 000000000000..ee61f2fc7f8e --- /dev/null +++ b/integration-tests/camel-k-runtime-model-reifier/src/main/resources/routes.yaml @@ -0,0 +1,47 @@ +# +# 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. +# + +- route: + id: "r1" + from: + uri: "direct:r1" + steps: + - to: "log:info1" +- route: + id: "r2" + from: + uri: "direct:r2" + steps: + - to: "log:info2" +- route: + id: "r3" + from: + uri: "direct:r3" + steps: + - to: "log:info3" +- route: + id: "r4" + from: + uri: "direct:r4" + steps: + - to: "log:info4" +- route: + id: "r5" + from: + uri: "direct:r5" + steps: + - to: "log:info5" diff --git a/integration-tests/camel-k-runtime-model-reifier/src/test/java/org/apache/camel/quarkus/k/it/WithRoutesOverridesIT.java b/integration-tests/camel-k-runtime-model-reifier/src/test/java/org/apache/camel/quarkus/k/it/WithRoutesOverridesIT.java new file mode 100644 index 000000000000..616112afb3f4 --- /dev/null +++ b/integration-tests/camel-k-runtime-model-reifier/src/test/java/org/apache/camel/quarkus/k/it/WithRoutesOverridesIT.java @@ -0,0 +1,23 @@ +/* + * 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.k.it; + +import io.quarkus.test.junit.QuarkusIntegrationTest; + +@QuarkusIntegrationTest +public class WithRoutesOverridesIT extends WithRoutesOverridesTest { +} diff --git a/integration-tests/camel-k-runtime-model-reifier/src/test/java/org/apache/camel/quarkus/k/it/WithRoutesOverridesTest.java b/integration-tests/camel-k-runtime-model-reifier/src/test/java/org/apache/camel/quarkus/k/it/WithRoutesOverridesTest.java new file mode 100644 index 000000000000..346f0ac547c0 --- /dev/null +++ b/integration-tests/camel-k-runtime-model-reifier/src/test/java/org/apache/camel/quarkus/k/it/WithRoutesOverridesTest.java @@ -0,0 +1,87 @@ +/* + * 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.k.it; + +import java.util.Map; + +import io.quarkus.test.common.QuarkusTestResource; +import io.quarkus.test.common.QuarkusTestResourceLifecycleManager; +import io.quarkus.test.junit.QuarkusTest; +import io.restassured.path.json.JsonPath; +import jakarta.ws.rs.core.MediaType; +import org.apache.camel.util.CollectionHelper; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.CsvSource; + +import static io.restassured.RestAssured.given; +import static org.assertj.core.api.Assertions.assertThat; + +@QuarkusTest +@QuarkusTestResource(WithRoutesOverridesTest.Resources.class) +public class WithRoutesOverridesTest { + + @ParameterizedTest + @CsvSource({ + "r1,direct://r1override", + "r2,direct://r2", + "r3,direct://r3", + "r4,direct://r4override", + "r5,direct://r5override", + }) + public void overrides(String id, String expected) { + JsonPath p = given() + .accept(MediaType.APPLICATION_JSON) + .get("/camel-k/inspect/route/" + id) + .then() + .statusCode(200) + .extract() + .body() + .jsonPath(); + + assertThat(p.getString("id")) + .isEqualTo(id); + assertThat(p.getString("input")) + .isEqualTo(expected); + } + + public static class Resources implements QuarkusTestResourceLifecycleManager { + @Override + public Map start() { + return CollectionHelper.mapOf( + "camel.k.routes.overrides[0].input.from", "direct:r1", + "camel.k.routes.overrides[0].input.with", "direct:r1override", + "camel.k.routes.overrides[1].id", "r2invalid", + "camel.k.routes.overrides[1].input.from", "direct:r2", + "camel.k.routes.overrides[1].input.with", "direct:r2override", + "camel.k.routes.overrides[2].id", "r3", + "camel.k.routes.overrides[2].input.from", "direct:r3invalid", + "camel.k.routes.overrides[2].input.with", "direct:r3override", + "camel.k.routes.overrides[3].id", "r4", + "camel.k.routes.overrides[3].input.from", "direct:r4", + "camel.k.routes.overrides[3].input.with", "direct:r4override", + "camel.k.routes.overrides[4].input.with", "direct:r5invalid", + "camel.k.routes.overrides[5].id", "r5", + "camel.k.routes.overrides[5].input.with", "direct:r5override", + "camel.k.sources[0].location", "classpath:routes.yaml", + "camel.k.sources[0].type", "source"); + } + + @Override + public void stop() { + } + } +} diff --git a/integration-tests/camel-k-runtime/src/main/resources/application.properties b/integration-tests/camel-k-runtime/src/main/resources/application.properties index 73989eb47376..97e58669af83 100644 --- a/integration-tests/camel-k-runtime/src/main/resources/application.properties +++ b/integration-tests/camel-k-runtime/src/main/resources/application.properties @@ -19,3 +19,6 @@ # Quarkus # quarkus.banner.enabled = false + +# disable kubernetes dev services as none of the test requires it. +quarkus.kubernetes-client.devservices.enabled = false \ No newline at end of file diff --git a/integration-tests/jasypt/pom.xml b/integration-tests/jasypt/pom.xml index d54b4dec47e9..325776eccf05 100644 --- a/integration-tests/jasypt/pom.xml +++ b/integration-tests/jasypt/pom.xml @@ -84,6 +84,11 @@ quarkus-test-h2 test + + org.apache.camel.quarkus + camel-quarkus-integration-test-support + test + @@ -203,6 +208,46 @@ + + fips + + + fips + + + + + + org.apache.maven.plugins + maven-surefire-plugin + + + **/JasyptFipsTest* + + + false + PKCS11 + PKCS11 + + + + + org.apache.maven.plugins + maven-failsafe-plugin + + + **/JasyptFipsIT* + + + false + PKCS11 + PKCS11 + + + + + + diff --git a/integration-tests/jasypt/src/test/java/org/apache/camel/quarkus/component/jasypt/it/JasyptFipsIT.java b/integration-tests/jasypt/src/test/java/org/apache/camel/quarkus/component/jasypt/it/JasyptFipsIT.java new file mode 100644 index 000000000000..8fbd841b3cd9 --- /dev/null +++ b/integration-tests/jasypt/src/test/java/org/apache/camel/quarkus/component/jasypt/it/JasyptFipsIT.java @@ -0,0 +1,25 @@ +/* + * 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.component.jasypt.it; + +import io.quarkus.test.junit.QuarkusIntegrationTest; +import org.apache.camel.quarkus.test.EnabledIfFipsMode; + +@QuarkusIntegrationTest +@EnabledIfFipsMode +class JasyptFipsIT extends JasyptFipsTest { +} diff --git a/integration-tests/jasypt/src/test/java/org/apache/camel/quarkus/component/jasypt/it/JasyptFipsModeTestProfile.java b/integration-tests/jasypt/src/test/java/org/apache/camel/quarkus/component/jasypt/it/JasyptFipsModeTestProfile.java new file mode 100644 index 000000000000..3aa1f22571f3 --- /dev/null +++ b/integration-tests/jasypt/src/test/java/org/apache/camel/quarkus/component/jasypt/it/JasyptFipsModeTestProfile.java @@ -0,0 +1,36 @@ +/* + * 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.component.jasypt.it; + +import java.util.Map; + +import io.quarkus.test.junit.QuarkusTestProfile; + +public class JasyptFipsModeTestProfile implements QuarkusTestProfile { + @Override + public Map getConfigOverrides() { + return Map.of( + "quarkus.camel.jasypt.algorithm", "PBEWithHMACSHA256AndAES_256", + "quarkus.camel.jasypt.random-iv-generator-algorithm", "PKCS11", + "quarkus.camel.jasypt.random-salt-generator-algorithm", "PKCS11", + "greeting.secret", "ENC(tp3QOxMouvD3oIdTXNM0uH+BtVEMCI1ak+GBTzPZOatthRP3m+ZxAg7CF0saNTmK)", + "explicit.config.provider.secret", "ENC(tp3QOxMouvD3oIdTXNM0uH+BtVEMCI1ak+GBTzPZOatthRP3m+ZxAg7CF0saNTmK)", + "camel.component.direct.timeout", "30000", + "timer.delay.secret", "ENC(/NsF9u8xrJh/sIre0ZQtOf6DwBaVVOcQkHe3ungkmvVfUyLXgboTgunz5Rpy+C6G)", + "timer.repeatCount.secret", "ENC(J1sLt6MpTuCTROefLY3MwQXcbPEDXnReFqvNdf/mBta4fs2HuO1Jkl8YbASg2oVt)"); + } +} diff --git a/integration-tests/jasypt/src/test/java/org/apache/camel/quarkus/component/jasypt/it/JasyptFipsTest.java b/integration-tests/jasypt/src/test/java/org/apache/camel/quarkus/component/jasypt/it/JasyptFipsTest.java new file mode 100644 index 000000000000..5bf0167e9e52 --- /dev/null +++ b/integration-tests/jasypt/src/test/java/org/apache/camel/quarkus/component/jasypt/it/JasyptFipsTest.java @@ -0,0 +1,27 @@ +/* + * 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.component.jasypt.it; + +import io.quarkus.test.junit.QuarkusTest; +import io.quarkus.test.junit.TestProfile; +import org.apache.camel.quarkus.test.EnabledIfFipsMode; + +@QuarkusTest +@TestProfile(JasyptFipsModeTestProfile.class) +@EnabledIfFipsMode +class JasyptFipsTest extends JasyptTest { +} diff --git a/integration-tests/jasypt/src/test/java/org/apache/camel/quarkus/component/jasypt/it/JasyptTest.java b/integration-tests/jasypt/src/test/java/org/apache/camel/quarkus/component/jasypt/it/JasyptTest.java index 9ce1cead39da..90ed255e08bf 100644 --- a/integration-tests/jasypt/src/test/java/org/apache/camel/quarkus/component/jasypt/it/JasyptTest.java +++ b/integration-tests/jasypt/src/test/java/org/apache/camel/quarkus/component/jasypt/it/JasyptTest.java @@ -16,6 +16,7 @@ */ package org.apache.camel.quarkus.component.jasypt.it; +import io.quarkus.arc.DefaultBean; import io.quarkus.test.junit.QuarkusTest; import io.restassured.RestAssured; import org.junit.jupiter.api.Test; @@ -24,6 +25,7 @@ import static org.hamcrest.Matchers.is; +@DefaultBean @QuarkusTest class JasyptTest { @ParameterizedTest diff --git a/integration-tests/pom.xml b/integration-tests/pom.xml index 4fbe65d5a212..bd11318b16a5 100644 --- a/integration-tests/pom.xml +++ b/integration-tests/pom.xml @@ -70,6 +70,7 @@ braintree caffeine camel-k-runtime + camel-k-runtime-model-reifier cassandraql cbor compression-grouped diff --git a/tooling/scripts/test-categories.yaml b/tooling/scripts/test-categories.yaml index 67b63d7a2332..d1400f4f669e 100644 --- a/tooling/scripts/test-categories.yaml +++ b/tooling/scripts/test-categories.yaml @@ -209,6 +209,7 @@ group-12: group-13: - box - camel-k-runtime + - camel-k-runtime-model-reifier - fhir - github - google