This is an automated email from the ASF dual-hosted git repository.
jialiang pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/ambari.git
The following commit(s) were added to refs/heads/trunk by this push:
new c09bcdefcc AMBARI-26138 : Fix the Ambari java test failures related to
TestUsers (#3832)
c09bcdefcc is described below
commit c09bcdefcc528ca4ff4b7e84fa0dc4eeba87ea6e
Author: Himanshu Maurya <[email protected]>
AuthorDate: Fri Sep 20 12:35:23 2024 +0530
AMBARI-26138 : Fix the Ambari java test failures related to TestUsers
(#3832)
---
.../server/security/authorization/TestUsers.java | 44 +++++++++++-----------
1 file changed, 22 insertions(+), 22 deletions(-)
diff --git
a/ambari-server/src/test/java/org/apache/ambari/server/security/authorization/TestUsers.java
b/ambari-server/src/test/java/org/apache/ambari/server/security/authorization/TestUsers.java
index da47027efa..b392cdd7f9 100644
---
a/ambari-server/src/test/java/org/apache/ambari/server/security/authorization/TestUsers.java
+++
b/ambari-server/src/test/java/org/apache/ambari/server/security/authorization/TestUsers.java
@@ -170,12 +170,12 @@ public class TestUsers {
userEntity = users.createUser("admin", "admin", "admin");
users.grantAdminPrivilege(userEntity);
- users.addLocalAuthentication(userEntity, "admin");
+ users.addLocalAuthentication(userEntity, "test_password");
setAuthenticatedUser(userEntity);
userEntity = users.createUser("user", "user", "user");
- users.addLocalAuthentication(userEntity, "user");
+ users.addLocalAuthentication(userEntity, "test_password");
UserEntity foundUserEntity = userDAO.findUserByName("user");
assertNotNull(foundUserEntity);
@@ -183,18 +183,18 @@ public class TestUsers {
UserAuthenticationEntity foundLocalAuthenticationEntity;
foundLocalAuthenticationEntity = getAuthenticationEntity(foundUserEntity,
UserAuthenticationType.LOCAL);
assertNotNull(foundLocalAuthenticationEntity);
- assertNotSame("user",
foundLocalAuthenticationEntity.getAuthenticationKey());
- assertTrue(passwordEncoder.matches("user",
foundLocalAuthenticationEntity.getAuthenticationKey()));
+ assertNotSame("test_password",
foundLocalAuthenticationEntity.getAuthenticationKey());
+ assertTrue(passwordEncoder.matches("test_password",
foundLocalAuthenticationEntity.getAuthenticationKey()));
foundUserEntity = userDAO.findUserByName("admin");
assertNotNull(foundUserEntity);
- users.modifyAuthentication(foundLocalAuthenticationEntity, "admin",
"user_new_password", false);
+ users.modifyAuthentication(foundLocalAuthenticationEntity,
"test_password", "new_test_password", false);
foundUserEntity = userDAO.findUserByName("user");
assertNotNull(foundUserEntity);
foundLocalAuthenticationEntity = getAuthenticationEntity(foundUserEntity,
UserAuthenticationType.LOCAL);
assertNotNull(foundLocalAuthenticationEntity);
- assertTrue(passwordEncoder.matches("user_new_password",
foundLocalAuthenticationEntity.getAuthenticationKey()));
+ assertTrue(passwordEncoder.matches("new_test_password",
foundLocalAuthenticationEntity.getAuthenticationKey()));
}
@Test
@@ -202,7 +202,7 @@ public class TestUsers {
UserEntity userEntity;
userEntity = users.createUser("user", "user", "user");
- users.addLocalAuthentication(userEntity, "user");
+ users.addLocalAuthentication(userEntity, "test_password");
UserEntity foundUserEntity = userDAO.findUserByName("user");
assertNotNull(foundUserEntity);
@@ -210,18 +210,18 @@ public class TestUsers {
UserAuthenticationEntity foundLocalAuthenticationEntity;
foundLocalAuthenticationEntity = getAuthenticationEntity(foundUserEntity,
UserAuthenticationType.LOCAL);
assertNotNull(foundLocalAuthenticationEntity);
- assertNotSame("user",
foundLocalAuthenticationEntity.getAuthenticationKey());
- assertTrue(passwordEncoder.matches("user",
foundLocalAuthenticationEntity.getAuthenticationKey()));
+ assertNotSame("test_password",
foundLocalAuthenticationEntity.getAuthenticationKey());
+ assertTrue(passwordEncoder.matches("test_password",
foundLocalAuthenticationEntity.getAuthenticationKey()));
try {
- users.modifyAuthentication(foundLocalAuthenticationEntity, "user", null,
true);
+ users.modifyAuthentication(foundLocalAuthenticationEntity,
"test_password", null, true);
fail("Null password should not be allowed");
} catch (IllegalArgumentException e) {
assertEquals("The password does not meet the password policy
requirements", e.getLocalizedMessage());
}
try {
- users.modifyAuthentication(foundLocalAuthenticationEntity, "user", "",
false);
+ users.modifyAuthentication(foundLocalAuthenticationEntity,
"test_password", "", false);
fail("Empty password should not be allowed");
} catch (IllegalArgumentException e) {
assertEquals("The password does not meet the password policy
requirements", e.getLocalizedMessage());
@@ -231,12 +231,12 @@ public class TestUsers {
configuration.setProperty(Configuration.PASSWORD_POLICY_REGEXP,
"^(?=.*[A-Za-z])(?=.*\\d)[A-Za-z\\d]{8,}$");
configuration.setProperty(Configuration.PASSWORD_POLICY_DESCRIPTION, "test
description");
try {
- users.modifyAuthentication(foundLocalAuthenticationEntity, "user",
"abc123", false);
+ users.modifyAuthentication(foundLocalAuthenticationEntity,
"test_password", "abc123", false);
fail("Should not pass validation");
} catch (IllegalArgumentException e) {
assertEquals("The password does not meet the Ambari user password policy
: test description", e.getLocalizedMessage());
}
- users.modifyAuthentication(foundLocalAuthenticationEntity, "user",
"abcd1234", false);
+ users.modifyAuthentication(foundLocalAuthenticationEntity,
"test_password", "abcd1234", false);
}
@Test
@@ -453,37 +453,37 @@ public class TestUsers {
@Test
public void testModifyPassword_UserByHimselfPasswordOk() throws Exception {
UserEntity userEntity = users.createUser("user", "user", null);
- users.addLocalAuthentication(userEntity, "user");
+ users.addLocalAuthentication(userEntity, "test_password");
userEntity = userDAO.findUserByName("user");
UserAuthenticationEntity localAuthenticationEntity =
getAuthenticationEntity(userEntity, UserAuthenticationType.LOCAL);
assertNotNull(localAuthenticationEntity);
- assertNotSame("user", localAuthenticationEntity.getAuthenticationKey());
- assertTrue(passwordEncoder.matches("user",
localAuthenticationEntity.getAuthenticationKey()));
+ assertNotSame("test_password",
localAuthenticationEntity.getAuthenticationKey());
+ assertTrue(passwordEncoder.matches("test_password",
localAuthenticationEntity.getAuthenticationKey()));
- users.modifyAuthentication(localAuthenticationEntity, "user",
"user_new_password", true);
+ users.modifyAuthentication(localAuthenticationEntity, "test_password",
"new_test_password", true);
userEntity = userDAO.findUserByName("user");
localAuthenticationEntity = getAuthenticationEntity(userEntity,
UserAuthenticationType.LOCAL);
assertNotNull(localAuthenticationEntity);
- assertTrue(passwordEncoder.matches("user_new_password",
localAuthenticationEntity.getAuthenticationKey()));
+ assertTrue(passwordEncoder.matches("new_test_password",
localAuthenticationEntity.getAuthenticationKey()));
}
@Test
public void testModifyPassword_UserByHimselfPasswordNotOk() throws Exception
{
UserEntity userEntity = users.createUser("user", "user", null);
- users.addLocalAuthentication(userEntity, "user");
+ users.addLocalAuthentication(userEntity, "test_password");
userEntity = userDAO.findUserByName("user");
UserAuthenticationEntity foundLocalAuthenticationEntity;
foundLocalAuthenticationEntity = getAuthenticationEntity(userEntity,
UserAuthenticationType.LOCAL);
assertNotNull(foundLocalAuthenticationEntity);
- assertNotSame("user",
foundLocalAuthenticationEntity.getAuthenticationKey());
- assertTrue(passwordEncoder.matches("user",
foundLocalAuthenticationEntity.getAuthenticationKey()));
+ assertNotSame("test_password",
foundLocalAuthenticationEntity.getAuthenticationKey());
+ assertTrue(passwordEncoder.matches("test_password",
foundLocalAuthenticationEntity.getAuthenticationKey()));
try {
- users.modifyAuthentication(foundLocalAuthenticationEntity, "admin",
"user_new_password", true);
+ users.modifyAuthentication(foundLocalAuthenticationEntity,
"incorrect_test_password", "new_test_password", true);
fail("Exception should be thrown here as password is incorrect");
} catch (AmbariException ex) {
// This is expected
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]