-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
⏪ Revert removing deprecated register/update avatar APIs and CSRF
- Loading branch information
Showing
7 changed files
with
168 additions
and
22 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -53,7 +53,7 @@ test.serial('USER: Login user. Case: success', async (t) => { | |
t.is(res.status, 200); | ||
}); | ||
|
||
test.serial('USER: Edit user. Case: success', async (t) => { | ||
test.serial('USER: Edit user by JSON. Case: success', async (t) => { | ||
const user = testingUser1; | ||
const token = jwtSign({ user }); | ||
const payload = { | ||
|
@@ -72,7 +72,7 @@ test.serial('USER: Edit user. Case: success', async (t) => { | |
t.is(res.status, 200); | ||
}); | ||
|
||
test.serial('USER: Edit user by form-data. Case: invalid content type', async (t) => { | ||
test.serial('USER: Edit user by form-data. Case: success', async (t) => { | ||
const user = testingUser1; | ||
const token = jwtSign({ user }); | ||
const payload = new FormData(); | ||
|
@@ -83,13 +83,34 @@ test.serial('USER: Edit user by form-data. Case: invalid content type', async (t | |
payload.append('email', '[email protected]'); | ||
const res = await axiosist.post('/api/users/update', payload, { | ||
headers: { | ||
Cookie: `likecoin_auth=${token};`, | ||
Cookie: `likecoin_auth=${token}; _csrf=unit_test`, | ||
'x-csrf-token': '73fb9061-W0SmQvlNKd0uKS4d2nKoZd0u7SA', | ||
...payload.getHeaders(), | ||
}, | ||
}); | ||
|
||
t.is(res.status, 200); | ||
}); | ||
|
||
test.serial('USER: Edit user by form-data. Case: invalid csrf token', async (t) => { | ||
const user = testingUser1; | ||
const token = jwtSign({ user }); | ||
const payload = new FormData(); | ||
payload.append('user', user); | ||
payload.append('displayName', testingDisplayName1); | ||
payload.append('ts', Date.now()); | ||
payload.append('wallet', testingWallet1); | ||
payload.append('email', '[email protected]'); | ||
const res = await axiosist.post('/api/users/update', payload, { | ||
headers: { | ||
Cookie: `likecoin_auth=${token}; _csrf=unit_test`, | ||
'x-csrf-token': 'invalid-token', | ||
...payload.getHeaders(), | ||
}, | ||
}).catch(err => err.response); | ||
|
||
t.is(res.status, 400); | ||
t.is(res.data, 'INVALID_PAYLOAD'); | ||
t.is(res.data, 'BAD_CSRF_TOKEN'); | ||
}); | ||
|
||
test.serial('USER: Update avatar. Case: success', async (t) => { | ||
|
@@ -303,6 +324,11 @@ for (let i = 0; i < userCases.length; i += 1) { | |
payload: formatedPayload, | ||
sign, | ||
platform: 'wallet', | ||
}, { | ||
headers: { | ||
Cookie: '_csrf=unit_test', | ||
'x-csrf-token': '73fb9061-W0SmQvlNKd0uKS4d2nKoZd0u7SA', | ||
}, | ||
}).catch(err => err.response); | ||
|
||
t.is(res.status, 400); | ||
|