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


##########
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());

Review Comment:
   Follow-up in 48cd060de3: upgraded the fixture table to a true golden-file 
test. The input case list now produces exact complete AST or complete error 
output, compared byte-for-byte with restricted-rego-v1-cases.golden. 
Intentional updates can be regenerated with 
GRAVITINO_UPDATE_RESTRICTED_REGO_GOLDEN=true.



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