This is an automated email from the ASF dual-hosted git repository.

panjuan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git


The following commit(s) were added to refs/heads/master by this push:
     new 22a37bb  10902 - unit test for all privileges authority algorithm 
class (#11152)
22a37bb is described below

commit 22a37bbbf7abe487c4de6ab1d48db3e9413d6f12
Author: Siva Tharun Kola <[email protected]>
AuthorDate: Thu Jul 22 12:50:10 2021 +0530

    10902 - unit test for all privileges authority algorithm class (#11152)
    
    * 10902 - unit test for all privileges authority algorithm class
    
    - added final access specifier for 
AllPrivilegesPermittedShardingSpherePrivileges class
    - added unit tests for all privileges authority algorithm class
    
    * 10902 - addressed checkstyle issues
    
    - addressed the checkstyle issues for method formatting
    
    * 10902 - addressed checkstyle issues
    
    * 10902 - added license for AllPrivilegesProviderAlgorithmTest class
    
    * 10902 -addressed review comments
    
    - marked the AllPrivilegesProviderAlgorithmTest class as final
---
 ...vilegesPermittedAuthorityProviderAlgorithm.java |  2 +-
 .../simple/AllPrivilegesProviderAlgorithmTest.java | 43 ++++++++++++++++++++++
 2 files changed, 44 insertions(+), 1 deletion(-)

diff --git 
a/shardingsphere-infra/shardingsphere-infra-authority/shardingsphere-infra-authority-common/src/main/java/org/apache/shardingsphere/authority/provider/simple/AllPrivilegesPermittedAuthorityProviderAlgorithm.java
 
b/shardingsphere-infra/shardingsphere-infra-authority/shardingsphere-infra-authority-common/src/main/java/org/apache/shardingsphere/authority/provider/simple/AllPrivilegesPermittedAuthorityProviderAlgorithm.java
index 14e0c11..81d79ea 100644
--- 
a/shardingsphere-infra/shardingsphere-infra-authority/shardingsphere-infra-authority-common/src/main/java/org/apache/shardingsphere/authority/provider/simple/AllPrivilegesPermittedAuthorityProviderAlgorithm.java
+++ 
b/shardingsphere-infra/shardingsphere-infra-authority/shardingsphere-infra-authority-common/src/main/java/org/apache/shardingsphere/authority/provider/simple/AllPrivilegesPermittedAuthorityProviderAlgorithm.java
@@ -54,7 +54,7 @@ public final class 
AllPrivilegesPermittedAuthorityProviderAlgorithm implements A
         return "ALL_PRIVILEGES_PERMITTED";
     }
     
-    private static class AllPrivilegesPermittedShardingSpherePrivileges 
implements ShardingSpherePrivileges {
+    private static final class AllPrivilegesPermittedShardingSpherePrivileges 
implements ShardingSpherePrivileges {
     
         @Override
         public void setSuperPrivilege() {
diff --git 
a/shardingsphere-infra/shardingsphere-infra-authority/shardingsphere-infra-authority-common/src/test/java/org/apache/shardingsphere/authority/provider/simple/AllPrivilegesProviderAlgorithmTest.java
 
b/shardingsphere-infra/shardingsphere-infra-authority/shardingsphere-infra-authority-common/src/test/java/org/apache/shardingsphere/authority/provider/simple/AllPrivilegesProviderAlgorithmTest.java
new file mode 100644
index 0000000..2112a0b
--- /dev/null
+++ 
b/shardingsphere-infra/shardingsphere-infra-authority/shardingsphere-infra-authority-common/src/test/java/org/apache/shardingsphere/authority/provider/simple/AllPrivilegesProviderAlgorithmTest.java
@@ -0,0 +1,43 @@
+/*
+ * 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.shardingsphere.authority.provider.simple;
+
+import java.util.Collections;
+import java.util.Optional;
+import org.apache.shardingsphere.authority.model.ShardingSpherePrivileges;
+import 
org.apache.shardingsphere.authority.provider.natived.model.subject.SchemaAccessSubject;
+import org.apache.shardingsphere.infra.metadata.user.Grantee;
+import org.junit.Test;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+public final class AllPrivilegesProviderAlgorithmTest {
+
+    @Test
+    public void assertFindPrivileges() {
+        AllPrivilegesPermittedAuthorityProviderAlgorithm 
authorityProviderAlgorithm = new 
AllPrivilegesPermittedAuthorityProviderAlgorithm();
+        Optional<ShardingSpherePrivileges> shardingSpherePrivilegesOptional = 
authorityProviderAlgorithm
+            .findPrivileges(new Grantee("TestUser", "testHost"));
+        assertNotNull(shardingSpherePrivilegesOptional.get());
+        
assertTrue(shardingSpherePrivilegesOptional.get().hasPrivileges("testSchema"));
+        
assertTrue(shardingSpherePrivilegesOptional.get().hasPrivileges(Collections.emptyList()));
+        assertTrue(shardingSpherePrivilegesOptional.get()
+            .hasPrivileges(new SchemaAccessSubject("testSchema"), 
Collections.emptyList()));
+    }
+}

Reply via email to