forked from mirrors/homebox
feat: change password (#35)
* refactor: implement factories for testing * add additional factories * change protection for dropFields * prevent timed attacks on login * use switch instead of else-if * API implementation for changing password * add change-password dialog
This commit is contained in:
parent
a6e3989aee
commit
a6d2fd45df
19 changed files with 458 additions and 149 deletions
27
frontend/lib/api/__test__/user/user.test.ts
Normal file
27
frontend/lib/api/__test__/user/user.test.ts
Normal file
|
@ -0,0 +1,27 @@
|
|||
import { faker } from "@faker-js/faker";
|
||||
import { describe, expect, test } from "vitest";
|
||||
import { factories } from "../factories";
|
||||
|
||||
describe("basic user workflows", () => {
|
||||
test("user should be able to change password", async () => {
|
||||
const { client, user } = await factories.client.singleUse();
|
||||
const password = faker.internet.password();
|
||||
|
||||
// Change Password
|
||||
{
|
||||
const response = await client.user.changePassword(user.password, password);
|
||||
expect(response.error).toBeFalsy();
|
||||
expect(response.status).toBe(204);
|
||||
}
|
||||
|
||||
// Ensure New Login is Valid
|
||||
{
|
||||
const pub = factories.client.public();
|
||||
const response = await pub.login(user.email, password);
|
||||
expect(response.error).toBeFalsy();
|
||||
expect(response.status).toBe(200);
|
||||
}
|
||||
|
||||
await client.user.delete();
|
||||
}, 20000);
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue