You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by du...@apache.org on 2021/02/02 11:35:27 UTC
[shardingsphere] branch master updated: Review function names
(#9277)
This is an automated email from the ASF dual-hosted git repository.
duanzhengqiang 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 28e984e Review function names (#9277)
28e984e is described below
commit 28e984ece083c0d0da5c4b29184ab2968784f8d0
Author: Juan Pan(Trista) <pa...@apache.org>
AuthorDate: Tue Feb 2 19:35:09 2021 +0800
Review function names (#9277)
---
.../infra/auth/builtin/DefaultAuthentication.java | 15 +++++----------
.../impl/StandardBootstrapInitializerTest.java | 4 ++--
.../yaml/swapper/YamlProxyConfigurationSwapperTest.java | 6 +++---
3 files changed, 10 insertions(+), 15 deletions(-)
diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/auth/builtin/DefaultAuthentication.java b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/auth/builtin/DefaultAuthentication.java
index 107d644..dff6187 100644
--- a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/auth/builtin/DefaultAuthentication.java
+++ b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/auth/builtin/DefaultAuthentication.java
@@ -23,12 +23,9 @@ import lombok.NoArgsConstructor;
import org.apache.shardingsphere.infra.auth.Authentication;
import org.apache.shardingsphere.infra.auth.Grantee;
import org.apache.shardingsphere.infra.auth.ShardingSphereUser;
-import org.apache.shardingsphere.infra.auth.privilege.PrivilegeType;
import org.apache.shardingsphere.infra.auth.privilege.ShardingSpherePrivilege;
-import org.apache.shardingsphere.infra.auth.privilege.TablePrivilege;
import java.util.Collection;
-import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Optional;
@@ -40,30 +37,28 @@ import java.util.Optional;
@Getter
public final class DefaultAuthentication implements Authentication {
- private final Map<ShardingSphereUser, ShardingSpherePrivilege> auth = new LinkedHashMap<>();
+ private final Map<ShardingSphereUser, ShardingSpherePrivilege> authentication = new LinkedHashMap<>();
public DefaultAuthentication(final Collection<ShardingSphereUser> users) {
for (ShardingSphereUser each : users) {
- auth.put(each, createShardingSpherePrivilege());
+ authentication.put(each, createShardingSpherePrivilege());
}
}
private ShardingSpherePrivilege createShardingSpherePrivilege() {
ShardingSpherePrivilege result = new ShardingSpherePrivilege();
- result.getInstancePrivilege().getPrivileges().add(PrivilegeType.ALL);
- result.getSchemaPrivilege().getTablePrivileges().put(PrivilegeType.ALL.getName(),
- new TablePrivilege(PrivilegeType.ALL.getName(), Collections.singleton(PrivilegeType.ALL)));
+ result.setSuper();
return result;
}
@Override
public Optional<ShardingSphereUser> findUser(final Grantee grantee) {
- return auth.keySet().stream().filter(each -> each.getUsername().equals(grantee.getUsername())
+ return authentication.keySet().stream().filter(each -> each.getUsername().equals(grantee.getUsername())
&& (each.getHostname().equals(grantee.getHostname()) || Strings.isNullOrEmpty(each.getHostname()))).findFirst();
}
@Override
public Optional<ShardingSpherePrivilege> findPrivilege(final Grantee grantee) {
- return findUser(grantee).map(auth::get);
+ return findUser(grantee).map(authentication::get);
}
}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-bootstrap/src/test/java/org/apache/shardingsphere/proxy/initializer/impl/StandardBootstrapInitializerTest.java b/shardingsphere-proxy/shardingsphere-proxy-bootstrap/src/test/java/org/apache/shardingsphere/proxy/initializer/impl/StandardBootstrapInitializerTest.java
index 2fbd45c..9c1dc64 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-bootstrap/src/test/java/org/apache/shardingsphere/proxy/initializer/impl/StandardBootstrapInitializerTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-bootstrap/src/test/java/org/apache/shardingsphere/proxy/initializer/impl/StandardBootstrapInitializerTest.java
@@ -159,7 +159,7 @@ public final class StandardBootstrapInitializerTest extends AbstractBootstrapIni
private YamlProxyServerConfiguration createYamlProxyServerConfiguration() {
YamlProxyServerConfiguration result = new YamlProxyServerConfiguration();
- result.setAuthentication(createYamlAuthenticationConfiguration());
+ result.setAuthentication(createYamlUserRuleConfiguration());
result.setProps(createProperties());
return result;
}
@@ -171,7 +171,7 @@ public final class StandardBootstrapInitializerTest extends AbstractBootstrapIni
return result;
}
- private YamlUserRuleConfiguration createYamlAuthenticationConfiguration() {
+ private YamlUserRuleConfiguration createYamlUserRuleConfiguration() {
Map<String, YamlUserConfiguration> users = new HashMap<>(1, 1);
users.put("root", createYamlUserConfiguration());
YamlUserRuleConfiguration result = new YamlUserRuleConfiguration();
diff --git a/shardingsphere-proxy/shardingsphere-proxy-common/src/test/java/org/apache/shardingsphere/proxy/config/yaml/swapper/YamlProxyConfigurationSwapperTest.java b/shardingsphere-proxy/shardingsphere-proxy-common/src/test/java/org/apache/shardingsphere/proxy/config/yaml/swapper/YamlProxyConfigurationSwapperTest.java
index 1dbc500..04e219e 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-common/src/test/java/org/apache/shardingsphere/proxy/config/yaml/swapper/YamlProxyConfigurationSwapperTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-common/src/test/java/org/apache/shardingsphere/proxy/config/yaml/swapper/YamlProxyConfigurationSwapperTest.java
@@ -219,9 +219,9 @@ public final class YamlProxyConfigurationSwapperTest {
when(yamlUserConfig.getPassword()).thenReturn("pass");
when(yamlUserConfig.getAuthorizedSchemas()).thenReturn("db1");
yamlUserConfigurationMap.put("user1", yamlUserConfig);
- YamlUserRuleConfiguration yamlAuthenticationConfig = mock(YamlUserRuleConfiguration.class);
- when(yamlAuthenticationConfig.getUsers()).thenReturn(yamlUserConfigurationMap);
- when(yamlProxyServerConfig.getAuthentication()).thenReturn(yamlAuthenticationConfig);
+ YamlUserRuleConfiguration userRuleConfiguration = mock(YamlUserRuleConfiguration.class);
+ when(userRuleConfiguration.getUsers()).thenReturn(yamlUserConfigurationMap);
+ when(yamlProxyServerConfig.getAuthentication()).thenReturn(userRuleConfiguration);
}
private YamlProxyServerConfiguration getYamlProxyServerConfiguration(final YamlProxyConfiguration yamlProxyConfig) {