feat: enhance password generation method; improve connection pooling logic in DatabasePlugin; update test cases with correct tokens

This commit is contained in:
Boris D
2025-10-13 09:12:47 +03:00
parent c4755f5346
commit 73999de32e
5 changed files with 21 additions and 15 deletions

View File

@ -108,21 +108,24 @@ export class DatabaseManagerService extends DatabaseEncryptionService {
const lowerCase = "abcdefghijklmnopqrstuvwxyz";
const numbers = "0123456789";
const symbols = "!@#$%^&*()_+[]{}|;:,.<>?";
// Ensure at least one character from each required category
let password = "";
password += upperCase.charAt(Math.floor(Math.random() * upperCase.length));
password += numbers.charAt(Math.floor(Math.random() * numbers.length));
password += symbols.charAt(Math.floor(Math.random() * symbols.length));
// Fill the rest with random characters from all categories
const allChars = upperCase + lowerCase + numbers + symbols;
for (let i = 3; i < length; i++) {
password += allChars.charAt(Math.floor(Math.random() * allChars.length));
}
// Shuffle the password to randomize the position of required characters
return password.split('').sort(() => Math.random() - 0.5).join('');
return password
.split("")
.sort(() => Math.random() - 0.5)
.join("");
}
async createDatabase(projectId: string): Promise<Database> {
@ -141,9 +144,7 @@ export class DatabaseManagerService extends DatabaseEncryptionService {
const c_username = `c_user_${Math.random().toString(36).substring(2, 8)}`;
const q_username = `q_user_${Math.random().toString(36).substring(2, 8)}`;
const databaseName = `db_${Math.random().toString(36).substring(2, 8)}`;
const password = this.encryptPassword(
this.generatePassword()
);
const password = this.encryptPassword(this.generatePassword());
await this.databaseNodeService.initDatabase(
{