adnanhemani commented on code in PR #1665:
URL: https://github.com/apache/polaris/pull/1665#discussion_r2110184952
##########
integration-tests/src/main/java/org/apache/polaris/service/it/test/PolarisPolicyServiceIntegrationTest.java:
##########
@@ -417,6 +607,74 @@ public void testListPolicies() {
policyApi.dropPolicy(currentCatalogName, NS1_P2);
}
+ @Test
+ public void testListPoliciesOnNonExistingNamespace() {
+ try (Response res =
+ policyApi
+ .request(
+ "polaris/v1/{cat}/namespaces/{ns}/policies",
+ Map.of("cat", currentCatalogName, "ns", INVALID_NAMESPACE))
+ .get()) {
+
Assertions.assertThat(res.getStatus()).isEqualTo(Response.Status.NOT_FOUND.getStatusCode());
+
Assertions.assertThat(res.readEntity(String.class)).contains(INVALID_NAMESPACE_MSG);
+ }
+ }
+
+ @Test
+ public void testGetApplicablePoliciesOnNonExistingNamespace() {
+ try (Response res =
+ policyApi
+ .request(
+ "polaris/v1/{cat}/applicable-policies",
+ Map.of("cat", currentCatalogName),
+ Map.of("namespace", INVALID_NAMESPACE))
+ .get()) {
+
Assertions.assertThat(res.getStatus()).isEqualTo(Response.Status.NOT_FOUND.getStatusCode());
+
Assertions.assertThat(res.readEntity(String.class)).contains(INVALID_NAMESPACE_MSG);
+ }
+ }
+
+ @Test
+ public void testGetApplicablePoliciesOnNonExistingTable() {
+ restCatalog.createNamespace(NS1);
+ policyApi.createPolicy(
+ currentCatalogName,
+ NS1_P1,
+ PredefinedPolicyTypes.DATA_COMPACTION,
+ EXAMPLE_TABLE_MAINTENANCE_POLICY_CONTENT,
+ "test policy");
+ try (Response res =
+ policyApi
+ .request(
+ "polaris/v1/{cat}/applicable-policies",
+ Map.of("cat", currentCatalogName),
+ Map.of("namespace", RESTUtil.encodeNamespace(NS1),
"target-name", "INVALID_TABLE"))
+ .get()) {
+
Assertions.assertThat(res.getStatus()).isEqualTo(Response.Status.NOT_FOUND.getStatusCode());
+ Assertions.assertThat(res.readEntity(String.class))
+ .contains("Table does not exist: NS1.INVALID_TABLE");
+ }
+ policyApi.dropPolicy(currentCatalogName, NS1_P1);
+ }
+
+ @Test
+ public void testLoadNonExistingPolicy() {
+ restCatalog.createNamespace(NS1);
+ try (Response res =
+ policyApi
+ .request(
+ "polaris/v1/{cat}/namespaces/{ns}/policies/{policy}",
+ Map.of("cat", currentCatalogName, "ns", "NS1", "policy",
INVALID_POLICY))
Review Comment:
nit: This is similar to the comment I left earlier - ideally we should not
have "magic strings" anywhere in the tests either.
So instead of using "NS1", we should be using variable `NS1` and in all
locations instead of using `NS1` inline on the assertion, make the string into
`"namespace: " + NS1` (and substitute all other locations of this, as required).
--
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]