nastra commented on code in PR #18665:
URL: https://github.com/apache/iceberg/pull/18665#discussion_r4456204596
##########
core/src/test/java/org/apache/iceberg/rest/TestRESTCatalog.java:
##########
@@ -2834,6 +2835,71 @@ protected <T extends RESTResponse> T execute(
});
}
+ private RESTCatalog catalogWithViewRequestsForbidden() {
+ RESTCatalogAdapter adapter =
+ new RESTCatalogAdapter(backendCatalog) {
+ @Override
+ protected <T extends RESTResponse> T execute(
+ HTTPRequest request,
+ Class<T> responseType,
+ Consumer<ErrorResponse> errorHandler,
+ Consumer<Map<String, String>> responseHeaders) {
+ if (request.path().equals(RESOURCE_PATHS.view(TABLE))) {
+ errorHandler.accept(
+
ErrorResponse.builder().responseCode(403).withMessage("Forbidden").build());
+ throw new IllegalStateException("Error handler should have
thrown");
+ }
+
+ return super.execute(request, responseType, errorHandler,
responseHeaders);
+ }
+ };
+
+ RESTCatalog catalog = catalog(adapter);
+ if (requiresNamespaceCreate()) {
+ catalog.createNamespace(TABLE.namespace());
+ }
+
+ return catalog;
+ }
+
+ @Test
+ public void replaceTransactionWithoutViewPermissions() {
+ RESTCatalog catalog = catalogWithViewRequestsForbidden();
+ catalog.buildTable(TABLE, OTHER_SCHEMA).create();
+
+ catalog.buildTable(TABLE, SCHEMA).replaceTransaction().commitTransaction();
+
+
assertThat(catalog.loadTable(TABLE).schema().asStruct()).isEqualTo(REPLACE_SCHEMA.asStruct());
+ }
+
+ @Test
+ public void createOrReplaceTransactionWithoutViewPermissions() {
Review Comment:
can we move those all into TestRESTViewCatalog?
##########
core/src/main/java/org/apache/iceberg/rest/RESTSessionCatalog.java:
##########
@@ -1249,6 +1257,17 @@ public Transaction createOrReplaceTransaction() {
}
}
+ private boolean viewExistsIfPermitted(
+ SessionContext sessionContext, TableIdentifier identifier) {
+ try {
+ return viewExists(sessionContext, identifier);
+ } catch (ForbiddenException e) {
Review Comment:
what about catching `NotAuthorizedException`?
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]