@docbrasil/api-systemmanager 1.0.97 → 1.0.99

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.
Files changed (59) hide show
  1. package/api/admin/doctypes.js +76 -76
  2. package/api/admin/document.js +332 -332
  3. package/api/admin/form.js +151 -151
  4. package/api/admin/index.js +46 -46
  5. package/api/admin/list.js +133 -133
  6. package/api/admin/message.js +194 -194
  7. package/api/admin/notification.js +233 -233
  8. package/api/admin/organization.js +124 -124
  9. package/api/admin/plugin.js +116 -116
  10. package/api/admin/policy.js +78 -78
  11. package/api/admin/processes.js +370 -370
  12. package/api/admin/task.js +125 -125
  13. package/api/admin/user.js +185 -185
  14. package/api/dispatch.js +101 -101
  15. package/api/external.js +86 -0
  16. package/api/general/geoLocation.js +88 -88
  17. package/api/general/index.js +23 -23
  18. package/api/login.js +267 -267
  19. package/api/session.js +85 -85
  20. package/api/user/datasource.js +144 -144
  21. package/api/user/document.js +730 -730
  22. package/api/user/index.js +39 -39
  23. package/api/user/notification.js +101 -101
  24. package/api/user/organization.js +230 -230
  25. package/api/user/process.js +191 -191
  26. package/api/user/register.js +205 -205
  27. package/api/user/task.js +201 -202
  28. package/api/user/task_available.js +135 -135
  29. package/api/user/user.js +287 -287
  30. package/api/utils/cypher.js +37 -37
  31. package/api/utils/promises.js +118 -118
  32. package/bundleRollup.js +158 -158
  33. package/dist/bundle.cjs +4957 -4876
  34. package/dist/bundle.mjs +1 -1
  35. package/doc/api.md +2453 -2453
  36. package/doc.md +653 -653
  37. package/helper/boom.js +487 -487
  38. package/helper/cryptojs.js +6067 -6067
  39. package/index.js +87 -85
  40. package/package-lock.json +4635 -4635
  41. package/package.json +68 -68
  42. package/readme.md +25 -25
  43. package/tests/admin/document.spec.js +45 -45
  44. package/tests/admin/form.spec.js +74 -74
  45. package/tests/admin/list.spec.js +86 -86
  46. package/tests/admin/message.js +92 -92
  47. package/tests/admin/notification.spec.js +174 -174
  48. package/tests/admin/pluginspec..js +71 -71
  49. package/tests/admin/policy.spec.js +71 -71
  50. package/tests/admin/processes.spec.js +119 -119
  51. package/tests/admin/users.spec.js +127 -127
  52. package/tests/documents.spec.js +164 -164
  53. package/tests/login.spec.js +91 -91
  54. package/tests/session.spec..js +58 -58
  55. package/tests/user/documents.js +164 -164
  56. package/tests/user/organization.js +122 -122
  57. package/tests/user/process.js +71 -71
  58. package/tests/user/task_available.js +75 -75
  59. package/tests/user/user.js +88 -88
