roryqi commented on code in PR #13478:
URL: https://github.com/apache/gravitino/pull/13478#discussion_r4248026967


##########
core/src/test/java/org/apache/gravitino/policy/TestPolicyManager.java:
##########
@@ -483,6 +483,73 @@ public void testCreateUpdateAndGetRowFilterPolicy() {
     Assertions.assertEquals(updatedContent, updated.content());
     Assertions.assertEquals(
         updatedContent, policyManager.getPolicy(METALAKE, 
policyName).content());
+
+    Assertions.assertThrows(
+        IllegalArgumentException.class,
+        () ->
+            policyManager.createPolicy(
+                METALAKE,
+                "invalid_" + policyName,
+                Policy.BuiltInType.ROW_FILTER,
+                null,
+                true,
+                PolicyContents.rowFilter("filter := col(\"region\")")));
+    Assertions.assertThrows(
+        IllegalArgumentException.class,
+        () ->
+            policyManager.alterPolicy(
+                METALAKE,
+                policyName,
+                PolicyChange.updateContent(
+                    "system_row_filter",
+                    PolicyContents.rowFilter("mask := 
action(\"replace-with-null\")"))));
+    Assertions.assertEquals(
+        updatedContent, policyManager.getPolicy(METALAKE, 
policyName).content());
+  }
+
+  @Test
+  public void testCreateUpdateAndGetColumnMaskPolicy() {
+    String policyName = "column_mask_" + 
UUID.randomUUID().toString().replace("-", "");
+    PolicyContent originalContent = PolicyContents.columnMask("mask := 
action(\"show-last-4\")");
+
+    PolicyEntity created =
+        policyManager.createPolicy(
+            METALAKE, policyName, Policy.BuiltInType.COLUMN_MASK, null, true, 
originalContent);
+
+    Assertions.assertEquals(originalContent, created.content());
+    Assertions.assertEquals(
+        originalContent, policyManager.getPolicy(METALAKE, 
policyName).content());
+
+    PolicyContent updatedContent =
+        PolicyContents.columnMask("mask := action(\"replace-with-null\")");
+    PolicyEntity updated =
+        policyManager.alterPolicy(
+            METALAKE, policyName, 
PolicyChange.updateContent("system_column_mask", updatedContent));
+
+    Assertions.assertEquals(updatedContent, updated.content());
+    Assertions.assertEquals(
+        updatedContent, policyManager.getPolicy(METALAKE, 
policyName).content());
+
+    Assertions.assertThrows(
+        IllegalArgumentException.class,
+        () ->
+            policyManager.createPolicy(
+                METALAKE,
+                "invalid_" + policyName,
+                Policy.BuiltInType.COLUMN_MASK,
+                null,
+                true,
+                PolicyContents.columnMask("mask := action(\"unknown\")")));
+    Assertions.assertThrows(
+        IllegalArgumentException.class,
+        () ->
+            policyManager.alterPolicy(
+                METALAKE,
+                policyName,
+                PolicyChange.updateContent(
+                    "system_column_mask", PolicyContents.columnMask("filter := 
true"))));
+    Assertions.assertEquals(
+        updatedContent, policyManager.getPolicy(METALAKE, 
policyName).content());
   }
 
   @Test

Review Comment:
   Addressed in 4c6b5b178d. The former monolithic parser test was split by 
production responsibility: facade, lexer, source parser, source validator, 
program lowering, and golden/docs tests now have dedicated classes. The 
extracted AST implementations also have focused tests for `Column`, 
`SessionUser`, `GroupMembership`, `Literal`, `LiteralArray`, `Comparison`, 
`ComparisonOperator`, `Not`, and `LogicalExpression`. Existing parser coverage 
was retained, direct unit coverage was added for the split internals, and the 
complete restricted-Rego suite plus `TestPolicyManager` passes.



-- 
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