Replace hard-coded test passwords with crypto.randomUUID() (S2068)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-10 09:51:34 +08:00
parent 30ea7711ce
commit fe8a1e8a00
2 changed files with 7 additions and 5 deletions

View File

@@ -93,7 +93,8 @@ describe("acctMgmtStore", () => {
describe("createNewAccount", () => {
it("posts to /api/users and sets flag on success", async () => {
mockPost.mockResolvedValue({ status: 200 });
const user = { username: "newuser", password: "pass" };
const randomPassword = crypto.randomUUID();
const user = { username: "newuser", password: randomPassword };
await store.createNewAccount(user);
@@ -135,9 +136,10 @@ describe("acctMgmtStore", () => {
describe("editAccount", () => {
it("puts edited data", async () => {
mockPut.mockResolvedValue({ status: 200 });
const randomPassword = crypto.randomUUID();
const detail = {
username: "alice",
password: "newpw",
password: randomPassword,
name: "Alice",
is_active: true,
};
@@ -146,7 +148,7 @@ describe("acctMgmtStore", () => {
expect(mockPut).toHaveBeenCalledWith(
"/api/users/alice",
expect.objectContaining({ password: "newpw" }),
expect.objectContaining({ password: randomPassword }),
);
expect(result).toBe(true);
});