oscerd commented on code in PR #26670:
URL: https://github.com/apache/camel/pull/26670#discussion_r4069685017


##########
components/camel-opa/src/main/java/org/apache/camel/component/opa/security/OpaSecurityPolicy.java:
##########
@@ -89,31 +98,55 @@ public OpaSecurityPolicy(String serverUrl, String 
policyPath) {
     public void beforeWrap(Route route, NamedNode definition) {
         if (evaluator == null) {
             StringHelper.notEmpty(policyPath, "policyPath", this);
-            OpaHttpClient transport = null;
-            if (opaClient == null) {
-                // createClient moved to OpaRestEvaluator when the evaluator 
became an abstract base
-                sslContext = createSslContext(route.getCamelContext());
-                transport = OpaRestEvaluator.createTransport(
-                        bearerToken, connectionTimeout, requestTimeout, 
sslContext);
-                opaClient = OpaRestEvaluator.createClient(serverUrl, 
transport);
-                ownsClient = true;
-            }
-            evaluator = new OpaRestEvaluator(
-                    opaClient, transport, policyPath, allowKey, 
includeHeaders, includeProperties, includeBody,
-                    failOpen);
-            // a Policy has no stop hook of its own, so the transport would 
outlive the routes it was built for.
-            // Registering the evaluator as a service hands its close() to the 
context's shutdown
+            evaluator = buildEvaluator(route.getCamelContext());
+            // a Policy has no stop hook of its own, so the evaluator - its 
HTTP transport in rest mode, or its
+            // WebAssembly instance pool in wasm mode - would outlive the 
routes it was built for. Registering it as a
+            // service hands its close() to the context's shutdown.
             try {
                 route.getCamelContext().addService(evaluator);
             } catch (Exception e) {
                 throw new RuntimeCamelException("Could not register the 
evaluator for policy " + policyPath, e);
             }
         }
-        // after validation, so a policy that is missing its policyPath fails 
without leaving a ".../null" check
-        // behind in the registry
+        // after validation, so a policy that is missing its policyPath fails 
without leaving a ".../null" check behind
+        // in the registry. In wasm mode nothing sets ownsClient, so no server 
readiness check is registered - the
+        // policy is evaluated in-process and there is no server to probe 
(consistent with CAMEL-24743).
         registerHealthCheck(route);
     }
 
+    /**
+     * Builds the evaluator for the configured {@code evaluationMode}. Both 
share {@link OpaPolicyEvaluator}, so the
+     * decision contract - the {@code CamelOpaDecision} headers and a 
fail-closed default - is identical whichever
+     * engine runs.
+     */
+    private OpaPolicyEvaluator buildEvaluator(CamelContext camelContext) {
+        if (WASM_MODE.equalsIgnoreCase(evaluationMode)) {

Review Comment:
   Addressed in d4e205e. `OpaSecurityPolicy` now calls 
`warnIgnoredServerOptions()` on the wasm path of `buildEvaluator`, mirroring 
`OpaEndpoint.warnAboutIgnoredServerOptions` (from #26669) so both entry points 
behave alike: it warns on an injected `opaClient`, a set `bearerToken`, and a 
non-default `serverUrl`. `failOpen` is deliberately left out — it still governs 
a wasm evaluation failure. Thanks for the catch.
   



##########
components/camel-opa/src/main/java/org/apache/camel/component/opa/security/OpaSecurityPolicy.java:
##########
@@ -89,31 +98,55 @@ public OpaSecurityPolicy(String serverUrl, String 
policyPath) {
     public void beforeWrap(Route route, NamedNode definition) {
         if (evaluator == null) {
             StringHelper.notEmpty(policyPath, "policyPath", this);
-            OpaHttpClient transport = null;
-            if (opaClient == null) {
-                // createClient moved to OpaRestEvaluator when the evaluator 
became an abstract base
-                sslContext = createSslContext(route.getCamelContext());
-                transport = OpaRestEvaluator.createTransport(
-                        bearerToken, connectionTimeout, requestTimeout, 
sslContext);
-                opaClient = OpaRestEvaluator.createClient(serverUrl, 
transport);
-                ownsClient = true;
-            }
-            evaluator = new OpaRestEvaluator(
-                    opaClient, transport, policyPath, allowKey, 
includeHeaders, includeProperties, includeBody,
-                    failOpen);
-            // a Policy has no stop hook of its own, so the transport would 
outlive the routes it was built for.
-            // Registering the evaluator as a service hands its close() to the 
context's shutdown
+            evaluator = buildEvaluator(route.getCamelContext());
+            // a Policy has no stop hook of its own, so the evaluator - its 
HTTP transport in rest mode, or its
+            // WebAssembly instance pool in wasm mode - would outlive the 
routes it was built for. Registering it as a
+            // service hands its close() to the context's shutdown.
             try {
                 route.getCamelContext().addService(evaluator);
             } catch (Exception e) {
                 throw new RuntimeCamelException("Could not register the 
evaluator for policy " + policyPath, e);
             }
         }
-        // after validation, so a policy that is missing its policyPath fails 
without leaving a ".../null" check
-        // behind in the registry
+        // after validation, so a policy that is missing its policyPath fails 
without leaving a ".../null" check behind
+        // in the registry. In wasm mode nothing sets ownsClient, so no server 
readiness check is registered - the
+        // policy is evaluated in-process and there is no server to probe 
(consistent with CAMEL-24743).
         registerHealthCheck(route);
     }
 
+    /**
+     * Builds the evaluator for the configured {@code evaluationMode}. Both 
share {@link OpaPolicyEvaluator}, so the
+     * decision contract - the {@code CamelOpaDecision} headers and a 
fail-closed default - is identical whichever
+     * engine runs.
+     */
+    private OpaPolicyEvaluator buildEvaluator(CamelContext camelContext) {
+        if (WASM_MODE.equalsIgnoreCase(evaluationMode)) {
+            try {
+                return OpaWasmEvaluator.create(camelContext, policyBundle, 
entrypoint, poolSize, borrowTimeout,
+                        policyPath, allowKey, includeHeaders, 
includeProperties, includeBody, failOpen);
+            } catch (RuntimeException e) {
+                // the validation messages (policyBundle, poolSize) already 
read correctly; do not bury them
+                throw e;
+            } catch (Exception e) {
+                throw new RuntimeCamelException("Could not load the wasm 
policy bundle for policy " + policyPath, e);
+            }

Review Comment:
   Addressed in d4e205e. `OpaSecurityPolicy` now calls 
`warnIgnoredServerOptions()` on the wasm path of `buildEvaluator`, mirroring 
`OpaEndpoint.warnAboutIgnoredServerOptions` (from #26669) so both entry points 
behave alike: it warns on an injected `opaClient`, a set `bearerToken`, and a 
non-default `serverUrl`. `failOpen` is deliberately left out — it still governs 
a wasm evaluation failure. Thanks for the catch.
   



##########
components/camel-opa/src/test/java/org/apache/camel/component/opa/security/OpaSecurityPolicyWasmTest.java:
##########
@@ -0,0 +1,115 @@
+/*
+ * 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.component.opa.security;
+
+import java.util.List;
+
+import org.apache.camel.CamelAuthorizationException;
+import org.apache.camel.CamelExecutionException;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.health.HealthCheck;
+import org.apache.camel.health.HealthCheckRegistry;
+import org.apache.camel.test.junit6.CamelTestSupport;
+import org.junit.jupiter.api.Test;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
+
+/**
+ * {@link OpaSecurityPolicy} enforcing a route with an in-process WebAssembly 
bundle. The decision contract is the same
+ * as the REST engine - a match proceeds, a non-match throws {@code 
CamelAuthorizationException} - and no server
+ * readiness check is registered, because the policy is evaluated in-process 
(CAMEL-24830).
+ */
+public class OpaSecurityPolicyWasmTest extends CamelTestSupport {
+
+    private final OpaSecurityPolicy wasmPolicy = new OpaSecurityPolicy();
+    private final OpaSecurityPolicy restPolicy = new OpaSecurityPolicy();
+
+    @Override
+    protected RouteBuilder createRouteBuilder() {
+        wasmPolicy.setEvaluationMode("wasm");
+        wasmPolicy.setPolicyBundle("classpath:authz.wasm");
+        wasmPolicy.setPolicyPath("authz/allow");
+
+        // a rest-mode policy is the positive control for the readiness-check 
assertion: it registers a check, the
+        // wasm one must not
+        restPolicy.setServerUrl("http://opa-rest:8181";);
+        restPolicy.setPolicyPath("authz/allow");
+
+        return new RouteBuilder() {
+            @Override
+            public void configure() {
+                from("direct:wasm").policy(wasmPolicy).to("mock:allowed");
+                from("direct:rest").policy(restPolicy).to("mock:rest");
+            }
+        };
+    }
+
+    @Test
+    void allowsWhenTheWasmPolicyMatches() throws Exception {
+        MockEndpoint allowed = getMockEndpoint("mock:allowed");
+        allowed.expectedMessageCount(1);
+
+        template.sendBodyAndHeader("direct:wasm", "payload", "user", "alice");
+
+        allowed.assertIsSatisfied();
+    }
+
+    @Test
+    void deniesWhenTheWasmPolicyDoesNotMatch() throws Exception {
+        MockEndpoint allowed = getMockEndpoint("mock:allowed");
+        allowed.expectedMessageCount(0);
+
+        assertThatThrownBy(() -> template.sendBodyAndHeader("direct:wasm", 
"payload", "user", "mallory"))
+                .isInstanceOf(CamelExecutionException.class)
+                .hasCauseInstanceOf(CamelAuthorizationException.class);
+
+        allowed.assertIsSatisfied();
+    }
+
+    @Test
+    void registersOnlyTheRestPolicysReadinessCheck() {
+        HealthCheckRegistry registry = HealthCheckRegistry.get(context);
+        assertThat(registry).isNotNull();
+        List<HealthCheck> checks = registry.stream()
+                .filter(hc -> hc.getId().startsWith("security-policy:opa-"))
+                .toList();
+
+        // exactly one, and it is the rest policy's - the wasm policy 
evaluates in-process with no server to probe
+        assertThat(checks).hasSize(1);
+        assertThat(checks.get(0).getId()).contains("opa-rest");
+    }
+
+    @Test
+    void failsRouteStartOnABundleThatLoadsButIsNotAValidModule() {
+        // OpaWasmEvaluator borrows an instance at startup so a broken bundle 
fails fast, and beforeWrap - which cannot
+        // throw a checked exception - must surface that rather than swallow 
it, or a route would start and then
+        // authorize nothing. authz.rego is the Rego source: it loads as bytes 
but is not a compiled wasm module.
+        OpaSecurityPolicy corrupt = new OpaSecurityPolicy();
+        corrupt.setEvaluationMode("wasm");
+        corrupt.setPolicyBundle("classpath:authz.rego");
+        corrupt.setPolicyPath("authz/allow");
+
+        assertThatThrownBy(() -> context.addRoutes(new RouteBuilder() {
+            @Override
+            public void configure() {
+                from("direct:corrupt").policy(corrupt).to("mock:never");
+            }
+        })).isInstanceOf(Exception.class);

Review Comment:
   Strengthened in d4e205e. `context.addRoutes` wraps the `beforeWrap` failure 
in `FailedToCreateRouteException` (a `RuntimeCamelException`), so: the 
loads-but-invalid case now asserts `RuntimeException` thrown from `addRoutes` — 
which proves the route never started (a first-exchange failure would not 
surface there) — and I added 
`failsRouteStartWhenTheBundleResourceCannotBeLoaded`, which asserts the wrapper 
explicitly via 
`.isInstanceOf(RuntimeCamelException.class).hasMessageContaining("Could not 
load the wasm policy bundle")`.
   



##########
components/camel-opa/src/test/java/org/apache/camel/component/opa/security/OpaSecurityPolicyWasmTest.java:
##########
@@ -0,0 +1,115 @@
+/*
+ * 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.component.opa.security;
+
+import java.util.List;
+
+import org.apache.camel.CamelAuthorizationException;
+import org.apache.camel.CamelExecutionException;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.health.HealthCheck;
+import org.apache.camel.health.HealthCheckRegistry;
+import org.apache.camel.test.junit6.CamelTestSupport;
+import org.junit.jupiter.api.Test;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
+
+/**
+ * {@link OpaSecurityPolicy} enforcing a route with an in-process WebAssembly 
bundle. The decision contract is the same
+ * as the REST engine - a match proceeds, a non-match throws {@code 
CamelAuthorizationException} - and no server
+ * readiness check is registered, because the policy is evaluated in-process 
(CAMEL-24830).
+ */
+public class OpaSecurityPolicyWasmTest extends CamelTestSupport {
+
+    private final OpaSecurityPolicy wasmPolicy = new OpaSecurityPolicy();
+    private final OpaSecurityPolicy restPolicy = new OpaSecurityPolicy();
+
+    @Override
+    protected RouteBuilder createRouteBuilder() {
+        wasmPolicy.setEvaluationMode("wasm");
+        wasmPolicy.setPolicyBundle("classpath:authz.wasm");
+        wasmPolicy.setPolicyPath("authz/allow");
+
+        // a rest-mode policy is the positive control for the readiness-check 
assertion: it registers a check, the
+        // wasm one must not
+        restPolicy.setServerUrl("http://opa-rest:8181";);
+        restPolicy.setPolicyPath("authz/allow");
+
+        return new RouteBuilder() {
+            @Override
+            public void configure() {
+                from("direct:wasm").policy(wasmPolicy).to("mock:allowed");
+                from("direct:rest").policy(restPolicy).to("mock:rest");
+            }
+        };
+    }
+
+    @Test
+    void allowsWhenTheWasmPolicyMatches() throws Exception {
+        MockEndpoint allowed = getMockEndpoint("mock:allowed");
+        allowed.expectedMessageCount(1);
+
+        template.sendBodyAndHeader("direct:wasm", "payload", "user", "alice");
+
+        allowed.assertIsSatisfied();
+    }
+
+    @Test
+    void deniesWhenTheWasmPolicyDoesNotMatch() throws Exception {
+        MockEndpoint allowed = getMockEndpoint("mock:allowed");
+        allowed.expectedMessageCount(0);
+
+        assertThatThrownBy(() -> template.sendBodyAndHeader("direct:wasm", 
"payload", "user", "mallory"))
+                .isInstanceOf(CamelExecutionException.class)
+                .hasCauseInstanceOf(CamelAuthorizationException.class);
+
+        allowed.assertIsSatisfied();
+    }
+
+    @Test
+    void registersOnlyTheRestPolicysReadinessCheck() {
+        HealthCheckRegistry registry = HealthCheckRegistry.get(context);
+        assertThat(registry).isNotNull();
+        List<HealthCheck> checks = registry.stream()
+                .filter(hc -> hc.getId().startsWith("security-policy:opa-"))
+                .toList();
+
+        // exactly one, and it is the rest policy's - the wasm policy 
evaluates in-process with no server to probe
+        assertThat(checks).hasSize(1);
+        assertThat(checks.get(0).getId()).contains("opa-rest");
+    }
+
+    @Test
+    void failsRouteStartOnABundleThatLoadsButIsNotAValidModule() {
+        // OpaWasmEvaluator borrows an instance at startup so a broken bundle 
fails fast, and beforeWrap - which cannot
+        // throw a checked exception - must surface that rather than swallow 
it, or a route would start and then
+        // authorize nothing. authz.rego is the Rego source: it loads as bytes 
but is not a compiled wasm module.
+        OpaSecurityPolicy corrupt = new OpaSecurityPolicy();
+        corrupt.setEvaluationMode("wasm");
+        corrupt.setPolicyBundle("classpath:authz.rego");
+        corrupt.setPolicyPath("authz/allow");
+
+        assertThatThrownBy(() -> context.addRoutes(new RouteBuilder() {
+            @Override
+            public void configure() {
+                from("direct:corrupt").policy(corrupt).to("mock:never");
+            }
+        })).isInstanceOf(Exception.class);

Review Comment:
   Strengthened in d4e205e. `context.addRoutes` wraps the `beforeWrap` failure 
in `FailedToCreateRouteException` (a `RuntimeCamelException`), so: the 
loads-but-invalid case now asserts `RuntimeException` thrown from `addRoutes` — 
which proves the route never started (a first-exchange failure would not 
surface there) — and I added 
`failsRouteStartWhenTheBundleResourceCannotBeLoaded`, which asserts the wrapper 
explicitly via 
`.isInstanceOf(RuntimeCamelException.class).hasMessageContaining("Could not 
load the wasm policy bundle")`.
   



##########
components/camel-opa/src/test/java/org/apache/camel/component/opa/security/OpaSecurityPolicyWasmTest.java:
##########
@@ -0,0 +1,115 @@
+/*
+ * 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.component.opa.security;
+
+import java.util.List;
+
+import org.apache.camel.CamelAuthorizationException;
+import org.apache.camel.CamelExecutionException;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.health.HealthCheck;
+import org.apache.camel.health.HealthCheckRegistry;
+import org.apache.camel.test.junit6.CamelTestSupport;
+import org.junit.jupiter.api.Test;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
+
+/**
+ * {@link OpaSecurityPolicy} enforcing a route with an in-process WebAssembly 
bundle. The decision contract is the same
+ * as the REST engine - a match proceeds, a non-match throws {@code 
CamelAuthorizationException} - and no server
+ * readiness check is registered, because the policy is evaluated in-process 
(CAMEL-24830).
+ */
+public class OpaSecurityPolicyWasmTest extends CamelTestSupport {
+
+    private final OpaSecurityPolicy wasmPolicy = new OpaSecurityPolicy();
+    private final OpaSecurityPolicy restPolicy = new OpaSecurityPolicy();
+
+    @Override
+    protected RouteBuilder createRouteBuilder() {
+        wasmPolicy.setEvaluationMode("wasm");
+        wasmPolicy.setPolicyBundle("classpath:authz.wasm");
+        wasmPolicy.setPolicyPath("authz/allow");
+
+        // a rest-mode policy is the positive control for the readiness-check 
assertion: it registers a check, the
+        // wasm one must not
+        restPolicy.setServerUrl("http://opa-rest:8181";);
+        restPolicy.setPolicyPath("authz/allow");
+
+        return new RouteBuilder() {
+            @Override
+            public void configure() {
+                from("direct:wasm").policy(wasmPolicy).to("mock:allowed");
+                from("direct:rest").policy(restPolicy).to("mock:rest");
+            }
+        };
+    }
+
+    @Test
+    void allowsWhenTheWasmPolicyMatches() throws Exception {
+        MockEndpoint allowed = getMockEndpoint("mock:allowed");
+        allowed.expectedMessageCount(1);
+
+        template.sendBodyAndHeader("direct:wasm", "payload", "user", "alice");
+
+        allowed.assertIsSatisfied();
+    }
+
+    @Test
+    void deniesWhenTheWasmPolicyDoesNotMatch() throws Exception {
+        MockEndpoint allowed = getMockEndpoint("mock:allowed");
+        allowed.expectedMessageCount(0);
+
+        assertThatThrownBy(() -> template.sendBodyAndHeader("direct:wasm", 
"payload", "user", "mallory"))
+                .isInstanceOf(CamelExecutionException.class)
+                .hasCauseInstanceOf(CamelAuthorizationException.class);
+
+        allowed.assertIsSatisfied();
+    }
+
+    @Test
+    void registersOnlyTheRestPolicysReadinessCheck() {
+        HealthCheckRegistry registry = HealthCheckRegistry.get(context);
+        assertThat(registry).isNotNull();
+        List<HealthCheck> checks = registry.stream()
+                .filter(hc -> hc.getId().startsWith("security-policy:opa-"))
+                .toList();
+
+        // exactly one, and it is the rest policy's - the wasm policy 
evaluates in-process with no server to probe
+        assertThat(checks).hasSize(1);
+        assertThat(checks.get(0).getId()).contains("opa-rest");

Review Comment:
   Addressed in d4e205e. The assertion now also checks the 
`security-policy:opa-` ID-contract prefix 
(`.startsWith("security-policy:opa-").contains("opa-rest")`), so a refactor of 
the ID-building logic in `OpaSecurityPolicyHealthCheck` can no longer pass here 
silently.
   



##########
components/camel-opa/src/test/java/org/apache/camel/component/opa/security/OpaSecurityPolicyWasmTest.java:
##########
@@ -0,0 +1,115 @@
+/*
+ * 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.component.opa.security;
+
+import java.util.List;
+
+import org.apache.camel.CamelAuthorizationException;
+import org.apache.camel.CamelExecutionException;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.health.HealthCheck;
+import org.apache.camel.health.HealthCheckRegistry;
+import org.apache.camel.test.junit6.CamelTestSupport;
+import org.junit.jupiter.api.Test;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
+
+/**
+ * {@link OpaSecurityPolicy} enforcing a route with an in-process WebAssembly 
bundle. The decision contract is the same
+ * as the REST engine - a match proceeds, a non-match throws {@code 
CamelAuthorizationException} - and no server
+ * readiness check is registered, because the policy is evaluated in-process 
(CAMEL-24830).
+ */
+public class OpaSecurityPolicyWasmTest extends CamelTestSupport {
+
+    private final OpaSecurityPolicy wasmPolicy = new OpaSecurityPolicy();
+    private final OpaSecurityPolicy restPolicy = new OpaSecurityPolicy();
+
+    @Override
+    protected RouteBuilder createRouteBuilder() {
+        wasmPolicy.setEvaluationMode("wasm");
+        wasmPolicy.setPolicyBundle("classpath:authz.wasm");
+        wasmPolicy.setPolicyPath("authz/allow");
+
+        // a rest-mode policy is the positive control for the readiness-check 
assertion: it registers a check, the
+        // wasm one must not
+        restPolicy.setServerUrl("http://opa-rest:8181";);
+        restPolicy.setPolicyPath("authz/allow");
+
+        return new RouteBuilder() {
+            @Override
+            public void configure() {
+                from("direct:wasm").policy(wasmPolicy).to("mock:allowed");
+                from("direct:rest").policy(restPolicy).to("mock:rest");

Review Comment:
   Addressed in d4e205e. Added tests that go through 
`OpaSecurityPolicy.buildEvaluator()` (its own entry point, separate from the 
endpoint's validation): `failsRouteStartOnAnUnknownEvaluationMode`, 
`failsRouteStartWhenNoWasmBundleIsConfigured`, and 
`failsRouteStartOnAPoolSizeBelowOne`, each asserting the root-cause 
`IllegalArgumentException` and its message.
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to