zhangshenghang commented on code in PR #9818: URL: https://github.com/apache/seatunnel/pull/9818#discussion_r2348252742
########## seatunnel-e2e/seatunnel-connector-v2-e2e/connector-paimon-e2e/src/test/java/org/apache/seatunnel/e2e/connector/paimon/PrivilegeUtil.java: ########## @@ -0,0 +1,67 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.seatunnel.e2e.connector.paimon; + +import org.apache.paimon.catalog.Identifier; +import org.apache.paimon.privilege.PrivilegeChecker; +import org.apache.paimon.privilege.PrivilegeType; +import org.apache.paimon.privilege.PrivilegedCatalog; + +import java.util.List; +import java.util.concurrent.TimeUnit; + +import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; +import static org.testcontainers.shaded.org.awaitility.Awaitility.await; + +public class PrivilegeUtil { + private PrivilegeUtil() {} + + public static void awaitPrivilegeApplied( + PrivilegedCatalog privilegedCatalog, + List<PrivilegeType> privilegeTypes, + List<Identifier> identifiers) { + PrivilegeChecker privilegeChecker = + privilegedCatalog.privilegeManager().getPrivilegeChecker(); + await().atMost(30, TimeUnit.SECONDS) + .untilAsserted( + () -> { + assertDoesNotThrow( + () -> { + for (PrivilegeType type : privilegeTypes) { + switch (type) { + case SELECT: + for (Identifier tableIdentifier : identifiers) { + privilegeChecker.assertCanSelect( + tableIdentifier); + } + break; + case INSERT: + for (Identifier tableIdentifier : identifiers) { + privilegeChecker.assertCanInsert( + tableIdentifier); + } + break; + default: Review Comment: > Currently, the tests only check for insert and select privileges. I thought it would be fine to add checks for other privileges when we introduce corresponding tests for them. What do you think? @dybyte Sure, but it would be better if we could improve it when adding methods. See your schedule. -- 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]
