test: 密码检测用例 (#411)
* feat: 密码复杂度检测 * chore: 改为服务端校验 * test: 修改用例 * test: 添加getPasswordStrength测试用例
This commit is contained in:
parent
63e16e1694
commit
d3c2180ac8
@ -92,7 +92,10 @@ describe('AuthController', () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
await expect(controller.register(mockUserInfo)).rejects.toThrow(
|
await expect(controller.register(mockUserInfo)).rejects.toThrow(
|
||||||
new HttpException('密码无效', EXCEPTION_CODE.PASSWORD_INVALID),
|
new HttpException(
|
||||||
|
'密码只能输入数字、字母、特殊字符',
|
||||||
|
EXCEPTION_CODE.PASSWORD_INVALID,
|
||||||
|
),
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -217,4 +220,29 @@ describe('AuthController', () => {
|
|||||||
expect(typeof result.data.img).toBe('string');
|
expect(typeof result.data.img).toBe('string');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('password strength', () => {
|
||||||
|
it('it should return strong', async () => {
|
||||||
|
await expect(
|
||||||
|
controller.getPasswordStrength('abcd&1234'),
|
||||||
|
).resolves.toEqual({
|
||||||
|
code: 200,
|
||||||
|
data: 'Strong',
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('it should return medium', async () => {
|
||||||
|
await expect(controller.getPasswordStrength('abc123')).resolves.toEqual({
|
||||||
|
code: 200,
|
||||||
|
data: 'Medium',
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('it should return weak', async () => {
|
||||||
|
await expect(controller.getPasswordStrength('123456')).resolves.toEqual({
|
||||||
|
code: 200,
|
||||||
|
data: 'Weak',
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
@ -245,8 +245,10 @@ describe('WorkspaceController', () => {
|
|||||||
const req = { user: { _id: new ObjectId() } };
|
const req = { user: { _id: new ObjectId() } };
|
||||||
|
|
||||||
const workspaceId = new ObjectId();
|
const workspaceId = new ObjectId();
|
||||||
const memberList = [{ workspaceId, userId: new ObjectId() }];
|
const userId = new ObjectId();
|
||||||
|
const memberList = [{ workspaceId, userId: userId }];
|
||||||
const workspaces = [{ _id: workspaceId, name: 'Test Workspace' }];
|
const workspaces = [{ _id: workspaceId, name: 'Test Workspace' }];
|
||||||
|
const userList = [{ _id: userId, username: 'Test User' }];
|
||||||
|
|
||||||
jest
|
jest
|
||||||
.spyOn(workspaceService, 'findAllByUserId')
|
.spyOn(workspaceService, 'findAllByUserId')
|
||||||
@ -254,6 +256,9 @@ describe('WorkspaceController', () => {
|
|||||||
jest
|
jest
|
||||||
.spyOn(workspaceMemberService, 'batchSearchByWorkspace')
|
.spyOn(workspaceMemberService, 'batchSearchByWorkspace')
|
||||||
.mockResolvedValue(memberList as unknown as Array<WorkspaceMember>);
|
.mockResolvedValue(memberList as unknown as Array<WorkspaceMember>);
|
||||||
|
jest
|
||||||
|
.spyOn(userService, 'getUserListByIds')
|
||||||
|
.mockResolvedValue(userList as User[]);
|
||||||
|
|
||||||
const result = await controller.getWorkspaceAndMember(req);
|
const result = await controller.getWorkspaceAndMember(req);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user