soajs.multitenant 2.0.34 → 2.0.38
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/.travis.yml +5 -3
- package/bl/tenant.js +4 -0
- package/config.js +2 -2
- package/package.json +6 -5
- package/test/data/provision_integration/resources/dash_cluster.js +1 -2
- package/test/integration/product/delete/deleteProduct.test.js +4 -4
- package/test/integration/product/schemas/deleteProduct.js +4 -4
- package/test/integration/tenant/get/getTenant.test.js +1 -1
- package/test/integration/tenant/schemas/deleteTenant.js +37 -38
- package/test/unit/bl/index.test.js +2 -3
- package/test/unit/model/mongo/product.indexes.test.js +74 -75
- package/test/unit/model/mongo/product.test.js +5 -9
- package/test/unit/model/mongo/tenant.indexes.test.js +74 -75
- package/test/unit/model/mongo/tenant.test.js +429 -433
package/.travis.yml
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
language: node_js
|
|
2
2
|
|
|
3
|
-
node_js:
|
|
3
|
+
node_js: 16
|
|
4
4
|
|
|
5
5
|
jobs:
|
|
6
6
|
include:
|
|
@@ -46,7 +46,7 @@ jobs:
|
|
|
46
46
|
- git config --local user.email ${GIT_EMAIL}
|
|
47
47
|
- git tag ${PACKAGE_VERSION}
|
|
48
48
|
|
|
49
|
-
- docker login -u $DOCKER_USERNAME -
|
|
49
|
+
- echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin
|
|
50
50
|
|
|
51
51
|
- docker build -t soajsorg/multitenant .
|
|
52
52
|
|
|
@@ -56,9 +56,11 @@ jobs:
|
|
|
56
56
|
- docker tag soajsorg/multitenant:latest soajsorg/multitenant:${MAJOR_VERSION}.x
|
|
57
57
|
|
|
58
58
|
- docker push soajsorg/multitenant
|
|
59
|
+
- docker push soajsorg/multitenant:${PACKAGE_VERSION}
|
|
60
|
+
- docker push soajsorg/multitenant:${MAJOR_VERSION}.x
|
|
59
61
|
deploy:
|
|
60
62
|
on:
|
|
61
63
|
all_branches: true
|
|
62
64
|
provider: releases
|
|
63
65
|
api_key: ${GIT_TOKEN}
|
|
64
|
-
skip_cleanup: true
|
|
66
|
+
skip_cleanup: true
|
package/bl/tenant.js
CHANGED
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
'use strict';
|
|
10
|
+
const uuid = require("uuid");
|
|
10
11
|
const async = require('async');
|
|
11
12
|
const request = require("request");
|
|
12
13
|
|
|
@@ -494,6 +495,9 @@ let bl = {
|
|
|
494
495
|
}
|
|
495
496
|
if (inputmaskData.oauth) {
|
|
496
497
|
record.oauth = inputmaskData.oauth;
|
|
498
|
+
if (!record.oauth.secret || record.oauth.secret === "") {
|
|
499
|
+
record.oauth.secret = uuid.v4();
|
|
500
|
+
}
|
|
497
501
|
}
|
|
498
502
|
if (inputmaskData.profile) {
|
|
499
503
|
record.profile = inputmaskData.profile;
|
package/config.js
CHANGED
|
@@ -1421,7 +1421,7 @@ module.exports = {
|
|
|
1421
1421
|
"type": "object"
|
|
1422
1422
|
}
|
|
1423
1423
|
},
|
|
1424
|
-
"required": ["secret", "
|
|
1424
|
+
"required": ["secret", "disabled", "type", "loginMode"]
|
|
1425
1425
|
}
|
|
1426
1426
|
},
|
|
1427
1427
|
"application": {
|
|
@@ -1839,7 +1839,7 @@ module.exports = {
|
|
|
1839
1839
|
"type": "object"
|
|
1840
1840
|
}
|
|
1841
1841
|
},
|
|
1842
|
-
"required": ["loginMode", "type", "disabled", "
|
|
1842
|
+
"required": ["loginMode", "type", "disabled", "secret"]
|
|
1843
1843
|
}
|
|
1844
1844
|
},
|
|
1845
1845
|
"application": {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "soajs.multitenant",
|
|
3
3
|
"description": "soajs multitenant service",
|
|
4
|
-
"version": "2.0.
|
|
4
|
+
"version": "2.0.38",
|
|
5
5
|
"author": "soajs team <team@soajs.org>",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -31,11 +31,12 @@
|
|
|
31
31
|
"mocha": "6.2.2",
|
|
32
32
|
"nock": "13.0.3",
|
|
33
33
|
"request": "2.88.2",
|
|
34
|
-
"soajs.controller": "4.0.
|
|
34
|
+
"soajs.controller": "4.0.48"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"async": "3.2.
|
|
38
|
-
"soajs": "4.0.
|
|
39
|
-
"soajs.core.libs": "1.2.0"
|
|
37
|
+
"async": "3.2.2",
|
|
38
|
+
"soajs": "4.0.33",
|
|
39
|
+
"soajs.core.libs": "1.2.0",
|
|
40
|
+
"uuid": "8.3.2"
|
|
40
41
|
}
|
|
41
42
|
}
|
|
@@ -105,10 +105,10 @@ describe("Testing delete product API", () => {
|
|
|
105
105
|
assert.ifError(error);
|
|
106
106
|
assert.ok(body);
|
|
107
107
|
assert.ok(body.data);
|
|
108
|
-
assert.
|
|
108
|
+
assert.strictEqual(body.data.acknowledged, true);
|
|
109
109
|
let check = validator.validate(body, deleteProductSchema);
|
|
110
|
-
assert.
|
|
111
|
-
assert.
|
|
110
|
+
assert.strictEqual(check.valid, true);
|
|
111
|
+
assert.deepStrictEqual(check.errors, []);
|
|
112
112
|
done();
|
|
113
113
|
});
|
|
114
114
|
|
|
@@ -173,4 +173,4 @@ describe("Testing delete product API", () => {
|
|
|
173
173
|
done();
|
|
174
174
|
});
|
|
175
175
|
});
|
|
176
|
-
});
|
|
176
|
+
});
|
|
@@ -22,12 +22,12 @@ let deleteProductSchema = {
|
|
|
22
22
|
"type": "object",
|
|
23
23
|
"required": false,
|
|
24
24
|
"properties": {
|
|
25
|
-
"
|
|
25
|
+
"deletedCount": {
|
|
26
26
|
"type": "integer",
|
|
27
27
|
"required": true
|
|
28
28
|
},
|
|
29
|
-
"
|
|
30
|
-
"type": "
|
|
29
|
+
"acknowledged": {
|
|
30
|
+
"type": "boolean",
|
|
31
31
|
"required": true
|
|
32
32
|
}
|
|
33
33
|
}
|
|
@@ -49,4 +49,4 @@ let deleteProductSchema = {
|
|
|
49
49
|
}
|
|
50
50
|
};
|
|
51
51
|
|
|
52
|
-
module.exports = deleteProductSchema;
|
|
52
|
+
module.exports = deleteProductSchema;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
|
|
2
1
|
/**
|
|
3
2
|
* @license
|
|
4
3
|
* Copyright SOAJS All Rights Reserved.
|
|
@@ -10,43 +9,43 @@
|
|
|
10
9
|
"use strict";
|
|
11
10
|
|
|
12
11
|
let deleteTenantsSchema = {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
12
|
+
"type": "object",
|
|
13
|
+
"required": true,
|
|
14
|
+
"additionalProperties": false,
|
|
15
|
+
"properties": {
|
|
16
|
+
"result": {
|
|
17
|
+
"type": "boolean",
|
|
18
|
+
"required": true
|
|
19
|
+
},
|
|
20
|
+
"data": {
|
|
21
|
+
"type": "object",
|
|
22
|
+
"required": false,
|
|
23
|
+
"properties": {
|
|
24
|
+
"deletedCount": {
|
|
25
|
+
"type": "integer",
|
|
26
|
+
"required": true
|
|
27
|
+
},
|
|
28
|
+
"acknowledged": {
|
|
29
|
+
"type": "boolean",
|
|
30
|
+
"required": true
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
"errors": {
|
|
35
|
+
"type": "object",
|
|
36
|
+
"required": false,
|
|
37
|
+
"properties": {
|
|
38
|
+
"codes": {
|
|
39
|
+
"type": "array",
|
|
40
|
+
"required": true
|
|
41
|
+
},
|
|
42
|
+
"details": {
|
|
43
|
+
"type": "array",
|
|
44
|
+
"required": true
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
50
49
|
};
|
|
51
50
|
|
|
52
51
|
module.exports = deleteTenantsSchema;
|
|
@@ -71,8 +71,7 @@ describe("Unit test for: BLs", () => {
|
|
|
71
71
|
],
|
|
72
72
|
"credentials": null,
|
|
73
73
|
"URLParam": {
|
|
74
|
-
|
|
75
|
-
"autoReconnect": true
|
|
74
|
+
"useUnifiedTopology": true
|
|
76
75
|
}
|
|
77
76
|
}
|
|
78
77
|
}
|
|
@@ -89,4 +88,4 @@ describe("Unit test for: BLs", () => {
|
|
|
89
88
|
});
|
|
90
89
|
});
|
|
91
90
|
|
|
92
|
-
});
|
|
91
|
+
});
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
|
|
2
1
|
/**
|
|
3
2
|
* @license
|
|
4
3
|
* Copyright SOAJS All Rights Reserved.
|
|
@@ -14,77 +13,77 @@ const Product = helper.requireModule('model/mongo/product.js');
|
|
|
14
13
|
const assert = require('assert');
|
|
15
14
|
|
|
16
15
|
describe("Unit test for: Model - product - indexes", () => {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
});
|
|
16
|
+
let model;
|
|
17
|
+
let service = {
|
|
18
|
+
config: {
|
|
19
|
+
"errors": {},
|
|
20
|
+
},
|
|
21
|
+
log: {
|
|
22
|
+
error: () => {
|
|
23
|
+
console.log();
|
|
24
|
+
},
|
|
25
|
+
debug: () => {
|
|
26
|
+
console.log();
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
registry: {
|
|
30
|
+
get: () => {
|
|
31
|
+
return {
|
|
32
|
+
coreDB: {
|
|
33
|
+
provision: {
|
|
34
|
+
"name": "core_provision",
|
|
35
|
+
"prefix": '',
|
|
36
|
+
"servers": [
|
|
37
|
+
{
|
|
38
|
+
"host": "127.0.0.1",
|
|
39
|
+
"port": 27017
|
|
40
|
+
}
|
|
41
|
+
],
|
|
42
|
+
"credentials": null,
|
|
43
|
+
"URLParam": {
|
|
44
|
+
"useUnifiedTopology": true
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
before((done) => {
|
|
54
|
+
model = new Product(service);
|
|
55
|
+
done();
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
afterEach((done) => {
|
|
59
|
+
done();
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
it('Fails - Add Product - Code Exists - Index unique', (done) => {
|
|
63
|
+
model.addProduct({
|
|
64
|
+
name: "Console UI Product",
|
|
65
|
+
code: "DSBRD"
|
|
66
|
+
}, (err) => {
|
|
67
|
+
// assert.deepEqual(err.name, 'MongoServerError');
|
|
68
|
+
assert.ok(err.message.indexOf("E11000 duplicate key") !== -1);
|
|
69
|
+
// assert.deepEqual(err.message, 'E11000 duplicate key error collection: core_provision.products index: code_1 dup key: { code: "DSBRD" }');
|
|
70
|
+
assert.ok(err);
|
|
71
|
+
done();
|
|
72
|
+
});
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
it('Fails - Add Product - Code null - Index unique', (done) => {
|
|
76
|
+
model.addProduct({
|
|
77
|
+
name: "Console UI Product",
|
|
78
|
+
code: null
|
|
79
|
+
}, (err) => {
|
|
80
|
+
assert.ok(err);
|
|
81
|
+
done();
|
|
82
|
+
});
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
it("Success - closeConnection", (done) => {
|
|
86
|
+
model.closeConnection();
|
|
87
|
+
done();
|
|
88
|
+
});
|
|
89
|
+
});
|
|
@@ -41,8 +41,7 @@ describe("Unit test for: Model - product", () => {
|
|
|
41
41
|
],
|
|
42
42
|
"credentials": null,
|
|
43
43
|
"URLParam": {
|
|
44
|
-
"
|
|
45
|
-
"autoReconnect": true
|
|
44
|
+
"useUnifiedTopology": true
|
|
46
45
|
}
|
|
47
46
|
}
|
|
48
47
|
}
|
|
@@ -257,8 +256,7 @@ describe("Unit test for: Model - product", () => {
|
|
|
257
256
|
],
|
|
258
257
|
"credentials": null,
|
|
259
258
|
"URLParam": {
|
|
260
|
-
"
|
|
261
|
-
"autoReconnect": true
|
|
259
|
+
"useUnifiedTopology": true
|
|
262
260
|
}
|
|
263
261
|
}, null);
|
|
264
262
|
done();
|
|
@@ -539,8 +537,7 @@ describe("Unit test for: Model - product", () => {
|
|
|
539
537
|
"index": "test",
|
|
540
538
|
"credentials": null,
|
|
541
539
|
"URLParam": {
|
|
542
|
-
"
|
|
543
|
-
"autoReconnect": true
|
|
540
|
+
"useUnifiedTopology": true
|
|
544
541
|
},
|
|
545
542
|
}, null);
|
|
546
543
|
model.closeConnection();
|
|
@@ -560,12 +557,11 @@ describe("Unit test for: Model - product", () => {
|
|
|
560
557
|
"index": "test",
|
|
561
558
|
"credentials": null,
|
|
562
559
|
"URLParam": {
|
|
563
|
-
"
|
|
564
|
-
"autoReconnect": true
|
|
560
|
+
"useUnifiedTopology": true
|
|
565
561
|
},
|
|
566
562
|
"dbConfig": {}
|
|
567
563
|
}, null);
|
|
568
564
|
done();
|
|
569
565
|
});
|
|
570
566
|
});
|
|
571
|
-
});
|
|
567
|
+
});
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
|
|
2
1
|
/**
|
|
3
2
|
* @license
|
|
4
3
|
* Copyright SOAJS All Rights Reserved.
|
|
@@ -14,77 +13,77 @@ const Product = helper.requireModule('model/mongo/tenant.js');
|
|
|
14
13
|
const assert = require('assert');
|
|
15
14
|
|
|
16
15
|
describe("Unit test for: Model - tenant - indexes", () => {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
});
|
|
16
|
+
let model;
|
|
17
|
+
let service = {
|
|
18
|
+
config: {
|
|
19
|
+
"errors": {},
|
|
20
|
+
},
|
|
21
|
+
log: {
|
|
22
|
+
error: () => {
|
|
23
|
+
console.log();
|
|
24
|
+
},
|
|
25
|
+
debug: () => {
|
|
26
|
+
console.log();
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
registry: {
|
|
30
|
+
get: () => {
|
|
31
|
+
return {
|
|
32
|
+
coreDB: {
|
|
33
|
+
provision: {
|
|
34
|
+
"name": "core_provision",
|
|
35
|
+
"prefix": '',
|
|
36
|
+
"servers": [
|
|
37
|
+
{
|
|
38
|
+
"host": "127.0.0.1",
|
|
39
|
+
"port": 27017
|
|
40
|
+
}
|
|
41
|
+
],
|
|
42
|
+
"credentials": null,
|
|
43
|
+
"URLParam": {
|
|
44
|
+
"useUnifiedTopology": true
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
before((done) => {
|
|
54
|
+
model = new Product(service);
|
|
55
|
+
done();
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
afterEach((done) => {
|
|
59
|
+
done();
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
it('Fails - Add Tenant - Code Exists - Index unique', (done) => {
|
|
63
|
+
model.addProduct({
|
|
64
|
+
name: "Console Tenant",
|
|
65
|
+
code: "DBTN"
|
|
66
|
+
}, (err) => {
|
|
67
|
+
// assert.deepEqual(err.name, 'MongoError');
|
|
68
|
+
assert.ok(err.message.indexOf("E11000 duplicate key") !== -1);
|
|
69
|
+
// assert.deepEqual(err.message, 'E11000 duplicate key error collection: core_provision.products index: code_1 dup key: { : "DSBRD" }');
|
|
70
|
+
assert.ok(err);
|
|
71
|
+
done();
|
|
72
|
+
});
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
it('Fails - Add Tenant - Code null - Index unique', (done) => {
|
|
76
|
+
model.addProduct({
|
|
77
|
+
name: "Console Tenant",
|
|
78
|
+
code: null
|
|
79
|
+
}, (err) => {
|
|
80
|
+
assert.ok(err);
|
|
81
|
+
done();
|
|
82
|
+
});
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
it("Success - closeConnection", (done) => {
|
|
86
|
+
model.closeConnection();
|
|
87
|
+
done();
|
|
88
|
+
});
|
|
89
|
+
});
|