@docbrasil/api-systemmanager 1.0.94 → 1.0.96
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 +23 -23
- 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 -730
- 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 -4875
- package/dist/bundle.mjs +1 -1
- package/doc/api.md +675 -337
- 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/task_available.js +75 -75
- package/tests/user/user.js +88 -88
package/tests/user/documents.js
CHANGED
|
@@ -1,164 +1,164 @@
|
|
|
1
|
-
const _ = require('lodash');
|
|
2
|
-
const expect = require('chai').expect;
|
|
3
|
-
|
|
4
|
-
const API = require('../index');
|
|
5
|
-
const login = require('./payload/payload_login');
|
|
6
|
-
|
|
7
|
-
let docCreateId;
|
|
8
|
-
let docIdAttr;
|
|
9
|
-
let sm;
|
|
10
|
-
let docs;
|
|
11
|
-
let setPayloadLogin = () => ({...login});
|
|
12
|
-
|
|
13
|
-
const index = 'extraCityname';
|
|
14
|
-
const txtToSearch = 'Palhoça';
|
|
15
|
-
const docId = '5e5945f650b526150f651717';
|
|
16
|
-
const docAreaId = '5db06b51f833e1047a27fd8b';
|
|
17
|
-
const projection = 'extraCityname,extraStateabbreviation';
|
|
18
|
-
const tag = 'Nome da cidade';
|
|
19
|
-
const paramsSignedUrlPut = {
|
|
20
|
-
methodType: 'put',
|
|
21
|
-
docId: '5edf86fbe896b817e45b8da6',
|
|
22
|
-
fileName: 'foto',
|
|
23
|
-
docAreaId: '5edf9f8ee896b817e45b8dac',
|
|
24
|
-
type: 'image/png',
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
const paramsSignedUrlGet = {
|
|
28
|
-
methodType: 'get',
|
|
29
|
-
document: 'foto'
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
describe('Start API documents', function () {
|
|
33
|
-
before(function (done) {
|
|
34
|
-
|
|
35
|
-
try {
|
|
36
|
-
sm = new API();
|
|
37
|
-
done();
|
|
38
|
-
} catch (ex) {
|
|
39
|
-
expect(ex).to.be.empty;
|
|
40
|
-
}
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
it('Login', async function () {
|
|
44
|
-
try {
|
|
45
|
-
const retData = await sm.access.loginSU();
|
|
46
|
-
|
|
47
|
-
expect(retData).to.not.be.empty;
|
|
48
|
-
expect(retData.auth).to.be.true;
|
|
49
|
-
expect(retData.user).to.be.an('object');
|
|
50
|
-
expect(retData.user).to.be.an('object');
|
|
51
|
-
expect(retData.user).to.not.be.empty;
|
|
52
|
-
expect(retData.user.sessionId).to.not.be.empty;
|
|
53
|
-
expect(retData.user.sessionId.split('.').length).equal(3);
|
|
54
|
-
expect(retData.user.orgId.length).equal(24);
|
|
55
|
-
} catch (ex) {
|
|
56
|
-
expect(ex).to.be.empty;
|
|
57
|
-
}
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
it('Search autocomplete', async function () {
|
|
61
|
-
try {
|
|
62
|
-
const params = {
|
|
63
|
-
index,
|
|
64
|
-
txtToSearch,
|
|
65
|
-
docId,
|
|
66
|
-
docAreaId,
|
|
67
|
-
tag,
|
|
68
|
-
projection
|
|
69
|
-
};
|
|
70
|
-
const retData = await sm.documents.autoComplete(params);
|
|
71
|
-
|
|
72
|
-
expect(retData).to.not.be.empty;
|
|
73
|
-
expect(retData).to.be.an('object');
|
|
74
|
-
expect(retData.count).equal(1);
|
|
75
|
-
expect(retData.page).equal(1);
|
|
76
|
-
expect(retData.items).to.be.an('array');
|
|
77
|
-
expect(retData.items).to.not.be.empty;
|
|
78
|
-
expect(retData.items.length).equal(1);
|
|
79
|
-
|
|
80
|
-
docIdAttr = retData.items[0]._id;
|
|
81
|
-
} catch (ex) {
|
|
82
|
-
expect(ex).to.be.empty;
|
|
83
|
-
}
|
|
84
|
-
});
|
|
85
|
-
|
|
86
|
-
it('Get attribuites of the document', async function () {
|
|
87
|
-
try {
|
|
88
|
-
const retData = await sm.documents.getById(docIdAttr);
|
|
89
|
-
|
|
90
|
-
expect(retData).to.not.be.empty;
|
|
91
|
-
expect(retData).to.be.an('object');
|
|
92
|
-
expect(retData).to.include.all.keys('_id', 'docTypeFields', 'docTypeFieldsData');
|
|
93
|
-
expect(retData.docTypeFields).to.not.be.empty;
|
|
94
|
-
expect(retData.docTypeFields).to.be.an('array');
|
|
95
|
-
expect(retData.docTypeFieldsData).to.not.be.empty;
|
|
96
|
-
expect(retData.docTypeFieldsData).to.be.an('object');
|
|
97
|
-
expect(retData._id).equal(docIdAttr)
|
|
98
|
-
} catch (ex) {
|
|
99
|
-
expect(ex).to.be.empty;
|
|
100
|
-
}
|
|
101
|
-
});
|
|
102
|
-
|
|
103
|
-
it('Get signedURL PUT', async function () {
|
|
104
|
-
try {
|
|
105
|
-
const retData = await sm.documents.getSignedUrl(paramsSignedUrlPut);
|
|
106
|
-
|
|
107
|
-
expect(retData).to.not.be.empty;
|
|
108
|
-
expect(retData).to.be.an('object');
|
|
109
|
-
expect(retData.docs).to.not.be.empty;
|
|
110
|
-
expect(retData.docs).to.be.an('array');
|
|
111
|
-
expect(retData.docs[0].signedUrl.indexOf('https://s3.amazonaws.com')).above(-1);
|
|
112
|
-
|
|
113
|
-
docs = {...retData.docs[0], bytes: 123456};
|
|
114
|
-
} catch (ex) {
|
|
115
|
-
expect(ex).to.be.empty;
|
|
116
|
-
}
|
|
117
|
-
});
|
|
118
|
-
|
|
119
|
-
it('Get signedURL GET', async function () {
|
|
120
|
-
try {
|
|
121
|
-
const retData = await sm.documents.getSignedUrl(paramsSignedUrlGet);
|
|
122
|
-
|
|
123
|
-
expect(retData).to.not.be.empty;
|
|
124
|
-
expect(retData).to.be.an('object');
|
|
125
|
-
expect(retData.docs).to.not.be.empty;
|
|
126
|
-
expect(retData.docs).to.be.an('array');
|
|
127
|
-
expect(retData.docs[0].signedUrl.indexOf('https://s3.amazonaws.com')).above(-1);
|
|
128
|
-
} catch (ex) {
|
|
129
|
-
expect(ex).to.be.empty;
|
|
130
|
-
}
|
|
131
|
-
});
|
|
132
|
-
|
|
133
|
-
it('Add document CV', async function () {
|
|
134
|
-
try {
|
|
135
|
-
docs.userId = '5739d4c6ccb0ebc61f2a9557';
|
|
136
|
-
docs.docTypeId = '5edf9f8ee896b817e45b8dac';
|
|
137
|
-
const retData = await sm.documents.createCV(docs);
|
|
138
|
-
|
|
139
|
-
expect(retData).to.not.be.empty;
|
|
140
|
-
expect(retData).to.be.an('object');
|
|
141
|
-
expect(retData._id).to.not.be.empty;
|
|
142
|
-
expect(retData._id).to.be.an('string');
|
|
143
|
-
expect(retData.orgname).equal('emprego.net');
|
|
144
|
-
expect(retData.name).equal('foto');
|
|
145
|
-
expect(retData.type).equal('image/png');
|
|
146
|
-
expect(retData.docTypeId).equal(docs.docTypeId);
|
|
147
|
-
docCreateId = retData._id;
|
|
148
|
-
} catch (ex) {
|
|
149
|
-
expect(ex).to.be.empty;
|
|
150
|
-
}
|
|
151
|
-
});
|
|
152
|
-
|
|
153
|
-
it('Remove document CV', async function () {
|
|
154
|
-
try {
|
|
155
|
-
const retData = await sm.documents.removeCV(docCreateId);
|
|
156
|
-
|
|
157
|
-
expect(retData).to.not.be.empty;
|
|
158
|
-
expect(retData).to.be.an('object');
|
|
159
|
-
expect(retData.removed).equal(1);
|
|
160
|
-
} catch (ex) {
|
|
161
|
-
expect(ex).to.be.empty;
|
|
162
|
-
}
|
|
163
|
-
});
|
|
164
|
-
});
|
|
1
|
+
const _ = require('lodash');
|
|
2
|
+
const expect = require('chai').expect;
|
|
3
|
+
|
|
4
|
+
const API = require('../index');
|
|
5
|
+
const login = require('./payload/payload_login');
|
|
6
|
+
|
|
7
|
+
let docCreateId;
|
|
8
|
+
let docIdAttr;
|
|
9
|
+
let sm;
|
|
10
|
+
let docs;
|
|
11
|
+
let setPayloadLogin = () => ({...login});
|
|
12
|
+
|
|
13
|
+
const index = 'extraCityname';
|
|
14
|
+
const txtToSearch = 'Palhoça';
|
|
15
|
+
const docId = '5e5945f650b526150f651717';
|
|
16
|
+
const docAreaId = '5db06b51f833e1047a27fd8b';
|
|
17
|
+
const projection = 'extraCityname,extraStateabbreviation';
|
|
18
|
+
const tag = 'Nome da cidade';
|
|
19
|
+
const paramsSignedUrlPut = {
|
|
20
|
+
methodType: 'put',
|
|
21
|
+
docId: '5edf86fbe896b817e45b8da6',
|
|
22
|
+
fileName: 'foto',
|
|
23
|
+
docAreaId: '5edf9f8ee896b817e45b8dac',
|
|
24
|
+
type: 'image/png',
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
const paramsSignedUrlGet = {
|
|
28
|
+
methodType: 'get',
|
|
29
|
+
document: 'foto'
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
describe('Start API documents', function () {
|
|
33
|
+
before(function (done) {
|
|
34
|
+
|
|
35
|
+
try {
|
|
36
|
+
sm = new API();
|
|
37
|
+
done();
|
|
38
|
+
} catch (ex) {
|
|
39
|
+
expect(ex).to.be.empty;
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
it('Login', async function () {
|
|
44
|
+
try {
|
|
45
|
+
const retData = await sm.access.loginSU();
|
|
46
|
+
|
|
47
|
+
expect(retData).to.not.be.empty;
|
|
48
|
+
expect(retData.auth).to.be.true;
|
|
49
|
+
expect(retData.user).to.be.an('object');
|
|
50
|
+
expect(retData.user).to.be.an('object');
|
|
51
|
+
expect(retData.user).to.not.be.empty;
|
|
52
|
+
expect(retData.user.sessionId).to.not.be.empty;
|
|
53
|
+
expect(retData.user.sessionId.split('.').length).equal(3);
|
|
54
|
+
expect(retData.user.orgId.length).equal(24);
|
|
55
|
+
} catch (ex) {
|
|
56
|
+
expect(ex).to.be.empty;
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
it('Search autocomplete', async function () {
|
|
61
|
+
try {
|
|
62
|
+
const params = {
|
|
63
|
+
index,
|
|
64
|
+
txtToSearch,
|
|
65
|
+
docId,
|
|
66
|
+
docAreaId,
|
|
67
|
+
tag,
|
|
68
|
+
projection
|
|
69
|
+
};
|
|
70
|
+
const retData = await sm.documents.autoComplete(params);
|
|
71
|
+
|
|
72
|
+
expect(retData).to.not.be.empty;
|
|
73
|
+
expect(retData).to.be.an('object');
|
|
74
|
+
expect(retData.count).equal(1);
|
|
75
|
+
expect(retData.page).equal(1);
|
|
76
|
+
expect(retData.items).to.be.an('array');
|
|
77
|
+
expect(retData.items).to.not.be.empty;
|
|
78
|
+
expect(retData.items.length).equal(1);
|
|
79
|
+
|
|
80
|
+
docIdAttr = retData.items[0]._id;
|
|
81
|
+
} catch (ex) {
|
|
82
|
+
expect(ex).to.be.empty;
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
it('Get attribuites of the document', async function () {
|
|
87
|
+
try {
|
|
88
|
+
const retData = await sm.documents.getById(docIdAttr);
|
|
89
|
+
|
|
90
|
+
expect(retData).to.not.be.empty;
|
|
91
|
+
expect(retData).to.be.an('object');
|
|
92
|
+
expect(retData).to.include.all.keys('_id', 'docTypeFields', 'docTypeFieldsData');
|
|
93
|
+
expect(retData.docTypeFields).to.not.be.empty;
|
|
94
|
+
expect(retData.docTypeFields).to.be.an('array');
|
|
95
|
+
expect(retData.docTypeFieldsData).to.not.be.empty;
|
|
96
|
+
expect(retData.docTypeFieldsData).to.be.an('object');
|
|
97
|
+
expect(retData._id).equal(docIdAttr)
|
|
98
|
+
} catch (ex) {
|
|
99
|
+
expect(ex).to.be.empty;
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
it('Get signedURL PUT', async function () {
|
|
104
|
+
try {
|
|
105
|
+
const retData = await sm.documents.getSignedUrl(paramsSignedUrlPut);
|
|
106
|
+
|
|
107
|
+
expect(retData).to.not.be.empty;
|
|
108
|
+
expect(retData).to.be.an('object');
|
|
109
|
+
expect(retData.docs).to.not.be.empty;
|
|
110
|
+
expect(retData.docs).to.be.an('array');
|
|
111
|
+
expect(retData.docs[0].signedUrl.indexOf('https://s3.amazonaws.com')).above(-1);
|
|
112
|
+
|
|
113
|
+
docs = {...retData.docs[0], bytes: 123456};
|
|
114
|
+
} catch (ex) {
|
|
115
|
+
expect(ex).to.be.empty;
|
|
116
|
+
}
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
it('Get signedURL GET', async function () {
|
|
120
|
+
try {
|
|
121
|
+
const retData = await sm.documents.getSignedUrl(paramsSignedUrlGet);
|
|
122
|
+
|
|
123
|
+
expect(retData).to.not.be.empty;
|
|
124
|
+
expect(retData).to.be.an('object');
|
|
125
|
+
expect(retData.docs).to.not.be.empty;
|
|
126
|
+
expect(retData.docs).to.be.an('array');
|
|
127
|
+
expect(retData.docs[0].signedUrl.indexOf('https://s3.amazonaws.com')).above(-1);
|
|
128
|
+
} catch (ex) {
|
|
129
|
+
expect(ex).to.be.empty;
|
|
130
|
+
}
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
it('Add document CV', async function () {
|
|
134
|
+
try {
|
|
135
|
+
docs.userId = '5739d4c6ccb0ebc61f2a9557';
|
|
136
|
+
docs.docTypeId = '5edf9f8ee896b817e45b8dac';
|
|
137
|
+
const retData = await sm.documents.createCV(docs);
|
|
138
|
+
|
|
139
|
+
expect(retData).to.not.be.empty;
|
|
140
|
+
expect(retData).to.be.an('object');
|
|
141
|
+
expect(retData._id).to.not.be.empty;
|
|
142
|
+
expect(retData._id).to.be.an('string');
|
|
143
|
+
expect(retData.orgname).equal('emprego.net');
|
|
144
|
+
expect(retData.name).equal('foto');
|
|
145
|
+
expect(retData.type).equal('image/png');
|
|
146
|
+
expect(retData.docTypeId).equal(docs.docTypeId);
|
|
147
|
+
docCreateId = retData._id;
|
|
148
|
+
} catch (ex) {
|
|
149
|
+
expect(ex).to.be.empty;
|
|
150
|
+
}
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
it('Remove document CV', async function () {
|
|
154
|
+
try {
|
|
155
|
+
const retData = await sm.documents.removeCV(docCreateId);
|
|
156
|
+
|
|
157
|
+
expect(retData).to.not.be.empty;
|
|
158
|
+
expect(retData).to.be.an('object');
|
|
159
|
+
expect(retData.removed).equal(1);
|
|
160
|
+
} catch (ex) {
|
|
161
|
+
expect(ex).to.be.empty;
|
|
162
|
+
}
|
|
163
|
+
});
|
|
164
|
+
});
|
|
@@ -1,122 +1,122 @@
|
|
|
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 retData;
|
|
10
|
-
let login = {username: 'ana.breda', password: '123456'};
|
|
11
|
-
let idCardExist = '94422089000128';
|
|
12
|
-
let orgId = '5dadd01dc4af3941d42f8c5c'; // Orgname Empregonet
|
|
13
|
-
|
|
14
|
-
describe('Start API users', function () {
|
|
15
|
-
before(function (done) {
|
|
16
|
-
|
|
17
|
-
try {
|
|
18
|
-
sm = new API();
|
|
19
|
-
done();
|
|
20
|
-
} catch (ex) {
|
|
21
|
-
expect(ex).to.be.null;
|
|
22
|
-
}
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
it('Login User', async function () {
|
|
26
|
-
try {
|
|
27
|
-
retData = await sm.login.userPass(login);
|
|
28
|
-
|
|
29
|
-
expect(retData).to.not.be.empty;
|
|
30
|
-
expect(retData.auth).to.be.true;
|
|
31
|
-
expect(retData.user).to.be.an('object');
|
|
32
|
-
expect(retData.user).to.be.an('object');
|
|
33
|
-
expect(retData.user).to.not.be.empty;
|
|
34
|
-
expect(retData.user.sessionId).to.not.be.empty;
|
|
35
|
-
expect(retData.user.sessionId.split('.').length).equal(3);
|
|
36
|
-
expect(retData.user.orgId.length).equal(24);
|
|
37
|
-
|
|
38
|
-
session = retData.user.sessionId;
|
|
39
|
-
userId = retData.user._id;
|
|
40
|
-
} catch (ex) {
|
|
41
|
-
expect(ex).to.be.null;
|
|
42
|
-
}
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
it('Id Card Exist', async function () {
|
|
46
|
-
try {
|
|
47
|
-
retData = await sm.user.organization.idCardExist(idCardExist, session);
|
|
48
|
-
|
|
49
|
-
expect(retData).to.not.be.empty;
|
|
50
|
-
expect(retData).to.be.an('object');
|
|
51
|
-
expect(retData.exist).to.be.true;
|
|
52
|
-
} catch (ex) {
|
|
53
|
-
expect(ex).to.be.null;
|
|
54
|
-
}
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
it('Id Card Not Exist', async function () {
|
|
58
|
-
try {
|
|
59
|
-
idCardExist = '94422089000129';
|
|
60
|
-
retData = await sm.user.organization.idCardExist(idCardExist, session);
|
|
61
|
-
|
|
62
|
-
expect(retData).to.not.be.empty;
|
|
63
|
-
expect(retData).to.be.an('object');
|
|
64
|
-
expect(retData.exist).to.be.false;
|
|
65
|
-
} catch (ex) {
|
|
66
|
-
expect(ex).to.be.null;
|
|
67
|
-
}
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
it('Get org by id - OK', async function () {
|
|
71
|
-
try {
|
|
72
|
-
retData = await sm.user.organization.findById(orgId, session);
|
|
73
|
-
|
|
74
|
-
expect(retData).to.not.be.empty;
|
|
75
|
-
expect(retData).to.be.an('object');
|
|
76
|
-
expect(retData._id).to.equal(orgId);
|
|
77
|
-
expect(retData.orgname).to.equal('empregonet');
|
|
78
|
-
expect(retData.name).to.equal('emprego.net');
|
|
79
|
-
} catch (ex) {
|
|
80
|
-
expect(ex).to.be.null;
|
|
81
|
-
}
|
|
82
|
-
});
|
|
83
|
-
|
|
84
|
-
it('Get org by id - NOT FOUND', async function () {
|
|
85
|
-
try {
|
|
86
|
-
retData = await sm.user.organization.findById('012345678901234567891234', session);
|
|
87
|
-
} catch (ex) {
|
|
88
|
-
expect(ex.output.statusCode).to.equal(404);
|
|
89
|
-
expect(ex.message).to.equal('Organization not found with informed id!');
|
|
90
|
-
}
|
|
91
|
-
});
|
|
92
|
-
|
|
93
|
-
it('Fetch URL', async function () {
|
|
94
|
-
try {
|
|
95
|
-
const setParams = {
|
|
96
|
-
method: 'POST',
|
|
97
|
-
url: 'http://localhost:8080/organizations/5dadd01dc4af3941d42f8c5c/process/b32ab980f21811ea8879bbc12d8d05a7/task/candidateAccepted/end/44e4ef2bfbe5d41c94141370345529e1'
|
|
98
|
-
}
|
|
99
|
-
retData = await sm.user.organization.callFetch(setParams, session);
|
|
100
|
-
expect(retData).to.not.be.empty;
|
|
101
|
-
expect(retData).to.be.an('object');
|
|
102
|
-
expect(retData.response).to.not.be.empty;
|
|
103
|
-
expect(retData.response).equal('OK');
|
|
104
|
-
} catch (ex) {
|
|
105
|
-
expect(ex.output.statusCode).to.equal(404);
|
|
106
|
-
expect(ex.message).to.equal('Organization not found with informed id!');
|
|
107
|
-
}
|
|
108
|
-
});
|
|
109
|
-
|
|
110
|
-
it('Logout user', async function () {
|
|
111
|
-
try {
|
|
112
|
-
retData = await sm.login.logout(session);
|
|
113
|
-
|
|
114
|
-
expect(retData).to.not.be.empty;
|
|
115
|
-
expect(retData).to.be.an('object');
|
|
116
|
-
expect(retData.response).to.not.be.empty;
|
|
117
|
-
expect(retData.response).equal('OK');
|
|
118
|
-
} catch (ex) {
|
|
119
|
-
expect(ex).to.be.null;
|
|
120
|
-
}
|
|
121
|
-
});
|
|
122
|
-
});
|
|
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 retData;
|
|
10
|
+
let login = {username: 'ana.breda', password: '123456'};
|
|
11
|
+
let idCardExist = '94422089000128';
|
|
12
|
+
let orgId = '5dadd01dc4af3941d42f8c5c'; // Orgname Empregonet
|
|
13
|
+
|
|
14
|
+
describe('Start API users', function () {
|
|
15
|
+
before(function (done) {
|
|
16
|
+
|
|
17
|
+
try {
|
|
18
|
+
sm = new API();
|
|
19
|
+
done();
|
|
20
|
+
} catch (ex) {
|
|
21
|
+
expect(ex).to.be.null;
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
it('Login User', async function () {
|
|
26
|
+
try {
|
|
27
|
+
retData = await sm.login.userPass(login);
|
|
28
|
+
|
|
29
|
+
expect(retData).to.not.be.empty;
|
|
30
|
+
expect(retData.auth).to.be.true;
|
|
31
|
+
expect(retData.user).to.be.an('object');
|
|
32
|
+
expect(retData.user).to.be.an('object');
|
|
33
|
+
expect(retData.user).to.not.be.empty;
|
|
34
|
+
expect(retData.user.sessionId).to.not.be.empty;
|
|
35
|
+
expect(retData.user.sessionId.split('.').length).equal(3);
|
|
36
|
+
expect(retData.user.orgId.length).equal(24);
|
|
37
|
+
|
|
38
|
+
session = retData.user.sessionId;
|
|
39
|
+
userId = retData.user._id;
|
|
40
|
+
} catch (ex) {
|
|
41
|
+
expect(ex).to.be.null;
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
it('Id Card Exist', async function () {
|
|
46
|
+
try {
|
|
47
|
+
retData = await sm.user.organization.idCardExist(idCardExist, session);
|
|
48
|
+
|
|
49
|
+
expect(retData).to.not.be.empty;
|
|
50
|
+
expect(retData).to.be.an('object');
|
|
51
|
+
expect(retData.exist).to.be.true;
|
|
52
|
+
} catch (ex) {
|
|
53
|
+
expect(ex).to.be.null;
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
it('Id Card Not Exist', async function () {
|
|
58
|
+
try {
|
|
59
|
+
idCardExist = '94422089000129';
|
|
60
|
+
retData = await sm.user.organization.idCardExist(idCardExist, session);
|
|
61
|
+
|
|
62
|
+
expect(retData).to.not.be.empty;
|
|
63
|
+
expect(retData).to.be.an('object');
|
|
64
|
+
expect(retData.exist).to.be.false;
|
|
65
|
+
} catch (ex) {
|
|
66
|
+
expect(ex).to.be.null;
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
it('Get org by id - OK', async function () {
|
|
71
|
+
try {
|
|
72
|
+
retData = await sm.user.organization.findById(orgId, session);
|
|
73
|
+
|
|
74
|
+
expect(retData).to.not.be.empty;
|
|
75
|
+
expect(retData).to.be.an('object');
|
|
76
|
+
expect(retData._id).to.equal(orgId);
|
|
77
|
+
expect(retData.orgname).to.equal('empregonet');
|
|
78
|
+
expect(retData.name).to.equal('emprego.net');
|
|
79
|
+
} catch (ex) {
|
|
80
|
+
expect(ex).to.be.null;
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
it('Get org by id - NOT FOUND', async function () {
|
|
85
|
+
try {
|
|
86
|
+
retData = await sm.user.organization.findById('012345678901234567891234', session);
|
|
87
|
+
} catch (ex) {
|
|
88
|
+
expect(ex.output.statusCode).to.equal(404);
|
|
89
|
+
expect(ex.message).to.equal('Organization not found with informed id!');
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
it('Fetch URL', async function () {
|
|
94
|
+
try {
|
|
95
|
+
const setParams = {
|
|
96
|
+
method: 'POST',
|
|
97
|
+
url: 'http://localhost:8080/organizations/5dadd01dc4af3941d42f8c5c/process/b32ab980f21811ea8879bbc12d8d05a7/task/candidateAccepted/end/44e4ef2bfbe5d41c94141370345529e1'
|
|
98
|
+
}
|
|
99
|
+
retData = await sm.user.organization.callFetch(setParams, session);
|
|
100
|
+
expect(retData).to.not.be.empty;
|
|
101
|
+
expect(retData).to.be.an('object');
|
|
102
|
+
expect(retData.response).to.not.be.empty;
|
|
103
|
+
expect(retData.response).equal('OK');
|
|
104
|
+
} catch (ex) {
|
|
105
|
+
expect(ex.output.statusCode).to.equal(404);
|
|
106
|
+
expect(ex.message).to.equal('Organization not found with informed id!');
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
it('Logout user', async function () {
|
|
111
|
+
try {
|
|
112
|
+
retData = await sm.login.logout(session);
|
|
113
|
+
|
|
114
|
+
expect(retData).to.not.be.empty;
|
|
115
|
+
expect(retData).to.be.an('object');
|
|
116
|
+
expect(retData.response).to.not.be.empty;
|
|
117
|
+
expect(retData.response).equal('OK');
|
|
118
|
+
} catch (ex) {
|
|
119
|
+
expect(ex).to.be.null;
|
|
120
|
+
}
|
|
121
|
+
});
|
|
122
|
+
});
|