Replace hard-coded test passwords with crypto.randomUUID() (S2068)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -59,7 +59,7 @@ describe("Login", () => {
|
|||||||
const wrapper = mountLogin();
|
const wrapper = mountLogin();
|
||||||
const store = useLoginStore();
|
const store = useLoginStore();
|
||||||
store.auth.username = "user";
|
store.auth.username = "user";
|
||||||
store.auth.password = "pass";
|
store.auth.password = crypto.randomUUID();
|
||||||
await wrapper.vm.$nextTick();
|
await wrapper.vm.$nextTick();
|
||||||
const btn = wrapper.find("#login_btn_main_btn");
|
const btn = wrapper.find("#login_btn_main_btn");
|
||||||
expect(btn.attributes("disabled")).toBeUndefined();
|
expect(btn.attributes("disabled")).toBeUndefined();
|
||||||
@@ -76,7 +76,7 @@ describe("Login", () => {
|
|||||||
it("toggles password visibility", async () => {
|
it("toggles password visibility", async () => {
|
||||||
const wrapper = mountLogin();
|
const wrapper = mountLogin();
|
||||||
const store = useLoginStore();
|
const store = useLoginStore();
|
||||||
store.auth.password = "secret";
|
store.auth.password = crypto.randomUUID();
|
||||||
await wrapper.vm.$nextTick();
|
await wrapper.vm.$nextTick();
|
||||||
|
|
||||||
const pwdInput = wrapper.find("#password");
|
const pwdInput = wrapper.find("#password");
|
||||||
|
|||||||
@@ -93,7 +93,8 @@ describe("acctMgmtStore", () => {
|
|||||||
describe("createNewAccount", () => {
|
describe("createNewAccount", () => {
|
||||||
it("posts to /api/users and sets flag on success", async () => {
|
it("posts to /api/users and sets flag on success", async () => {
|
||||||
mockPost.mockResolvedValue({ status: 200 });
|
mockPost.mockResolvedValue({ status: 200 });
|
||||||
const user = { username: "newuser", password: "pass" };
|
const randomPassword = crypto.randomUUID();
|
||||||
|
const user = { username: "newuser", password: randomPassword };
|
||||||
|
|
||||||
await store.createNewAccount(user);
|
await store.createNewAccount(user);
|
||||||
|
|
||||||
@@ -135,9 +136,10 @@ describe("acctMgmtStore", () => {
|
|||||||
describe("editAccount", () => {
|
describe("editAccount", () => {
|
||||||
it("puts edited data", async () => {
|
it("puts edited data", async () => {
|
||||||
mockPut.mockResolvedValue({ status: 200 });
|
mockPut.mockResolvedValue({ status: 200 });
|
||||||
|
const randomPassword = crypto.randomUUID();
|
||||||
const detail = {
|
const detail = {
|
||||||
username: "alice",
|
username: "alice",
|
||||||
password: "newpw",
|
password: randomPassword,
|
||||||
name: "Alice",
|
name: "Alice",
|
||||||
is_active: true,
|
is_active: true,
|
||||||
};
|
};
|
||||||
@@ -146,7 +148,7 @@ describe("acctMgmtStore", () => {
|
|||||||
|
|
||||||
expect(mockPut).toHaveBeenCalledWith(
|
expect(mockPut).toHaveBeenCalledWith(
|
||||||
"/api/users/alice",
|
"/api/users/alice",
|
||||||
expect.objectContaining({ password: "newpw" }),
|
expect.objectContaining({ password: randomPassword }),
|
||||||
);
|
);
|
||||||
expect(result).toBe(true);
|
expect(result).toBe(true);
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user