not-node 5.1.44 → 6.0.0
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/.eslintrc.json +32 -38
- package/index.js +6 -0
- package/package.json +12 -11
- package/src/app.js +2 -2
- package/src/auth/index.js +0 -2
- package/src/auth/routes.js +25 -61
- package/src/auth/rules.js +8 -7
- package/src/common.js +19 -0
- package/src/identity/exceptions.js +17 -0
- package/src/identity/identity.js +61 -0
- package/src/identity/index.js +35 -0
- package/src/identity/providers/session.js +137 -0
- package/src/identity/providers/token.js +255 -0
- package/src/manifest/result.filter.js +268 -0
- package/src/manifest/route.js +6 -36
- package/static2.js +24 -0
- package/test/auth/identity.js +0 -0
- package/test/auth/routes.js +1 -1
- package/test/auth.js +427 -229
- package/test/env.js +20 -20
- package/test/fields.js +3 -2
- package/test/identity/identity.js +1 -0
- package/test/identity/index.js +12 -0
- package/test/identity/providers/session.js +227 -0
- package/test/identity/providers/token.js +244 -0
- package/test/identity.js +5 -0
- package/test/init/app.js +359 -365
- package/test/init/bodyparser.js +37 -39
- package/test/init/compression.js +29 -31
- package/test/init/cors.js +38 -39
- package/test/init/db.js +60 -64
- package/test/init/env.js +109 -114
- package/test/init/express.js +50 -47
- package/test/init/fileupload.js +30 -32
- package/test/init/http.js +258 -240
- package/test/init/informer.js +20 -24
- package/test/init/methodoverride.js +29 -31
- package/test/init/middleware.js +56 -58
- package/test/init/modules.js +19 -19
- package/test/init/monitoring.js +22 -22
- package/test/init/routes.js +185 -171
- package/test/init/security.js +77 -103
- package/test/init/sessions/mongoose.js +56 -57
- package/test/init/sessions/redis.js +59 -61
- package/test/init/sessions.js +84 -79
- package/test/init/static.js +108 -113
- package/test/init/template.js +46 -41
- package/test/notInit.js +217 -217
- package/test/notManifest.js +232 -191
- package/test/notRoute.js +1022 -799
- package/test/result.filter.js +422 -0
- package/src/auth/session.js +0 -151
- package/test/auth/session.js +0 -266
package/test/notManifest.js
CHANGED
|
@@ -1,205 +1,246 @@
|
|
|
1
|
-
const expect = require(
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
const expect = require("chai").expect,
|
|
2
|
+
notManifest = require("../src/manifest/manifest"),
|
|
3
|
+
manifest = new notManifest();
|
|
4
4
|
|
|
5
5
|
const rawRoutesManifest = {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
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
|
-
|
|
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
|
-
|
|
6
|
+
admin: {
|
|
7
|
+
model: "admin",
|
|
8
|
+
url: "/api/:modelName",
|
|
9
|
+
actions: {
|
|
10
|
+
reboot: {
|
|
11
|
+
method: "post",
|
|
12
|
+
rules: [
|
|
13
|
+
{
|
|
14
|
+
root: true,
|
|
15
|
+
},
|
|
16
|
+
],
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
post: {
|
|
21
|
+
model: "post",
|
|
22
|
+
url: "/api/:modelName",
|
|
23
|
+
actions: {
|
|
24
|
+
list: {
|
|
25
|
+
method: "get",
|
|
26
|
+
rules: [
|
|
27
|
+
{
|
|
28
|
+
auth: false,
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
auth: true,
|
|
32
|
+
actionPrefix: "user",
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
root: true,
|
|
36
|
+
actionName: "listForAdmin",
|
|
37
|
+
},
|
|
38
|
+
],
|
|
39
|
+
},
|
|
40
|
+
listAll: {
|
|
41
|
+
method: "get",
|
|
42
|
+
rules: [
|
|
43
|
+
{
|
|
44
|
+
auth: true,
|
|
45
|
+
role: ["manager"],
|
|
46
|
+
actionName: "managerListAll",
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
root: true,
|
|
50
|
+
actionPrefix: "__",
|
|
51
|
+
actionName: "listForAdmin",
|
|
52
|
+
},
|
|
53
|
+
],
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
},
|
|
57
|
+
user: {
|
|
58
|
+
model: "user",
|
|
59
|
+
url: "/api/:modelName",
|
|
60
|
+
actions: {
|
|
61
|
+
list: {
|
|
62
|
+
method: "get",
|
|
63
|
+
rules: [
|
|
64
|
+
{
|
|
65
|
+
root: true,
|
|
66
|
+
},
|
|
67
|
+
],
|
|
68
|
+
},
|
|
69
|
+
profile: {
|
|
70
|
+
method: "get",
|
|
71
|
+
rules: [
|
|
72
|
+
{
|
|
73
|
+
auth: true,
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
root: true,
|
|
77
|
+
},
|
|
78
|
+
],
|
|
79
|
+
},
|
|
80
|
+
activate: {
|
|
81
|
+
method: "get",
|
|
82
|
+
auth: false,
|
|
83
|
+
role: "notActivated",
|
|
84
|
+
},
|
|
85
|
+
},
|
|
86
|
+
},
|
|
87
|
+
journal: {},
|
|
88
|
+
files: { actions: { empty: undefined } },
|
|
75
89
|
};
|
|
76
90
|
|
|
77
|
-
describe(
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
91
|
+
describe("Manifest", function () {
|
|
92
|
+
const initSummary = () => {
|
|
93
|
+
return {
|
|
94
|
+
get: [],
|
|
95
|
+
post: [],
|
|
96
|
+
delete: [],
|
|
97
|
+
};
|
|
98
|
+
};
|
|
85
99
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
100
|
+
const initFakeApp = (summary) => {
|
|
101
|
+
return {
|
|
102
|
+
get(url, cb) {
|
|
103
|
+
summary.get.push([url, cb]);
|
|
104
|
+
},
|
|
105
|
+
post(url, cb) {
|
|
106
|
+
summary.post.push([url, cb]);
|
|
107
|
+
},
|
|
108
|
+
delete(url, cb) {
|
|
109
|
+
summary.delete.push([url, cb]);
|
|
110
|
+
},
|
|
111
|
+
};
|
|
112
|
+
};
|
|
99
113
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
114
|
+
describe("registerRouteForAction", function () {
|
|
115
|
+
it("Guest GET request", function () {
|
|
116
|
+
manifest.app = { get: () => {} };
|
|
117
|
+
let result = manifest.registerRouteForAction(
|
|
118
|
+
"/api/:modelName",
|
|
119
|
+
"list",
|
|
120
|
+
"list",
|
|
121
|
+
rawRoutesManifest.post.actions.list
|
|
122
|
+
);
|
|
123
|
+
expect(result).to.be.equal(true);
|
|
124
|
+
});
|
|
125
|
+
it("Guest GET request to wrong end point", function () {
|
|
126
|
+
let result = manifest.registerRouteForAction(
|
|
127
|
+
"/api/:modelName",
|
|
128
|
+
"get",
|
|
129
|
+
"list",
|
|
130
|
+
rawRoutesManifest.post.actions.listAlly
|
|
131
|
+
);
|
|
132
|
+
expect(result).to.deep.equal(false);
|
|
133
|
+
});
|
|
134
|
+
it("Guest POST request", function () {
|
|
135
|
+
manifest.app = { post: () => {} };
|
|
136
|
+
let result = manifest.registerRouteForAction(
|
|
137
|
+
"/api/:modelName",
|
|
138
|
+
"admin",
|
|
139
|
+
"reboot",
|
|
140
|
+
rawRoutesManifest.admin.actions.reboot
|
|
141
|
+
);
|
|
142
|
+
expect(result).to.deep.equal(true);
|
|
143
|
+
});
|
|
144
|
+
});
|
|
116
145
|
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
146
|
+
describe("registerRoutes", function () {
|
|
147
|
+
it("empty routes", function () {
|
|
148
|
+
const summary = initSummary();
|
|
149
|
+
const fakeApp = initFakeApp(summary);
|
|
150
|
+
manifest.app = fakeApp;
|
|
151
|
+
const input = {};
|
|
152
|
+
manifest.registerRoutes(input);
|
|
153
|
+
expect(summary).to.be.deep.equal(initSummary());
|
|
154
|
+
});
|
|
126
155
|
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
156
|
+
it("empty routes", function () {
|
|
157
|
+
const summary = initSummary();
|
|
158
|
+
const fakeApp = initFakeApp(summary);
|
|
159
|
+
manifest.app = fakeApp;
|
|
160
|
+
const input = {
|
|
161
|
+
user: {
|
|
162
|
+
url: "/api/:modelName",
|
|
163
|
+
model: "user",
|
|
164
|
+
actions: {
|
|
165
|
+
info: {
|
|
166
|
+
method: "GET",
|
|
167
|
+
},
|
|
168
|
+
rules: [{ auth: false }],
|
|
169
|
+
},
|
|
170
|
+
},
|
|
171
|
+
looser: {
|
|
172
|
+
url: "/api/:modelName",
|
|
173
|
+
actions: {},
|
|
174
|
+
},
|
|
175
|
+
};
|
|
176
|
+
manifest.registerRoutes(input);
|
|
177
|
+
expect(summary.get[0][0]).to.be.equal("/api/user");
|
|
178
|
+
expect(typeof summary.get[0][1]).to.be.equal("function");
|
|
179
|
+
expect(summary.get.length).to.be.equal(1);
|
|
180
|
+
});
|
|
181
|
+
});
|
|
153
182
|
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
183
|
+
describe("routeHasRoutes", function () {
|
|
184
|
+
it("actions", function () {
|
|
185
|
+
const result = manifest.routeHasRoutes({ actions: {} });
|
|
186
|
+
expect(result).to.deep.equal(false);
|
|
187
|
+
});
|
|
159
188
|
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
189
|
+
it("actions, url", function () {
|
|
190
|
+
const result = manifest.routeHasRoutes({ actions: {}, url: "" });
|
|
191
|
+
expect(result).to.deep.equal(false);
|
|
192
|
+
});
|
|
164
193
|
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
194
|
+
it("actions, url, model not empty", function () {
|
|
195
|
+
const result = manifest.routeHasRoutes({
|
|
196
|
+
actions: {},
|
|
197
|
+
url: "",
|
|
198
|
+
model: "sadf",
|
|
199
|
+
});
|
|
200
|
+
expect(result).to.deep.equal(true);
|
|
201
|
+
});
|
|
169
202
|
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
203
|
+
it("actions, url, model is empty", function () {
|
|
204
|
+
const result = manifest.routeHasRoutes({
|
|
205
|
+
actions: {},
|
|
206
|
+
url: "",
|
|
207
|
+
model: "",
|
|
208
|
+
});
|
|
209
|
+
expect(result).to.deep.equal(false);
|
|
210
|
+
});
|
|
211
|
+
});
|
|
175
212
|
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
213
|
+
//filterManifest
|
|
214
|
+
describe("filterManifest", function () {
|
|
215
|
+
it("filter;", function () {
|
|
216
|
+
expect(
|
|
217
|
+
notManifest.prototype.filterManifest.call(
|
|
218
|
+
{},
|
|
219
|
+
rawRoutesManifest,
|
|
220
|
+
true,
|
|
221
|
+
"user",
|
|
222
|
+
false
|
|
223
|
+
)
|
|
224
|
+
).to.deep.equal({
|
|
225
|
+
post: {
|
|
226
|
+
model: "post",
|
|
227
|
+
url: "/api/:modelName",
|
|
228
|
+
actions: {
|
|
229
|
+
list: {
|
|
230
|
+
method: "get",
|
|
231
|
+
},
|
|
232
|
+
},
|
|
233
|
+
},
|
|
234
|
+
user: {
|
|
235
|
+
model: "user",
|
|
236
|
+
url: "/api/:modelName",
|
|
237
|
+
actions: {
|
|
238
|
+
profile: {
|
|
239
|
+
method: "get",
|
|
240
|
+
},
|
|
241
|
+
},
|
|
242
|
+
},
|
|
243
|
+
});
|
|
244
|
+
});
|
|
245
|
+
});
|
|
205
246
|
});
|