@@ -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,91 +1,91 @@
1
- const _ = require('lodash');
2
- const expect = require('chai').expect;
3
- const API = require('../index');
4
-
5
- let session;
6
- let sm;
7
-
8
- let facebookAccessToken = 'EAAKCTEy0o0UBACCX4ZB3WEdRVhjlS4ZArMf0QHOstZA4nul9PZB1HcnkngpLZCRnzCP3zUgCZBvrYlqnQFfkPU1FBEa4Lentj0YPTXJiOqkTmWZANCgsmZBr4aP3VEkatZB5usmkOxQuJ9aCPXy2PZARfdWzekBY3i1b8gtRA0c0YejQZDZD';
9
- let apiKey = '25c04b9a-0f6b-11ea-8d71-362b9e155667';
10
- let googleAccessToken = 'ya29.a0AfH6SMCB76tDDIekmlJALX3RIbdZNE-VBj3R2_83zUSJRnAZt_oxMBrRzgLwGSJQxyJU0tHkDVEjFsHmOTYMxYz2TL6QHwZtaXLL-mJUGJ8UqmbBLKz_BWHUh5U_y3C7UMtPCsM3JLsCevnWtuvcPWdYxfQ1yIRFfj4';
11
- let userpass = {username: 'ana.breda@gmail.com', password: '123456'};
12
-
13
- describe('Start API access', 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 facebook', async function () {
25
- try {
26
- const retData = await sm.login.facebook({ accessToken: facebookAccessToken });
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
- } catch (ex) {
36
- expect(ex).to.be.empty;
37
- }
38
- });
39
-
40
- it('Login Google', async function () {
41
- try {
42
- const retData = await sm.login.google({ accessToken: googleAccessToken });
43
-
44
- expect(retData).to.not.be.empty;
45
- expect(retData.auth).to.be.true;
46
- expect(retData.user).to.be.an('object');
47
- expect(retData.user).to.be.an('object');
48
- expect(retData.user).to.not.be.empty;
49
- expect(retData.user.sessionId).to.not.be.empty;
50
- expect(retData.user.sessionId.split('.').length).equal(3);
51
-
52
- session = retData.user.sessionId;
53
- } catch (ex) {
54
- expect(ex).to.be.empty;
55
- }
56
- });
57
-
58
- it('Login User and Pass', async function () {
59
- try {
60
- const retData = await sm.login.userPass(userpass);
61
-
62
- expect(retData).to.not.be.empty;
63
- expect(retData.auth).to.be.true;
64
- expect(retData.user).to.be.an('object');
65
- expect(retData.user).to.be.an('object');
66
- expect(retData.user).to.not.be.empty;
67
- expect(retData.user.sessionId).to.not.be.empty;
68
- expect(retData.user.sessionId.split('.').length).equal(3);
69
- expect(retData.user.orgId.length).equal(24);
70
- } catch (ex) {
71
- expect(ex).to.be.empty;
72
- }
73
- });
74
-
75
- it('Login API Key', async function () {
76
- try {
77
- const retData = await sm.login.apiKey(apiKey);
78
-
79
- expect(retData).to.not.be.empty;
80
- expect(retData.auth).to.be.true;
81
- expect(retData.user).to.be.an('object');
82
- expect(retData.user).to.be.an('object');
83
- expect(retData.user).to.not.be.empty;
84
- expect(retData.user.sessionId).to.not.be.empty;
85
- expect(retData.user.sessionId.split('.').length).equal(3);
86
- expect(retData.user.orgId.length).equal(24);
87
- } catch (ex) {
88
- expect(ex).to.be.empty;
89
- }
90
- });
91
- });
1
+ const _ = require('lodash');
2
+ const expect = require('chai').expect;
3
+ const API = require('../index');
4
+
5
+ let session;
6
+ let sm;
7
+
8
+ let facebookAccessToken = 'EAAKCTEy0o0UBACCX4ZB3WEdRVhjlS4ZArMf0QHOstZA4nul9PZB1HcnkngpLZCRnzCP3zUgCZBvrYlqnQFfkPU1FBEa4Lentj0YPTXJiOqkTmWZANCgsmZBr4aP3VEkatZB5usmkOxQuJ9aCPXy2PZARfdWzekBY3i1b8gtRA0c0YejQZDZD';
9
+ let apiKey = '25c04b9a-0f6b-11ea-8d71-362b9e155667';
10
+ let googleAccessToken = 'ya29.a0AfH6SMCB76tDDIekmlJALX3RIbdZNE-VBj3R2_83zUSJRnAZt_oxMBrRzgLwGSJQxyJU0tHkDVEjFsHmOTYMxYz2TL6QHwZtaXLL-mJUGJ8UqmbBLKz_BWHUh5U_y3C7UMtPCsM3JLsCevnWtuvcPWdYxfQ1yIRFfj4';
11
+ let userpass = {username: 'ana.breda@gmail.com', password: '123456'};
12
+
13
+ describe('Start API access', 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 facebook', async function () {
25
+ try {
26
+ const retData = await sm.login.facebook({ accessToken: facebookAccessToken });
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
+ } catch (ex) {
36
+ expect(ex).to.be.empty;
37
+ }
38
+ });
39
+
40
+ it('Login Google', async function () {
41
+ try {
42
+ const retData = await sm.login.google({ accessToken: googleAccessToken });
43
+
44
+ expect(retData).to.not.be.empty;
45
+ expect(retData.auth).to.be.true;
46
+ expect(retData.user).to.be.an('object');
47
+ expect(retData.user).to.be.an('object');
48
+ expect(retData.user).to.not.be.empty;
49
+ expect(retData.user.sessionId).to.not.be.empty;
50
+ expect(retData.user.sessionId.split('.').length).equal(3);
51
+
52
+ session = retData.user.sessionId;
53
+ } catch (ex) {
54
+ expect(ex).to.be.empty;
55
+ }
56
+ });
57
+
58
+ it('Login User and Pass', async function () {
59
+ try {
60
+ const retData = await sm.login.userPass(userpass);
61
+
62
+ expect(retData).to.not.be.empty;
63
+ expect(retData.auth).to.be.true;
64
+ expect(retData.user).to.be.an('object');
65
+ expect(retData.user).to.be.an('object');
66
+ expect(retData.user).to.not.be.empty;
67
+ expect(retData.user.sessionId).to.not.be.empty;
68
+ expect(retData.user.sessionId.split('.').length).equal(3);
69
+ expect(retData.user.orgId.length).equal(24);
70
+ } catch (ex) {
71
+ expect(ex).to.be.empty;
72
+ }
73
+ });
74
+
75
+ it('Login API Key', async function () {
76
+ try {
77
+ const retData = await sm.login.apiKey(apiKey);
78
+
79
+ expect(retData).to.not.be.empty;
80
+ expect(retData.auth).to.be.true;
81
+ expect(retData.user).to.be.an('object');
82
+ expect(retData.user).to.be.an('object');
83
+ expect(retData.user).to.not.be.empty;
84
+ expect(retData.user.sessionId).to.not.be.empty;
85
+ expect(retData.user.sessionId.split('.').length).equal(3);
86
+ expect(retData.user.orgId.length).equal(24);
87
+ } catch (ex) {
88
+ expect(ex).to.be.empty;
89
+ }
90
+ });
91
+ });
@@ -1,58 +1,58 @@
1
- const _ = require('lodash');
2
- const expect = require('chai').expect;
3
- const API = require('../index');
4
-
5
- let session;
6
- let sm;
7
-
8
- let apiKey = '25c04b9a-0f6b-11ea-8d71-362b9e155667';
9
- let userpass = {username: 'ana.breda@gmail.com', password: '123456'};
10
-
11
- describe('Start API access', function () {
12
- before(function (done) {
13
-
14
- try {
15
- sm = new API();
16
- done();
17
- } catch (ex) {
18
- expect(ex).to.be.empty;
19
- }
20
- });
21
-
22
- it('Login API Key', async function () {
23
- try {
24
- const retData = await sm.login.apiKey(apiKey);
25
-
26
- expect(retData).to.not.be.empty;
27
- expect(retData.auth).to.be.true;
28
- expect(retData.user).to.be.an('object');
29
- expect(retData.user).to.be.an('object');
30
- expect(retData.user).to.not.be.empty;
31
- expect(retData.user.sessionId).to.not.be.empty;
32
- expect(retData.user.sessionId.split('.').length).equal(3);
33
- expect(retData.user.orgId.length).equal(24);
34
-
35
- session = retData.user.sessionId
36
- } catch (ex) {
37
- expect(ex).to.be.empty;
38
- }
39
- });
40
-
41
- it('Session information by sessionID', async function () {
42
- try {
43
- const retData = await sm.session.information(session, session);
44
-
45
- expect(retData).to.not.be.empty;
46
- expect(retData).to.be.an('object');
47
- expect(retData._id).to.not.be.empty;
48
- expect(retData._id).to.be.an('string');
49
- expect(retData._id.length).equal(24);
50
-
51
- expect(retData.orgId).to.not.be.empty;
52
- expect(retData.orgId).to.be.an('string');
53
- expect(retData.orgId.length).equal(24);
54
- } catch (ex) {
55
- expect(ex).to.be.empty;
56
- }
57
- });
58
- });
1
+ const _ = require('lodash');
2
+ const expect = require('chai').expect;
3
+ const API = require('../index');
4
+
5
+ let session;
6
+ let sm;
7
+
8
+ let apiKey = '25c04b9a-0f6b-11ea-8d71-362b9e155667';
9
+ let userpass = {username: 'ana.breda@gmail.com', password: '123456'};
10
+
11
+ describe('Start API access', function () {
12
+ before(function (done) {
13
+
14
+ try {
15
+ sm = new API();
16
+ done();
17
+ } catch (ex) {
18
+ expect(ex).to.be.empty;
19
+ }
20
+ });
21
+
22
+ it('Login API Key', async function () {
23
+ try {
24
+ const retData = await sm.login.apiKey(apiKey);
25
+
26
+ expect(retData).to.not.be.empty;
27
+ expect(retData.auth).to.be.true;
28
+ expect(retData.user).to.be.an('object');
29
+ expect(retData.user).to.be.an('object');
30
+ expect(retData.user).to.not.be.empty;
31
+ expect(retData.user.sessionId).to.not.be.empty;
32
+ expect(retData.user.sessionId.split('.').length).equal(3);
33
+ expect(retData.user.orgId.length).equal(24);
34
+
35
+ session = retData.user.sessionId
36
+ } catch (ex) {
37
+ expect(ex).to.be.empty;
38
+ }
39
+ });
40
+
41
+ it('Session information by sessionID', async function () {
42
+ try {
43
+ const retData = await sm.session.information(session, session);
44
+
45
+ expect(retData).to.not.be.empty;
46
+ expect(retData).to.be.an('object');
47
+ expect(retData._id).to.not.be.empty;
48
+ expect(retData._id).to.be.an('string');
49
+ expect(retData._id.length).equal(24);
50
+
51
+ expect(retData.orgId).to.not.be.empty;
52
+ expect(retData.orgId).to.be.an('string');
53
+ expect(retData.orgId.length).equal(24);
54
+ } catch (ex) {
55
+ expect(ex).to.be.empty;
56
+ }
57
+ });
58
+ });