You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@polaris.apache.org by "dimas-b (via GitHub) via issues" <is...@polaris.apache.org> on 2026/10/30 22:32:31 UTC

Re: [PR] OPA: add operator-defined static properties to the authorization input context [polaris]

dimas-b commented on code in PR #5925:
URL: https://github.com/apache/polaris/pull/5925#discussion_r4429023647


##########
extensions/auth/opa/src/test/java/org/apache/polaris/extension/auth/opa/OpaPolarisAuthorizerFactoryTest.java:
##########
@@ -252,6 +253,72 @@ public void testFactoryPassesRealmToAuthorizerContext() throws Exception {
     }
   }
 
+  @Test
+  public void testFactoryPassesContextPropertiesToAuthorizerContext() throws Exception {
+    final String[] capturedRequestBody = new String[1];
+
+    HttpServer server = createServerWithRequestCapture(capturedRequestBody);
+    try {
+      OpaAuthorizationConfig opaConfig =
+          ImmutableOpaAuthorizationConfig.builder()
+              .policyUri(
+                  URI.create(
+                      "http://localhost:"
+                          + server.getAddress().getPort()
+                          + "/v1/data/polaris/allow"))
+              .contextProperties(Map.of("group", "example-group", "tier", "qa"))
+              .auth(
+                  ImmutableAuthenticationConfig.builder()
+                      .type(OpaAuthorizationConfig.AuthenticationType.NONE)
+                      .build())
+              .http(
+                  ImmutableHttpConfig.builder()
+                      .timeout(Duration.ofSeconds(2))
+                      .verifySsl(true)
+                      .build())
+              .build();
+
+      try (JavaPoolAsyncExec asyncExec = new JavaPoolAsyncExec()) {
+        OpaPolarisAuthorizerFactory factory =
+            new OpaPolarisAuthorizerFactory(
+                opaConfig, Clock.systemUTC(), asyncExec, () -> null, () -> "test-realm");
+
+        factory.initialize();
+        OpaPolarisAuthorizer authorizer =
+            (OpaPolarisAuthorizer) factory.create(mock(RealmConfig.class));
+
+        PolarisPrincipal principal =
+            PolarisPrincipal.of("alice", AttributeMap.EMPTY, Set.of("admin"));
+        assertThatNoException()
+            .isThrownBy(

Review Comment:
   This is a bit hard to read. Why not just execute the lambda body directly? Any exception fails the test anyway.



-- 
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: issues-unsubscribe@polaris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org