dev: accounts testing
Massimo Melina committed
Jan 7, 2023 at 17:10 UTC
78ad1a98b06134c74829442d2bb2e1b8b3429b30
3 files changed
+10
-3
src/api.helpers.ts
+2
-2
@@ -6,7 +6,7 @@ import { UNAUTHORIZED } from './const'
6
7
export async function changePasswordHelper(account: Account | undefined, newPassword: string) {
8
if (!newPassword) // clear text version
9
- return Error('missing parameters')
9
+ return new ApiError(400, 'missing parameters')
10
if (!account)
11
return new ApiError(UNAUTHORIZED)
12
await updateAccount(account, account => {
@@ -19,7 +19,7 @@ export async function changeSrpHelper(account: Account | undefined, salt: string
19
if (allowClearTextLogin.get())
20
return new ApiError(406)
21
if (!salt || !verifier)
22
- return Error('missing parameters')
22
+ return new ApiError(400, 'missing parameters')
23
if (!account)
24
return new ApiError(UNAUTHORIZED)
25
await updateAccount(account, account => {
tests/config.yaml
+1
-1
@@ -1,7 +1,7 @@
1
allowed_referer: x.com
2
vfs:
3
mime:
4
- "*.jpg|*.png|*.mp3|*.txt": auto
4
+ "*": auto
5
masks:
6
tests/page/*.html:
7
mime: text/plain
tests/test.ts
+7
@@ -80,6 +80,13 @@ describe('basics', () => {
80
}))
81
})
82
83
+describe('accounts', () => {
84
+ const username = 'test-Add'
85
+ it('accounts.add', reqApi('add_account', { username }, res => res?.username === username.toLowerCase()))
86
+ it('account.password', reqApi('change_password_others', { username, newPassword: password }, 200))
87
+ it('accounts.remove', reqApi('del_account', { username }, 200))
88
+})
89
+
90
describe('after-login', () => {
91
before(() =>
92
srpSequence(username, password, (cmd: string, params: any) =>