This is an automated email from the ASF dual-hosted git repository.
pfzhan pushed a commit to branch kylin5
in repository https://gitbox.apache.org/repos/asf/kylin.git
The following commit(s) were added to refs/heads/kylin5 by this push:
new b11c5de8e5 KYLIN-6029 Ensure reset password successfully (#2278)
b11c5de8e5 is described below
commit b11c5de8e53b18f7c9b86c461dd04e8bfd0d46ab
Author: Guoliang Sun <[email protected]>
AuthorDate: Tue Feb 25 14:31:38 2025 +0800
KYLIN-6029 Ensure reset password successfully (#2278)
Co-authored-by: 夏旭晨 <[email protected]>
Co-authored-by: xuchen.xia <[email protected]>
---
.../apache/kylin/tool/security/KylinPasswordResetCLI.java | 4 ++--
.../kylin/tool/security/KylinPasswordResetCLITest.java | 14 +++++++++++---
2 files changed, 13 insertions(+), 5 deletions(-)
diff --git
a/src/tool/src/main/java/org/apache/kylin/tool/security/KylinPasswordResetCLI.java
b/src/tool/src/main/java/org/apache/kylin/tool/security/KylinPasswordResetCLI.java
index fb451970b8..fbd4e6b3fb 100644
---
a/src/tool/src/main/java/org/apache/kylin/tool/security/KylinPasswordResetCLI.java
+++
b/src/tool/src/main/java/org/apache/kylin/tool/security/KylinPasswordResetCLI.java
@@ -79,8 +79,8 @@ public class KylinPasswordResetCLI {
UnitOfWork.doInTransactionWithRetry(() -> {
KylinConfig conf = KylinConfig.getInstanceFromEnv();
NKylinUserManager.getInstance(conf).updateUser("ADMIN",
copyForWrite -> {
- user.setPassword(pwdEncoder.encode(password));
- user.setDefaultPassword(true);
+ copyForWrite.setPassword(pwdEncoder.encode(password));
+ copyForWrite.setDefaultPassword(true);
});
return true;
}, UnitOfWork.GLOBAL_UNIT);
diff --git
a/src/tool/src/test/java/org/apache/kylin/tool/security/KylinPasswordResetCLITest.java
b/src/tool/src/test/java/org/apache/kylin/tool/security/KylinPasswordResetCLITest.java
index a7aaa5fb76..ca127ee58f 100644
---
a/src/tool/src/test/java/org/apache/kylin/tool/security/KylinPasswordResetCLITest.java
+++
b/src/tool/src/test/java/org/apache/kylin/tool/security/KylinPasswordResetCLITest.java
@@ -99,7 +99,7 @@ public class KylinPasswordResetCLITest extends
LogOutputTestCase {
ResourceStore.clearCache(config);
config.clearManagers();
val afterManager = NKylinUserManager.getInstance(config);
-
+ Assert.assertFalse(pwdEncoder.matches("KYLIN2",
afterManager.get(user.getUsername()).getPassword()));
Assert.assertFalse(pwdEncoder.matches("KYLIN",
afterManager.get(user.getUsername()).getPassword()));
Assert.assertTrue(output.toString(Charset.defaultCharset().name()).startsWith("The
metadata backup path is"));
Assert.assertTrue(output.toString(Charset.defaultCharset().name())
@@ -107,13 +107,21 @@ public class KylinPasswordResetCLITest extends
LogOutputTestCase {
+ StringConstant.ANSI_RED + "] succeed. The password
is "));
Assert.assertTrue(output.toString(Charset.defaultCharset().name())
.endsWith("Please keep the password properly." +
StringConstant.ANSI_RESET + "\n"));
-
val url = getTestConfig().getMetadataUrl();
val jdbcTemplate = getJdbcTemplate();
- val all = jdbcTemplate.query("select * from " + url.getIdentifier() +
JdbcAuditLogStore.AUDIT_LOG_SUFFIX, new AuditLogRowMapper());
+ val all = jdbcTemplate.query("select * from " + url.getIdentifier() +
JdbcAuditLogStore.AUDIT_LOG_SUFFIX,
+ new AuditLogRowMapper());
Assert.assertTrue(all.stream().anyMatch(auditLog ->
auditLog.getResPath().equals("USER_INFO/ADMIN")));
System.setOut(System.out);
+ // reset password to KYLIN
+ overwriteSystemProp("kylin.metadata.random-admin-password.enabled",
"false");
+ KylinPasswordResetCLI.reset();
+
+ ResourceStore.clearCache(config);
+ config.clearManagers();
+ val afterManager2 = NKylinUserManager.getInstance(config);
+ Assert.assertTrue(pwdEncoder.matches("KYLIN",
afterManager2.get(user.getUsername()).getPassword()));
}
JdbcTemplate getJdbcTemplate() throws Exception {