@docbrasil/api-systemmanager 1.0.88 → 1.0.90
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/api/admin/doctypes.js +76 -76
- package/api/admin/document.js +332 -332
- package/api/admin/form.js +151 -151
- package/api/admin/index.js +46 -46
- package/api/admin/list.js +133 -133
- package/api/admin/message.js +194 -194
- package/api/admin/notification.js +233 -233
- package/api/admin/organization.js +124 -124
- package/api/admin/plugin.js +116 -116
- package/api/admin/policy.js +78 -78
- package/api/admin/processes.js +370 -370
- package/api/admin/task.js +125 -125
- package/api/admin/user.js +185 -185
- package/api/dispatch.js +101 -101
- package/api/general/geoLocation.js +88 -88
- package/api/general/index.js +22 -22
- package/api/login.js +267 -267
- package/api/session.js +85 -85
- package/api/user/datasource.js +144 -144
- package/api/user/document.js +730 -731
- package/api/user/index.js +39 -39
- package/api/user/notification.js +101 -101
- package/api/user/organization.js +230 -230
- package/api/user/process.js +191 -191
- package/api/user/register.js +205 -205
- package/api/user/task.js +201 -201
- package/api/user/task_available.js +135 -135
- package/api/user/user.js +287 -287
- package/api/utils/cypher.js +37 -37
- package/api/utils/promises.js +118 -118
- package/bundleRollup.js +158 -158
- package/dist/bundle.cjs +4875 -4876
- package/dist/bundle.mjs +1 -1
- package/doc/api.md +674 -336
- package/doc.md +653 -653
- package/helper/boom.js +487 -487
- package/helper/cryptojs.js +6067 -6067
- package/index.js +85 -85
- package/package-lock.json +4635 -4635
- package/package.json +68 -68
- package/readme.md +25 -25
- package/tests/admin/document.spec.js +45 -45
- package/tests/admin/form.spec.js +74 -74
- package/tests/admin/list.spec.js +86 -86
- package/tests/admin/message.js +92 -92
- package/tests/admin/notification.spec.js +174 -174
- package/tests/admin/pluginspec..js +71 -71
- package/tests/admin/policy.spec.js +71 -71
- package/tests/admin/processes.spec.js +119 -119
- package/tests/admin/users.spec.js +127 -127
- package/tests/documents.spec.js +164 -164
- package/tests/login.spec.js +91 -91
- package/tests/session.spec..js +58 -58
- package/tests/user/documents.js +164 -164
- package/tests/user/organization.js +122 -122
- package/tests/user/process.js +71 -71
- package/tests/user/user.js +88 -88
|
@@ -1,71 +1,71 @@
|
|
|
1
|
-
const _ = require('lodash');
|
|
2
|
-
const expect = require('chai').expect;
|
|
3
|
-
|
|
4
|
-
const API = require('../../index');
|
|
5
|
-
|
|
6
|
-
let userId;
|
|
7
|
-
let orgId;
|
|
8
|
-
let sm;
|
|
9
|
-
let session;
|
|
10
|
-
let apiKey = '38bd15aa-6418-4d4f-812a-e7ed5b3bfcde';
|
|
11
|
-
|
|
12
|
-
describe('Start API policy', function () {
|
|
13
|
-
before(function (done) {
|
|
14
|
-
|
|
15
|
-
try {
|
|
16
|
-
sm = new API();
|
|
17
|
-
done();
|
|
18
|
-
} catch (ex) {
|
|
19
|
-
expect(ex).to.be.empty;
|
|
20
|
-
}
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
it('Login SU', async function () {
|
|
24
|
-
try {
|
|
25
|
-
const retData = await sm.login.apiKey(apiKey);
|
|
26
|
-
|
|
27
|
-
expect(retData).to.not.be.empty;
|
|
28
|
-
expect(retData.auth).to.be.true;
|
|
29
|
-
expect(retData.user).to.be.an('object');
|
|
30
|
-
expect(retData.user).to.be.an('object');
|
|
31
|
-
expect(retData.user).to.not.be.empty;
|
|
32
|
-
expect(retData.user.sessionId).to.not.be.empty;
|
|
33
|
-
expect(retData.user.sessionId.split('.').length).equal(3);
|
|
34
|
-
expect(retData.user.orgId.length).equal(24);
|
|
35
|
-
|
|
36
|
-
session = retData.user.sessionId;
|
|
37
|
-
userId = retData.user._id;
|
|
38
|
-
orgId = retData.user.orgId;
|
|
39
|
-
} catch (ex) {
|
|
40
|
-
expect(ex).to.be.empty;
|
|
41
|
-
}
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
it('Get policies', async function () {
|
|
45
|
-
try {
|
|
46
|
-
const retData = await sm.admin.policy.find(session);
|
|
47
|
-
|
|
48
|
-
expect(retData).to.not.be.empty;
|
|
49
|
-
expect(retData).to.be.an('array');
|
|
50
|
-
expect(retData[0]).to.include.all.keys('_id', 'name', 'policy', 'description');
|
|
51
|
-
} catch (ex) {
|
|
52
|
-
expect(ex).to.be.empty;
|
|
53
|
-
}
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
it('Logout user', async function () {
|
|
57
|
-
try {
|
|
58
|
-
const retData = await sm.login.logout(session);
|
|
59
|
-
|
|
60
|
-
expect(retData).to.not.be.empty;
|
|
61
|
-
expect(retData).to.be.an('object');
|
|
62
|
-
expect(retData.response).to.not.be.empty;
|
|
63
|
-
expect(retData.response).equal('OK');
|
|
64
|
-
} catch (ex) {
|
|
65
|
-
expect(ex).to.be.empty;
|
|
66
|
-
}
|
|
67
|
-
});
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
1
|
+
const _ = require('lodash');
|
|
2
|
+
const expect = require('chai').expect;
|
|
3
|
+
|
|
4
|
+
const API = require('../../index');
|
|
5
|
+
|
|
6
|
+
let userId;
|
|
7
|
+
let orgId;
|
|
8
|
+
let sm;
|
|
9
|
+
let session;
|
|
10
|
+
let apiKey = '38bd15aa-6418-4d4f-812a-e7ed5b3bfcde';
|
|
11
|
+
|
|
12
|
+
describe('Start API policy', function () {
|
|
13
|
+
before(function (done) {
|
|
14
|
+
|
|
15
|
+
try {
|
|
16
|
+
sm = new API();
|
|
17
|
+
done();
|
|
18
|
+
} catch (ex) {
|
|
19
|
+
expect(ex).to.be.empty;
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
it('Login SU', async function () {
|
|
24
|
+
try {
|
|
25
|
+
const retData = await sm.login.apiKey(apiKey);
|
|
26
|
+
|
|
27
|
+
expect(retData).to.not.be.empty;
|
|
28
|
+
expect(retData.auth).to.be.true;
|
|
29
|
+
expect(retData.user).to.be.an('object');
|
|
30
|
+
expect(retData.user).to.be.an('object');
|
|
31
|
+
expect(retData.user).to.not.be.empty;
|
|
32
|
+
expect(retData.user.sessionId).to.not.be.empty;
|
|
33
|
+
expect(retData.user.sessionId.split('.').length).equal(3);
|
|
34
|
+
expect(retData.user.orgId.length).equal(24);
|
|
35
|
+
|
|
36
|
+
session = retData.user.sessionId;
|
|
37
|
+
userId = retData.user._id;
|
|
38
|
+
orgId = retData.user.orgId;
|
|
39
|
+
} catch (ex) {
|
|
40
|
+
expect(ex).to.be.empty;
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
it('Get policies', async function () {
|
|
45
|
+
try {
|
|
46
|
+
const retData = await sm.admin.policy.find(session);
|
|
47
|
+
|
|
48
|
+
expect(retData).to.not.be.empty;
|
|
49
|
+
expect(retData).to.be.an('array');
|
|
50
|
+
expect(retData[0]).to.include.all.keys('_id', 'name', 'policy', 'description');
|
|
51
|
+
} catch (ex) {
|
|
52
|
+
expect(ex).to.be.empty;
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
it('Logout user', async function () {
|
|
57
|
+
try {
|
|
58
|
+
const retData = await sm.login.logout(session);
|
|
59
|
+
|
|
60
|
+
expect(retData).to.not.be.empty;
|
|
61
|
+
expect(retData).to.be.an('object');
|
|
62
|
+
expect(retData.response).to.not.be.empty;
|
|
63
|
+
expect(retData.response).equal('OK');
|
|
64
|
+
} catch (ex) {
|
|
65
|
+
expect(ex).to.be.empty;
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
|
|
@@ -1,119 +1,119 @@
|
|
|
1
|
-
const _ = require('lodash');
|
|
2
|
-
const expect = require('chai').expect;
|
|
3
|
-
|
|
4
|
-
const API = require('../../index');
|
|
5
|
-
|
|
6
|
-
let userId;
|
|
7
|
-
let orgId;
|
|
8
|
-
let sm;
|
|
9
|
-
let session;
|
|
10
|
-
let apiKey = '38bd15aa-6418-4d4f-812a-e7ed5b3bfcde';
|
|
11
|
-
|
|
12
|
-
describe('Start API policy', function () {
|
|
13
|
-
before(function (done) {
|
|
14
|
-
|
|
15
|
-
try {
|
|
16
|
-
sm = new API();
|
|
17
|
-
done();
|
|
18
|
-
} catch (ex) {
|
|
19
|
-
expect(ex).to.be.empty;
|
|
20
|
-
}
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
it('Login SU', async function () {
|
|
24
|
-
try {
|
|
25
|
-
const retData = await sm.login.apiKey(apiKey);
|
|
26
|
-
|
|
27
|
-
expect(retData).to.not.be.empty;
|
|
28
|
-
expect(retData.auth).to.be.true;
|
|
29
|
-
expect(retData.user).to.be.an('object');
|
|
30
|
-
expect(retData.user).to.be.an('object');
|
|
31
|
-
expect(retData.user).to.not.be.empty;
|
|
32
|
-
expect(retData.user.sessionId).to.not.be.empty;
|
|
33
|
-
expect(retData.user.sessionId.split('.').length).equal(3);
|
|
34
|
-
expect(retData.user.orgId.length).equal(24);
|
|
35
|
-
|
|
36
|
-
session = retData.user.sessionId;
|
|
37
|
-
userId = retData.user._id;
|
|
38
|
-
orgId = retData.user.orgId;
|
|
39
|
-
} catch (ex) {
|
|
40
|
-
expect(ex).to.be.empty;
|
|
41
|
-
}
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
it('Search process: Context recruiter', async function () {
|
|
45
|
-
try {
|
|
46
|
-
const setParams = {
|
|
47
|
-
orgProcessId: {value: '5f57d4f3b8fe3d0d22fc99be'},
|
|
48
|
-
initParams: [
|
|
49
|
-
{
|
|
50
|
-
value: '5f67651a7dae1a260eb92625',
|
|
51
|
-
name: 'initParams.jobId',
|
|
52
|
-
},
|
|
53
|
-
{
|
|
54
|
-
value: 'remote',
|
|
55
|
-
name: 'initParams.type',
|
|
56
|
-
},
|
|
57
|
-
{
|
|
58
|
-
value: '23/09/2020 13:00',
|
|
59
|
-
type: 'date_time',
|
|
60
|
-
oper: '>=',
|
|
61
|
-
name: 'initParams.startDateTime'
|
|
62
|
-
},
|
|
63
|
-
{
|
|
64
|
-
value: '23/09/2020 15:00',
|
|
65
|
-
type: 'date_time',
|
|
66
|
-
oper: '<=',
|
|
67
|
-
name: 'initParams.endDateTime'
|
|
68
|
-
},
|
|
69
|
-
],
|
|
70
|
-
orgId
|
|
71
|
-
};
|
|
72
|
-
const retData = await sm.admin.processes.search(setParams, session);
|
|
73
|
-
|
|
74
|
-
expect(retData.items).to.not.be.empty;
|
|
75
|
-
expect(retData.items).to.be.an('array');
|
|
76
|
-
expect(retData.items[0]).to.include.all.keys('history', 'properties');
|
|
77
|
-
} catch (ex) {
|
|
78
|
-
expect(ex).to.be.empty;
|
|
79
|
-
}
|
|
80
|
-
});
|
|
81
|
-
|
|
82
|
-
it('Search process: Context professional', async function () {
|
|
83
|
-
try {
|
|
84
|
-
const setParams = {
|
|
85
|
-
orgProcessId: {value: '5f57d4f3b8fe3d0d22fc99be'},
|
|
86
|
-
initParams: [
|
|
87
|
-
{
|
|
88
|
-
value: [{id: '5f677fa16d92486104823bcb'}],
|
|
89
|
-
name: 'initParams.candidates.id',
|
|
90
|
-
},
|
|
91
|
-
],
|
|
92
|
-
orgId
|
|
93
|
-
};
|
|
94
|
-
const retData = await sm.admin.processes.search(setParams, session);
|
|
95
|
-
|
|
96
|
-
expect(retData.items).to.not.be.empty;
|
|
97
|
-
expect(retData.items).to.be.an('array');
|
|
98
|
-
expect(retData.items[0]).to.include.all.keys('history', 'properties');
|
|
99
|
-
} catch (ex) {
|
|
100
|
-
expect(ex).to.be.empty;
|
|
101
|
-
}
|
|
102
|
-
});
|
|
103
|
-
|
|
104
|
-
it('Logout user', async function () {
|
|
105
|
-
try {
|
|
106
|
-
const retData = await sm.login.logout(session);
|
|
107
|
-
|
|
108
|
-
expect(retData).to.not.be.empty;
|
|
109
|
-
expect(retData).to.be.an('object');
|
|
110
|
-
expect(retData.response).to.not.be.empty;
|
|
111
|
-
expect(retData.response).equal('OK');
|
|
112
|
-
} catch (ex) {
|
|
113
|
-
expect(ex).to.be.empty;
|
|
114
|
-
}
|
|
115
|
-
});
|
|
116
|
-
});
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
1
|
+
const _ = require('lodash');
|
|
2
|
+
const expect = require('chai').expect;
|
|
3
|
+
|
|
4
|
+
const API = require('../../index');
|
|
5
|
+
|
|
6
|
+
let userId;
|
|
7
|
+
let orgId;
|
|
8
|
+
let sm;
|
|
9
|
+
let session;
|
|
10
|
+
let apiKey = '38bd15aa-6418-4d4f-812a-e7ed5b3bfcde';
|
|
11
|
+
|
|
12
|
+
describe('Start API policy', function () {
|
|
13
|
+
before(function (done) {
|
|
14
|
+
|
|
15
|
+
try {
|
|
16
|
+
sm = new API();
|
|
17
|
+
done();
|
|
18
|
+
} catch (ex) {
|
|
19
|
+
expect(ex).to.be.empty;
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
it('Login SU', async function () {
|
|
24
|
+
try {
|
|
25
|
+
const retData = await sm.login.apiKey(apiKey);
|
|
26
|
+
|
|
27
|
+
expect(retData).to.not.be.empty;
|
|
28
|
+
expect(retData.auth).to.be.true;
|
|
29
|
+
expect(retData.user).to.be.an('object');
|
|
30
|
+
expect(retData.user).to.be.an('object');
|
|
31
|
+
expect(retData.user).to.not.be.empty;
|
|
32
|
+
expect(retData.user.sessionId).to.not.be.empty;
|
|
33
|
+
expect(retData.user.sessionId.split('.').length).equal(3);
|
|
34
|
+
expect(retData.user.orgId.length).equal(24);
|
|
35
|
+
|
|
36
|
+
session = retData.user.sessionId;
|
|
37
|
+
userId = retData.user._id;
|
|
38
|
+
orgId = retData.user.orgId;
|
|
39
|
+
} catch (ex) {
|
|
40
|
+
expect(ex).to.be.empty;
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
it('Search process: Context recruiter', async function () {
|
|
45
|
+
try {
|
|
46
|
+
const setParams = {
|
|
47
|
+
orgProcessId: {value: '5f57d4f3b8fe3d0d22fc99be'},
|
|
48
|
+
initParams: [
|
|
49
|
+
{
|
|
50
|
+
value: '5f67651a7dae1a260eb92625',
|
|
51
|
+
name: 'initParams.jobId',
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
value: 'remote',
|
|
55
|
+
name: 'initParams.type',
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
value: '23/09/2020 13:00',
|
|
59
|
+
type: 'date_time',
|
|
60
|
+
oper: '>=',
|
|
61
|
+
name: 'initParams.startDateTime'
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
value: '23/09/2020 15:00',
|
|
65
|
+
type: 'date_time',
|
|
66
|
+
oper: '<=',
|
|
67
|
+
name: 'initParams.endDateTime'
|
|
68
|
+
},
|
|
69
|
+
],
|
|
70
|
+
orgId
|
|
71
|
+
};
|
|
72
|
+
const retData = await sm.admin.processes.search(setParams, session);
|
|
73
|
+
|
|
74
|
+
expect(retData.items).to.not.be.empty;
|
|
75
|
+
expect(retData.items).to.be.an('array');
|
|
76
|
+
expect(retData.items[0]).to.include.all.keys('history', 'properties');
|
|
77
|
+
} catch (ex) {
|
|
78
|
+
expect(ex).to.be.empty;
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
it('Search process: Context professional', async function () {
|
|
83
|
+
try {
|
|
84
|
+
const setParams = {
|
|
85
|
+
orgProcessId: {value: '5f57d4f3b8fe3d0d22fc99be'},
|
|
86
|
+
initParams: [
|
|
87
|
+
{
|
|
88
|
+
value: [{id: '5f677fa16d92486104823bcb'}],
|
|
89
|
+
name: 'initParams.candidates.id',
|
|
90
|
+
},
|
|
91
|
+
],
|
|
92
|
+
orgId
|
|
93
|
+
};
|
|
94
|
+
const retData = await sm.admin.processes.search(setParams, session);
|
|
95
|
+
|
|
96
|
+
expect(retData.items).to.not.be.empty;
|
|
97
|
+
expect(retData.items).to.be.an('array');
|
|
98
|
+
expect(retData.items[0]).to.include.all.keys('history', 'properties');
|
|
99
|
+
} catch (ex) {
|
|
100
|
+
expect(ex).to.be.empty;
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
it('Logout user', async function () {
|
|
105
|
+
try {
|
|
106
|
+
const retData = await sm.login.logout(session);
|
|
107
|
+
|
|
108
|
+
expect(retData).to.not.be.empty;
|
|
109
|
+
expect(retData).to.be.an('object');
|
|
110
|
+
expect(retData.response).to.not.be.empty;
|
|
111
|
+
expect(retData.response).equal('OK');
|
|
112
|
+
} catch (ex) {
|
|
113
|
+
expect(ex).to.be.empty;
|
|
114
|
+
}
|
|
115
|
+
});
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
|
|
@@ -1,127 +1,127 @@
|
|
|
1
|
-
const _ = require('lodash');
|
|
2
|
-
const expect = require('chai').expect;
|
|
3
|
-
|
|
4
|
-
const API = require('../../index');
|
|
5
|
-
|
|
6
|
-
let session;
|
|
7
|
-
let userId;
|
|
8
|
-
let sm;
|
|
9
|
-
let updatePass = {id: userId, oldPassword: '123456', newPassword: '123456789'};
|
|
10
|
-
let apiKey = '38bd15aa-6418-4d4f-812a-e7ed5b3bfcde';
|
|
11
|
-
let emailExist = 'emailisunique@gmail.com';
|
|
12
|
-
|
|
13
|
-
describe('Start API users', function () {
|
|
14
|
-
before(function (done) {
|
|
15
|
-
|
|
16
|
-
try {
|
|
17
|
-
sm = new API();
|
|
18
|
-
done();
|
|
19
|
-
} catch (ex) {
|
|
20
|
-
expect(ex).to.be.empty;
|
|
21
|
-
}
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
it('Login SU', async function () {
|
|
25
|
-
try {
|
|
26
|
-
const retData = await sm.login.apiKey(apiKey);
|
|
27
|
-
|
|
28
|
-
expect(retData).to.not.be.empty;
|
|
29
|
-
expect(retData.auth).to.be.true;
|
|
30
|
-
expect(retData.user).to.be.an('object');
|
|
31
|
-
expect(retData.user).to.be.an('object');
|
|
32
|
-
expect(retData.user).to.not.be.empty;
|
|
33
|
-
expect(retData.user.sessionId).to.not.be.empty;
|
|
34
|
-
expect(retData.user.sessionId.split('.').length).equal(3);
|
|
35
|
-
expect(retData.user.orgId.length).equal(24);
|
|
36
|
-
|
|
37
|
-
session = retData.user.sessionId;
|
|
38
|
-
userId = retData.user._id;
|
|
39
|
-
} catch (ex) {
|
|
40
|
-
expect(ex).to.be.empty;
|
|
41
|
-
}
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
it('Get profile', async function () {
|
|
45
|
-
try {
|
|
46
|
-
const retData = await sm.admin.user.findById(userId, session);
|
|
47
|
-
|
|
48
|
-
expect(retData).to.not.be.empty;
|
|
49
|
-
expect(retData).to.be.an('object');
|
|
50
|
-
expect(retData._id).equal(userId);
|
|
51
|
-
expect(retData.name).equal('Automation SM');
|
|
52
|
-
expect(retData.username).equal('en_automation');
|
|
53
|
-
} catch (ex) {
|
|
54
|
-
expect(ex).to.be.empty;
|
|
55
|
-
}
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
it('Update password', async function () {
|
|
59
|
-
try {
|
|
60
|
-
updatePass.userId = userId;
|
|
61
|
-
const retData = await sm.admin.user.findByIdAndUpdatePassword(updatePass, session);
|
|
62
|
-
|
|
63
|
-
expect(retData).to.not.be.empty;
|
|
64
|
-
expect(retData).to.be.an('object');
|
|
65
|
-
expect(retData._id).equal(userId);
|
|
66
|
-
expect(retData.name).equal('Automation SM');
|
|
67
|
-
expect(retData.username).equal('en_automation');
|
|
68
|
-
} catch (ex) {
|
|
69
|
-
expect(ex).to.be.empty;
|
|
70
|
-
}
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
it('Rollback Update password', async function () {
|
|
74
|
-
try {
|
|
75
|
-
updatePass.oldPassword = '123456789';
|
|
76
|
-
updatePass.newPassword = '123456';
|
|
77
|
-
updatePass.id = userId;
|
|
78
|
-
const retData = await sm.admin.user.findByIdAndUpdatePassword(updatePass, session);
|
|
79
|
-
|
|
80
|
-
expect(retData).to.not.be.empty;
|
|
81
|
-
expect(retData).to.be.an('object');
|
|
82
|
-
expect(retData._id).equal(userId);
|
|
83
|
-
expect(retData.name).equal('Automation SM');
|
|
84
|
-
expect(retData.username).equal('en_automation');
|
|
85
|
-
} catch (ex) {
|
|
86
|
-
expect(ex).to.be.empty;
|
|
87
|
-
}
|
|
88
|
-
});
|
|
89
|
-
|
|
90
|
-
it('Email is unique', async function () {
|
|
91
|
-
try {
|
|
92
|
-
const retData = await sm.admin.user.emailExist(emailExist, session);
|
|
93
|
-
|
|
94
|
-
expect(retData).to.not.be.empty;
|
|
95
|
-
expect(retData).to.be.an('object');
|
|
96
|
-
expect(retData.exist).to.be.false;
|
|
97
|
-
} catch (ex) {
|
|
98
|
-
expect(ex).to.be.empty;
|
|
99
|
-
}
|
|
100
|
-
});
|
|
101
|
-
|
|
102
|
-
it('Email is not unique', async function () {
|
|
103
|
-
try {
|
|
104
|
-
emailExist = 'ana.breda@gmail.com';
|
|
105
|
-
const retData = await sm.admin.user.emailExist(emailExist, session);
|
|
106
|
-
|
|
107
|
-
expect(retData).to.not.be.empty;
|
|
108
|
-
expect(retData).to.be.an('object');
|
|
109
|
-
expect(retData.exist).to.be.true;
|
|
110
|
-
} catch (ex) {
|
|
111
|
-
expect(ex).to.be.empty;
|
|
112
|
-
}
|
|
113
|
-
});
|
|
114
|
-
|
|
115
|
-
it('Logout user', async function () {
|
|
116
|
-
try {
|
|
117
|
-
const retData = await sm.login.logout(session);
|
|
118
|
-
|
|
119
|
-
expect(retData).to.not.be.empty;
|
|
120
|
-
expect(retData).to.be.an('object');
|
|
121
|
-
expect(retData.response).to.not.be.empty;
|
|
122
|
-
expect(retData.response).equal('OK');
|
|
123
|
-
} catch (ex) {
|
|
124
|
-
expect(ex).to.be.empty;
|
|
125
|
-
}
|
|
126
|
-
});
|
|
127
|
-
});
|
|
1
|
+
const _ = require('lodash');
|
|
2
|
+
const expect = require('chai').expect;
|
|
3
|
+
|
|
4
|
+
const API = require('../../index');
|
|
5
|
+
|
|
6
|
+
let session;
|
|
7
|
+
let userId;
|
|
8
|
+
let sm;
|
|
9
|
+
let updatePass = {id: userId, oldPassword: '123456', newPassword: '123456789'};
|
|
10
|
+
let apiKey = '38bd15aa-6418-4d4f-812a-e7ed5b3bfcde';
|
|
11
|
+
let emailExist = 'emailisunique@gmail.com';
|
|
12
|
+
|
|
13
|
+
describe('Start API users', function () {
|
|
14
|
+
before(function (done) {
|
|
15
|
+
|
|
16
|
+
try {
|
|
17
|
+
sm = new API();
|
|
18
|
+
done();
|
|
19
|
+
} catch (ex) {
|
|
20
|
+
expect(ex).to.be.empty;
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
it('Login SU', async function () {
|
|
25
|
+
try {
|
|
26
|
+
const retData = await sm.login.apiKey(apiKey);
|
|
27
|
+
|
|
28
|
+
expect(retData).to.not.be.empty;
|
|
29
|
+
expect(retData.auth).to.be.true;
|
|
30
|
+
expect(retData.user).to.be.an('object');
|
|
31
|
+
expect(retData.user).to.be.an('object');
|
|
32
|
+
expect(retData.user).to.not.be.empty;
|
|
33
|
+
expect(retData.user.sessionId).to.not.be.empty;
|
|
34
|
+
expect(retData.user.sessionId.split('.').length).equal(3);
|
|
35
|
+
expect(retData.user.orgId.length).equal(24);
|
|
36
|
+
|
|
37
|
+
session = retData.user.sessionId;
|
|
38
|
+
userId = retData.user._id;
|
|
39
|
+
} catch (ex) {
|
|
40
|
+
expect(ex).to.be.empty;
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
it('Get profile', async function () {
|
|
45
|
+
try {
|
|
46
|
+
const retData = await sm.admin.user.findById(userId, session);
|
|
47
|
+
|
|
48
|
+
expect(retData).to.not.be.empty;
|
|
49
|
+
expect(retData).to.be.an('object');
|
|
50
|
+
expect(retData._id).equal(userId);
|
|
51
|
+
expect(retData.name).equal('Automation SM');
|
|
52
|
+
expect(retData.username).equal('en_automation');
|
|
53
|
+
} catch (ex) {
|
|
54
|
+
expect(ex).to.be.empty;
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
it('Update password', async function () {
|
|
59
|
+
try {
|
|
60
|
+
updatePass.userId = userId;
|
|
61
|
+
const retData = await sm.admin.user.findByIdAndUpdatePassword(updatePass, session);
|
|
62
|
+
|
|
63
|
+
expect(retData).to.not.be.empty;
|
|
64
|
+
expect(retData).to.be.an('object');
|
|
65
|
+
expect(retData._id).equal(userId);
|
|
66
|
+
expect(retData.name).equal('Automation SM');
|
|
67
|
+
expect(retData.username).equal('en_automation');
|
|
68
|
+
} catch (ex) {
|
|
69
|
+
expect(ex).to.be.empty;
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
it('Rollback Update password', async function () {
|
|
74
|
+
try {
|
|
75
|
+
updatePass.oldPassword = '123456789';
|
|
76
|
+
updatePass.newPassword = '123456';
|
|
77
|
+
updatePass.id = userId;
|
|
78
|
+
const retData = await sm.admin.user.findByIdAndUpdatePassword(updatePass, session);
|
|
79
|
+
|
|
80
|
+
expect(retData).to.not.be.empty;
|
|
81
|
+
expect(retData).to.be.an('object');
|
|
82
|
+
expect(retData._id).equal(userId);
|
|
83
|
+
expect(retData.name).equal('Automation SM');
|
|
84
|
+
expect(retData.username).equal('en_automation');
|
|
85
|
+
} catch (ex) {
|
|
86
|
+
expect(ex).to.be.empty;
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
it('Email is unique', async function () {
|
|
91
|
+
try {
|
|
92
|
+
const retData = await sm.admin.user.emailExist(emailExist, session);
|
|
93
|
+
|
|
94
|
+
expect(retData).to.not.be.empty;
|
|
95
|
+
expect(retData).to.be.an('object');
|
|
96
|
+
expect(retData.exist).to.be.false;
|
|
97
|
+
} catch (ex) {
|
|
98
|
+
expect(ex).to.be.empty;
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
it('Email is not unique', async function () {
|
|
103
|
+
try {
|
|
104
|
+
emailExist = 'ana.breda@gmail.com';
|
|
105
|
+
const retData = await sm.admin.user.emailExist(emailExist, session);
|
|
106
|
+
|
|
107
|
+
expect(retData).to.not.be.empty;
|
|
108
|
+
expect(retData).to.be.an('object');
|
|
109
|
+
expect(retData.exist).to.be.true;
|
|
110
|
+
} catch (ex) {
|
|
111
|
+
expect(ex).to.be.empty;
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
it('Logout user', async function () {
|
|
116
|
+
try {
|
|
117
|
+
const retData = await sm.login.logout(session);
|
|
118
|
+
|
|
119
|
+
expect(retData).to.not.be.empty;
|
|
120
|
+
expect(retData).to.be.an('object');
|
|
121
|
+
expect(retData.response).to.not.be.empty;
|
|
122
|
+
expect(retData.response).equal('OK');
|
|
123
|
+
} catch (ex) {
|
|
124
|
+
expect(ex).to.be.empty;
|
|
125
|
+
}
|
|
126
|
+
});
|
|
127
|
+
});
|