feat(auth): change default admin password to admin and default agent password to 123 using TDD
This commit is contained in:
1 parent
14a4b7bce5
commit
bb89e6ad2a
4 files changed
+45
-5
No files matched your search
@@ -0,0 +1,40 @@
|
||||
const Database = require('better-sqlite3');
|
||||
const path = require('path');
|
||||
const bcrypt = require('bcryptjs');
|
||||
|
||||
const dbPath = path.join(__dirname, '../netify_data.db');
|
||||
const dbModule = require('../database');
|
||||
|
||||
console.log("=== RUNNING TDD TEST: DEFAULT PASSWORDS VERIFICATION ===");
|
||||
|
||||
// 1. Verify admin password
|
||||
const adminUser = dbModule.getUserByUsername('admin');
|
||||
if (!adminUser) {
|
||||
throw new Error("❌ TEST FAILED: Admin user not found!");
|
||||
}
|
||||
|
||||
const adminPwOk = bcrypt.compareSync('admin', adminUser.password_hash);
|
||||
if (!adminPwOk) {
|
||||
throw new Error("❌ TEST FAILED: Admin default password is NOT 'admin'!");
|
||||
}
|
||||
console.log("✅ Admin default password is correctly 'admin'.");
|
||||
|
||||
// 2. Verify agent default password
|
||||
const mockAgents = [
|
||||
{ id: 999999999, uuid: "TDD-TEST-AGENT", label: "TDD-TEST-AGENT" }
|
||||
];
|
||||
dbModule.syncAgentUsers(mockAgents);
|
||||
|
||||
const agentUser = dbModule.getUserByUsername('tdd-test-agent');
|
||||
if (!agentUser) {
|
||||
throw new Error("❌ TEST FAILED: Test agent user not created!");
|
||||
}
|
||||
|
||||
const agentPwOk = bcrypt.compareSync('123', agentUser.password_hash);
|
||||
if (!agentPwOk) {
|
||||
throw new Error("❌ TEST FAILED: Agent default password is NOT '123'!");
|
||||
}
|
||||
console.log("✅ Agent default password is correctly '123'.");
|
||||
|
||||
console.log("=== TDD TEST PASSED SUCCESSFULLY! ===");
|
||||
process.exit(0);
|
||||
@@ -37,8 +37,8 @@ for (const u of expectedUsernames) {
|
||||
}
|
||||
console.log(`✅ User verified: '${u}' (Role: ${user.role}, Agent UUID: ${user.agent_uuid})`);
|
||||
|
||||
// Verify password matches agent123
|
||||
const pwOk = bcrypt.compareSync('agent123', user.password_hash);
|
||||
// Verify password matches 123
|
||||
const pwOk = bcrypt.compareSync('123', user.password_hash);
|
||||
if (!pwOk) {
|
||||
throw new Error(`❌ TEST FAILED: Password for user '${u}' is incorrect!`);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user