Skip to content

Commit c0901b6

Browse files
test: changed test approach for mockito v3 - use getLdapManager instead of field
1 parent 2de1e89 commit c0901b6

2 files changed

Lines changed: 4 additions & 4 deletions

File tree

fe/fe-core/src/main/java/org/apache/doris/mysql/privilege/Auth.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -227,17 +227,17 @@ public Set<String> getRolesByUser(UserIdentity user, boolean showUserDefaultRole
227227
public void checkPlainPassword(String remoteUser, String remoteHost, String remotePasswd,
228228
List<UserIdentity> currentUser) throws AuthenticationException {
229229
// Check the LDAP password when the user exists in the LDAP service.
230-
if (ldapManager.doesUserExist(remoteUser)) {
230+
if (getLdapManager().doesUserExist(remoteUser)) {
231231
//not allow to login in case when empty password is specified but such mode is disabled by configuration
232232
if (Strings.isNullOrEmpty(remotePasswd) && !LdapConfig.ldap_allow_empty_pass) {
233233
LOG.info("empty pass branch was activated: for user {}, pass {}, mode {}",
234234
remoteUser, remotePasswd, LdapConfig.ldap_allow_empty_pass);
235235
throw new AuthenticationException(ErrorCode.ERR_EMPTY_PASSWORD, remoteUser + "@" + remoteHost);
236236
}
237237

238-
if (!ldapManager.checkUserPasswd(remoteUser, remotePasswd, remoteHost, currentUser)) {
238+
if (!getLdapManager().checkUserPasswd(remoteUser, remotePasswd, remoteHost, currentUser)) {
239239
throw new AuthenticationException(ErrorCode.ERR_ACCESS_DENIED_ERROR,
240-
remoteUser + "@" + remoteHost + "[" + remotePasswd + "]",
240+
remoteUser + "@" + remoteHost + " via LDAP",
241241
Strings.isNullOrEmpty(remotePasswd) ? "NO" : "YES");
242242
}
243243
} else {

fe/fe-core/src/test/java/org/apache/doris/mysql/privilege/PlainAuthWithEmptyPasswordAndLdapTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public void testPlainPasswordAuthWithAllowEmptyPassTrue() throws Exception {
7272

7373
//non empty pass - success
7474
Assertions.assertTrue(LdapConfig.ldap_allow_empty_pass);
75-
Env.getCurrentEnv().getAuth().checkPlainPassword("user2.2", IP, "testPass", null);
75+
Env.getCurrentEnv().getAuth().checkPlainPassword("user2.2", IP, "testPass", null);
7676
//empty pass - success
7777
Assertions.assertTrue(LdapConfig.ldap_allow_empty_pass);
7878
Env.getCurrentEnv().getAuth().checkPlainPassword("user2.1", IP, "", null);

0 commit comments

Comments
 (0)