soajs.controller 4.3.20 → 4.3.22
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/.github/workflows/ci.yml
CHANGED
|
@@ -17,10 +17,9 @@ jobs:
|
|
|
17
17
|
|
|
18
18
|
services:
|
|
19
19
|
mongodb:
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
image: mongo:7.0
|
|
20
|
+
image: mongo:8
|
|
21
|
+
env:
|
|
22
|
+
GLIBC_TUNABLES: glibc.pthread.rseq=1 # disable tcmalloc per-CPU cache; mongo:8 refuses to start on kernel 6.19+ otherwise (SERVER-121912)
|
|
24
23
|
ports:
|
|
25
24
|
- 27017:27017
|
|
26
25
|
|
|
@@ -17,10 +17,9 @@ jobs:
|
|
|
17
17
|
|
|
18
18
|
services:
|
|
19
19
|
mongodb:
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
image: mongo:7.0
|
|
20
|
+
image: mongo:8
|
|
21
|
+
env:
|
|
22
|
+
GLIBC_TUNABLES: glibc.pthread.rseq=1 # disable tcmalloc per-CPU cache; mongo:8 refuses to start on kernel 6.19+ otherwise (SERVER-121912)
|
|
24
23
|
ports:
|
|
25
24
|
- 27017:27017
|
|
26
25
|
|
|
@@ -44,7 +44,7 @@ module.exports = (configuration) => {
|
|
|
44
44
|
if (finalACL[s] && finalACL[s].version) {
|
|
45
45
|
let version = coreLibs.version.getLatest(finalACL[s].version, v);
|
|
46
46
|
if (version !== v) {
|
|
47
|
-
|
|
47
|
+
continue;
|
|
48
48
|
}
|
|
49
49
|
}
|
|
50
50
|
finalACL[s] = {
|
|
@@ -53,7 +53,7 @@ module.exports = (configuration) => {
|
|
|
53
53
|
if (sv.apisPermission && sv.apisPermission === "restricted") {
|
|
54
54
|
for (let m in sv) {
|
|
55
55
|
if (sv.hasOwnProperty(m)) {
|
|
56
|
-
if (m !== "access"
|
|
56
|
+
if (m !== "access" && m !== "apisPermission") {
|
|
57
57
|
if (sv[m].apis) {
|
|
58
58
|
for (let a in sv[m].apis) {
|
|
59
59
|
if (sv[m].apis.hasOwnProperty(a)) {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "soajs.controller",
|
|
3
3
|
"description": "soajs multi tenant API gateway",
|
|
4
|
-
"version": "4.3.
|
|
4
|
+
"version": "4.3.22",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "soajs team",
|
|
7
7
|
"email": "team@soajs.org"
|
|
@@ -29,17 +29,17 @@
|
|
|
29
29
|
"oauth2-server": "2.4.1",
|
|
30
30
|
"path-to-regexp": "8.4.2",
|
|
31
31
|
"soajs.core.libs": "1.2.2",
|
|
32
|
-
"soajs.core.modules": "5.2.
|
|
33
|
-
"soajs.urac.driver": "3.2.
|
|
32
|
+
"soajs.core.modules": "5.2.22",
|
|
33
|
+
"soajs.urac.driver": "3.2.20",
|
|
34
34
|
"useragent": "2.3.0"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
|
-
"@babel/core": "7.29.
|
|
38
|
-
"@babel/plugin-transform-runtime": "7.29.
|
|
39
|
-
"@babel/preset-env": "7.29.
|
|
37
|
+
"@babel/core": "7.29.7",
|
|
38
|
+
"@babel/plugin-transform-runtime": "7.29.7",
|
|
39
|
+
"@babel/preset-env": "7.29.7",
|
|
40
40
|
"@babel/runtime": "7.28.6",
|
|
41
|
-
"express": "5.
|
|
42
|
-
"grunt": "1.6.
|
|
41
|
+
"express": "5.3.0",
|
|
42
|
+
"grunt": "1.6.3",
|
|
43
43
|
"grunt-babel": "8.0.0",
|
|
44
44
|
"grunt-contrib-clean": "2.0.1",
|
|
45
45
|
"grunt-contrib-copy": "1.0.0",
|
package/test/unit/index.js
CHANGED
|
@@ -36,6 +36,7 @@ describe("Starting Gateway Unit test", () => {
|
|
|
36
36
|
require("./mw/oauth/index.js");
|
|
37
37
|
require("./mw/response/index.js");
|
|
38
38
|
require("./mw/soajs/index.js");
|
|
39
|
+
require("./mw/soajsRoutes/keyACL.js");
|
|
39
40
|
require("./mw/traffic/index.js");
|
|
40
41
|
require("./mw/idempotency/index.js");
|
|
41
42
|
require("./mw/idempotency/memory.js");
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const helper = require("../../../helper.js");
|
|
4
|
+
const mw = helper.requireModule('./mw/soajsRoutes/keyACL/index');
|
|
5
|
+
const assert = require('assert');
|
|
6
|
+
|
|
7
|
+
let configuration = {
|
|
8
|
+
core: {
|
|
9
|
+
error: {
|
|
10
|
+
getError: (code) => {
|
|
11
|
+
return {code: code};
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
serviceName: "controller",
|
|
16
|
+
serviceVersion: "1"
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
let getACL = (acl, cb) => {
|
|
20
|
+
let req = {
|
|
21
|
+
headers: {key: "extKey"},
|
|
22
|
+
soajs: {
|
|
23
|
+
registry: {services: {controller: {}}},
|
|
24
|
+
controller: {
|
|
25
|
+
serviceParams: {
|
|
26
|
+
keyObj: {
|
|
27
|
+
tenant: {id: "t1", name: "Tenant", code: "TNT", type: "product"},
|
|
28
|
+
application: {package: "PROD_PCK", acl: acl}
|
|
29
|
+
},
|
|
30
|
+
packObj: {}
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
log: {
|
|
34
|
+
debug: () => {
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
controllerResponse: (response) => {
|
|
38
|
+
return cb(response);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
mw(configuration)(req, {}, () => {
|
|
43
|
+
req.soajs.controller.gotoservice(req);
|
|
44
|
+
});
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
describe("Unit test for: mw - soajsRoutes keyACL", () => {
|
|
48
|
+
|
|
49
|
+
it("Fail - no key", (done) => {
|
|
50
|
+
let req = {
|
|
51
|
+
headers: {},
|
|
52
|
+
soajs: {
|
|
53
|
+
controllerResponse: (response) => {
|
|
54
|
+
assert.deepStrictEqual(response, {code: 132});
|
|
55
|
+
done();
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
mw(configuration)(req, {}, () => {
|
|
60
|
+
});
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
it("Success - picks the latest version whatever the order of the versions", (done) => {
|
|
64
|
+
// integer keys are always walked in ascending order, decimal keys in insertion order
|
|
65
|
+
getACL({
|
|
66
|
+
"urac": {
|
|
67
|
+
"2.1": {"access": true},
|
|
68
|
+
"1.5": {"access": true},
|
|
69
|
+
"3.5": {"access": true}
|
|
70
|
+
}
|
|
71
|
+
}, (response) => {
|
|
72
|
+
assert.deepStrictEqual(response.finalACL, {"urac": {"version": "3.5"}});
|
|
73
|
+
assert.deepStrictEqual(response.packages, ["PROD_PCK"]);
|
|
74
|
+
assert.deepStrictEqual(response.tenant, {id: "t1", name: "Tenant", code: "TNT", type: "product"});
|
|
75
|
+
done();
|
|
76
|
+
});
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
it("Success - restricted lists the apis of the latest version per method", (done) => {
|
|
80
|
+
getACL({
|
|
81
|
+
"urac": {
|
|
82
|
+
"2": {
|
|
83
|
+
"access": true,
|
|
84
|
+
"apisPermission": "restricted",
|
|
85
|
+
"get": {"apis": {"/user": {}, "/users": {}}},
|
|
86
|
+
"post": {"apis": {"/user": {}}}
|
|
87
|
+
},
|
|
88
|
+
"1": {
|
|
89
|
+
"access": true,
|
|
90
|
+
"apisPermission": "restricted",
|
|
91
|
+
"delete": {"apis": {"/user": {}}}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}, (response) => {
|
|
95
|
+
assert.deepStrictEqual(response.finalACL, {
|
|
96
|
+
"urac": {
|
|
97
|
+
"version": "2",
|
|
98
|
+
"get": ["/user", "/users"],
|
|
99
|
+
"post": ["/user"]
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
done();
|
|
103
|
+
});
|
|
104
|
+
});
|
|
105
|
+
});
|