-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #16 from Trazi-Ventures/fix-#47-audit-user-new-val…
…-json Fix json and buffer data audit values
- Loading branch information
Showing
3 changed files
with
51 additions
and
17 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
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 |
---|---|---|
@@ -1,5 +1,6 @@ | ||
const config = require('../../include/utils/config'); | ||
const User = require('../../include/database/models/user'); | ||
const Audit = require('../../include/database/models/audit'); | ||
const { Travelling } = require('../../sdk/node')('http://127.0.0.1:6969/' + config.serviceName, { | ||
resolveWithFullResponse: true | ||
}); | ||
|
@@ -421,6 +422,41 @@ module.exports = () => { | |
expect(res.statusCode).toEqual(200); | ||
expect(res.body.length).toEqual(0); | ||
}); | ||
|
||
test('Checking Audit of (Edit Test User Email Property [test2])', async () => { | ||
const u = await User.findAllBy({ username: 'test2' }); | ||
const audit = await Audit.findAllBy({ of_user_id: u[0].id, action: 'EDIT', subaction: 'USER_PROPERTY' }); | ||
|
||
expect(audit[0]).toHaveProperty('id'); | ||
expect(audit[0].created_on).not.toBeNull(); | ||
expect(audit[0].prop).toEqual('email'); | ||
expect(audit[0].old_val).toMatch('[email protected]'); | ||
expect(audit[0].new_val).toMatch('[email protected]'); | ||
|
||
expect(audit[1]).toHaveProperty('id'); | ||
expect(audit[1].created_on).not.toBeNull(); | ||
expect(audit[1].prop).toEqual('email'); | ||
expect(audit[1].old_val).toMatch('[email protected]'); | ||
expect(audit[1].new_val).toMatch('[email protected]'); | ||
|
||
expect(audit[2]).toHaveProperty('id'); | ||
expect(audit[2].created_on).not.toBeNull(); | ||
expect(audit[2].prop).toEqual('email'); | ||
expect(audit[2].old_val).toMatch('[email protected]'); | ||
expect(audit[2].new_val).toMatch('[email protected]'); | ||
|
||
expect(audit[3]).toHaveProperty('id'); | ||
expect(audit[3].created_on).not.toBeNull(); | ||
expect(audit[3].prop).toEqual('user_data'); | ||
expect(audit[3].old_val).toBeNull(); | ||
expect(audit[3].new_val).toMatch('{"test":1,"foo":"bar"}'); | ||
|
||
expect(audit[4]).toHaveProperty('id'); | ||
expect(audit[4].created_on).not.toBeNull(); | ||
expect(audit[4].prop).toEqual('user_data'); | ||
expect(audit[4].old_val).toMatch('{"test":1,"foo":"bar"}'); | ||
expect(audit[4].new_val).toMatch('{"notes":"notey totey"}'); | ||
}); | ||
}); | ||
|
||
describe('Invalid', () => { | ||
|
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 |
---|---|---|
|
@@ -58,19 +58,6 @@ module.exports = () => { | |
expect(res.statusCode).toEqual(200); | ||
}); | ||
|
||
test('Checking Audit of (Edit Test User Email Property [test2])', async () => { | ||
if (config.audit.edit.enable === true) { | ||
const u = await User.findAllBy({ username: 'test2' }); | ||
const audit = await Audit.findAllBy({ of_user_id: u[0].id, action: 'EDIT', subaction: 'USER_PROPERTY' }); | ||
|
||
expect(audit[0]).toHaveProperty('id'); | ||
expect(audit[0].created_on).not.toBeNull(); | ||
expect(audit[0].prop).toEqual('email'); | ||
expect(audit[0].old_val).toMatch('[email protected]'); | ||
expect(audit[0].new_val).toMatch('[email protected]'); | ||
} | ||
}); | ||
|
||
test('Edit Test User 2 Email Property Value ', async () => { | ||
var res = await Travelling.User.editPropertyValue('test2', 'email', '[email protected]', userContainer.user1Token); | ||
|
||
|
@@ -89,6 +76,17 @@ module.exports = () => { | |
expect(res.body).toMatchObject({ email: '[email protected]', user_data: { test: 1, foo: 'bar' } }); | ||
}); | ||
|
||
test('Edit Test User Update Existing UserData', async () => { | ||
var res = await Travelling.User.edit( | ||
{ user_data: { notes: 'notey totey' } }, | ||
'test2', | ||
userContainer.user1Token | ||
); | ||
|
||
expect(res.statusCode).toEqual(200); | ||
expect(res.body).toMatchObject({ user_data: { notes: 'notey totey' } }); | ||
}); | ||
|
||
test('Edit Test User 1 Email Property By GroupRequest', async () => { | ||
var res = await Travelling.Group.Request.User.editProperty( | ||
'[email protected]', | ||
|