-
-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: don't require password when creating user
* feat: don't require password when creating user
- Loading branch information
Showing
4 changed files
with
106 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,7 +36,7 @@ describe('setup', () => { | |
data: { | ||
email: '[email protected]', | ||
fullname: 'Mock User', | ||
password: 'hello', | ||
password: 'helloworld', | ||
username: 'mock-1', | ||
}, | ||
method: 'create', | ||
|
@@ -60,7 +60,7 @@ describe('setup', () => { | |
const res = await app.api( | ||
context({ | ||
data: { | ||
password: 'hello', | ||
password: 'helloworld', | ||
username: 'mock', | ||
}, | ||
method: 'create', | ||
|
@@ -77,7 +77,7 @@ describe('setup', () => { | |
data: { | ||
email: '[email protected]', | ||
fullname: 'Mock User', | ||
password: 'hello', | ||
password: 'helloworld', | ||
role: 'dev', | ||
username: 'mock', | ||
}, | ||
|
@@ -819,7 +819,7 @@ describe('hooks registry', () => { | |
'log-data', | ||
'custom-code', | ||
'restrict-method', | ||
'auth-require-password', | ||
'auth-collect-password', | ||
'create-auth-credential', | ||
'require-auth', | ||
'assign-auth-user', | ||
|
@@ -832,3 +832,67 @@ describe('hooks registry', () => { | |
) | ||
}) | ||
}) | ||
|
||
describe('users/auth service', () => { | ||
it('creates user', async () => { | ||
const res = await app.api( | ||
context({ | ||
data: { | ||
email: '[email protected]', | ||
fullname: 'Mock User', | ||
password: 'helloworld', | ||
username: 'mock-user-1', | ||
}, | ||
method: 'create', | ||
path: 'users', | ||
}) | ||
) | ||
|
||
expect(res.statusCode).toBe(201) | ||
expect(res.result).toStrictEqual({ | ||
_id: expect.anything(), | ||
created_at: expect.any(Date), | ||
email: '[email protected]', | ||
fullname: 'Mock User', | ||
role: 'basic', | ||
updated_at: expect.any(Date), | ||
username: 'mock-user-1', | ||
}) | ||
}) | ||
|
||
it('returns 400 when password is less than 8 characters', async () => { | ||
const res = await app.api( | ||
context({ | ||
data: { | ||
email: '[email protected]', | ||
fullname: 'Mock User', | ||
password: 'hello', | ||
username: 'mock-user-2', | ||
}, | ||
method: 'create', | ||
path: 'users', | ||
}) | ||
) | ||
|
||
expect(res.statusCode).toBe(400) | ||
expect(res.result.error).toStrictEqual( | ||
'`password` should be at least 8 characters long' | ||
) | ||
}) | ||
|
||
it('should create user without requiring password', async () => { | ||
const res = await app.api( | ||
context({ | ||
data: { | ||
email: '[email protected]', | ||
fullname: 'Mock User', | ||
username: 'mock-user-3', | ||
}, | ||
method: 'create', | ||
path: 'users', | ||
}) | ||
) | ||
|
||
expect(res.statusCode).toBe(201) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,7 +31,7 @@ describe('authentication', () => { | |
data: { | ||
email: '[email protected]', | ||
fullname: 'Mock User', | ||
password: 'hello', | ||
password: 'helloworld', | ||
username: 'mock-1', | ||
}, | ||
method: 'create', | ||
|
@@ -47,7 +47,7 @@ describe('authentication', () => { | |
const { result } = await app.api( | ||
context({ | ||
data: { | ||
password: 'hello', | ||
password: 'helloworld', | ||
username: 'mock-1', | ||
}, | ||
method: 'create', | ||
|
@@ -66,7 +66,7 @@ describe('authentication', () => { | |
context({ | ||
data: { | ||
email: '[email protected]', | ||
password: 'hello', | ||
password: 'helloworld', | ||
}, | ||
method: 'create', | ||
path: 'login', | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters