feat/TS-5927-long-password-fix-cases

This commit is contained in:
dmchen 2025-02-13 10:02:17 +00:00
parent 58b7a6fe97
commit 80f60449e3
3 changed files with 13 additions and 10 deletions

View File

@ -10093,8 +10093,11 @@ static int32_t translateAlterUser(STranslateContext* pCxt, SAlterUserStmt* pStmt
alterReq.sysInfo = pStmt->sysinfo;
alterReq.createdb = pStmt->createdb ? 1 : 0;
taosEncryptPass_c((uint8_t*)pStmt->password, strlen(pStmt->password), alterReq.pass);
alterReq.passIsMd5 = 1;
int32_t len = strlen(pStmt->password);
if (len > 0) {
taosEncryptPass_c((uint8_t*)pStmt->password, len, alterReq.pass);
alterReq.passIsMd5 = 1;
}
if (NULL != pCxt->pParseCxt->db) {
snprintf(alterReq.objname, sizeof(alterReq.objname), "%s", pCxt->pParseCxt->db);

View File

@ -817,7 +817,7 @@ TEST_F(ParserInitialATest, alterUser) {
expect.sysInfo = sysInfo;
expect.enable = enable;
if (nullptr != pPass) {
strcpy(expect.pass, pPass);
taosEncryptPass_c((uint8_t*)pPass, strlen(pPass), expect.pass);
}
strcpy(expect.objname, "test");
};
@ -838,8 +838,8 @@ TEST_F(ParserInitialATest, alterUser) {
tFreeSAlterUserReq(&req);
});
setAlterUserReq("wxy", TSDB_ALTER_USER_PASSWD, "123456");
run("ALTER USER wxy PASS '123456'");
setAlterUserReq("wxy", TSDB_ALTER_USER_PASSWD, "12345678@Abc");
run("ALTER USER wxy PASS '12345678@Abc'");
clearAlterUserReq();
setAlterUserReq("wxy", TSDB_ALTER_USER_ENABLE, nullptr, 0, 1);

View File

@ -1345,11 +1345,11 @@ TEST_F(ParserInitialCTest, createUser) {
auto setCreateUserReq = [&](const char* pUser, const char* pPass, int8_t sysInfo = 1) {
strcpy(expect.user, pUser);
strcpy(expect.pass, pPass);
expect.createType = 0;
expect.superUser = 0;
expect.sysInfo = sysInfo;
expect.enable = 1;
taosEncryptPass_c((uint8_t*)pPass, strlen(pPass), expect.pass);
};
setCheckDdlFunc([&](const SQuery* pQuery, ParserStage stage) {
@ -1366,12 +1366,12 @@ TEST_F(ParserInitialCTest, createUser) {
tFreeSCreateUserReq(&req);
});
setCreateUserReq("wxy", "123456");
run("CREATE USER wxy PASS '123456'");
setCreateUserReq("wxy", "12345678@Abc");
run("CREATE USER wxy PASS '12345678@Abc'");
clearCreateUserReq();
setCreateUserReq("wxy1", "a123456", 1);
run("CREATE USER wxy1 PASS 'a123456' SYSINFO 1");
setCreateUserReq("wxy1", "12345678@Abc", 1);
run("CREATE USER wxy1 PASS '12345678@Abc' SYSINFO 1");
clearCreateUserReq();
}