not-node 6.2.18 → 6.2.19

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 (47) hide show
  1. package/.husky/pre-commit +4 -0
  2. package/package.json +7 -4
  3. package/src/auth/roles.js +9 -1
  4. package/src/auth/rules.js +5 -5
  5. package/src/cli/actions/env.mjs +1 -1
  6. package/src/cli/actions/nginx.mjs +1 -1
  7. package/src/cli/actions/pm2.mjs +1 -1
  8. package/src/common.js +1 -1
  9. package/src/domain.js +36 -24
  10. package/src/identity/providers/session.js +3 -0
  11. package/src/manifest/batchRunner.js +5 -1
  12. package/src/manifest/registrator/fields.js +4 -4
  13. package/src/manifest/route.js +1 -0
  14. package/src/model/exceptions.js +3 -3
  15. package/src/model/versioning.js +2 -2
  16. package/test/auth/routes.js +34 -10
  17. package/test/fakes.js +52 -0
  18. package/test/identity/providers/session.js +14 -5
  19. package/test/identity/providers/token.js +1 -1
  20. package/test/init/additional.js +31 -33
  21. package/test/init/app.js +66 -10
  22. package/test/init/bodyparser.js +4 -1
  23. package/test/init/compression.js +4 -1
  24. package/test/init/cors.js +5 -1
  25. package/test/init/csp.js +2 -2
  26. package/test/init/db.js +5 -1
  27. package/test/init/env.js +12 -2
  28. package/test/init/express.js +4 -1
  29. package/test/init/fileupload.js +4 -1
  30. package/test/init/http.js +21 -4
  31. package/test/init/middleware.js +13 -1
  32. package/test/init/routes.js +1 -0
  33. package/test/init/sessions/mongoose.js +5 -1
  34. package/test/init/sessions/redis.js +5 -1
  35. package/test/init/sessions.js +21 -15
  36. package/test/init/static.js +4 -1
  37. package/test/init/template.js +5 -1
  38. package/test/model/versioning.js +3 -3
  39. package/test/module/fields.js +45 -20
  40. package/test/module/index.js +26 -15
  41. package/test/notApp.js +221 -187
  42. package/test/notDomain.js +799 -707
  43. package/test/notManifestFilter.js +385 -322
  44. package/test/notModule.js +689 -644
  45. package/test/notRoute.js +112 -99
  46. package/test/testies/module/fields/collection.js +16 -14
  47. package/test/testies/module/fields/single.js +11 -11
@@ -1,337 +1,400 @@
1
- const expect = require('chai').expect,
2
- notManifestFilter = require('../src/manifest/manifest.filter');
3
-
1
+ const expect = require("chai").expect,
2
+ notManifestFilter = require("../src/manifest/manifest.filter");
4
3
 
5
4
  const rawRoutesManifest = {
6
- admin: {
7
- model: 'admin',
8
- url: '/api/:modelName',
9
- actions: {
10
- reboot: {
11
- method: 'post',
12
- rules: [{
13
- root: true
14
- }]
15
- }
16
- }
17
- },
18
- post: {
19
- model: 'post',
20
- url: '/api/:modelName',
21
- actions: {
22
- list: {
23
- method: 'get',
24
- rules: [{
25
- auth: false
26
- }, {
27
- auth: true,
28
- actionPrefix: 'user'
29
- }, {
30
- root: true,
31
- actionName: 'listForAdmin'
32
- }]
33
- },
34
- listAll: {
35
- method: 'get',
36
- rules: [{
37
- auth: true,
38
- role: ['manager'],
39
- actionName: 'managerListAll'
40
- }, {
41
- root: true,
42
- actionPrefix: '__',
43
- actionName: 'listForAdmin'
44
- }]
45
- }
46
- }
47
- },
48
- user: {
49
- model: 'user',
50
- url: '/api/:modelName',
51
- actions: {
52
- list: {
53
- method: 'get',
54
- rules: [{
55
- root: true
56
- }]
57
- },
58
- profile: {
59
- method: 'get',
60
- rules: [{
61
- auth: true
62
- }, {
63
- root: true
64
- }]
65
- },
66
- activate: {
67
- method: 'get',
68
- auth: false,
69
- role: 'notActivated'
70
- }
71
- }
72
- },
73
- journal:{},
74
- files:{actions:{empty: undefined}}
5
+ admin: {
6
+ model: "admin",
7
+ url: "/api/:modelName",
8
+ actions: {
9
+ reboot: {
10
+ method: "post",
11
+ rules: [
12
+ {
13
+ root: true,
14
+ },
15
+ ],
16
+ },
17
+ },
18
+ },
19
+ post: {
20
+ model: "post",
21
+ url: "/api/:modelName",
22
+ actions: {
23
+ list: {
24
+ method: "get",
25
+ rules: [
26
+ {
27
+ auth: false,
28
+ },
29
+ {
30
+ auth: true,
31
+ actionPrefix: "user",
32
+ },
33
+ {
34
+ root: true,
35
+ actionName: "listForAdmin",
36
+ },
37
+ ],
38
+ },
39
+ listAll: {
40
+ method: "get",
41
+ rules: [
42
+ {
43
+ auth: true,
44
+ role: ["manager"],
45
+ actionName: "managerListAll",
46
+ },
47
+ {
48
+ root: true,
49
+ actionPrefix: "__",
50
+ actionName: "listForAdmin",
51
+ },
52
+ ],
53
+ },
54
+ },
55
+ },
56
+ user: {
57
+ model: "user",
58
+ url: "/api/:modelName",
59
+ actions: {
60
+ list: {
61
+ method: "get",
62
+ rules: [
63
+ {
64
+ root: true,
65
+ },
66
+ ],
67
+ },
68
+ profile: {
69
+ method: "get",
70
+ rules: [
71
+ {
72
+ auth: true,
73
+ },
74
+ {
75
+ root: true,
76
+ },
77
+ ],
78
+ },
79
+ activate: {
80
+ method: "get",
81
+ auth: false,
82
+ role: "notActivated",
83
+ },
84
+ },
85
+ },
86
+ journal: {},
87
+ files: { actions: { empty: undefined } },
75
88
  };
76
89
 
77
- describe('notManifestFilter', function () {
78
- describe('clearActionFromRules', function () {
79
- it('with rules', function () {
80
- const input = {
81
- modelName: 'jelly',
82
- rules: [{
83
- auth: true,
84
- fields: ['name']
85
- }, {
86
- root: true,
87
- fields: ['name', 'email']
88
- }]
89
- };
90
- const result = notManifestFilter.clearActionFromRules(input, {
91
- root: true,
92
- fields: ['name', 'email']
93
- });
94
- expect(result).to.deep.equal({
95
- modelName: 'jelly',
96
- fields: ['name', 'email']
97
- });
98
- });
99
-
100
- it('without rules', function () {
101
- const input = {
102
- modelName: 'jelly',
103
- auth: true,
104
- role: ['root'],
105
- root: true
106
- };
107
- const result = notManifestFilter.clearActionFromRules(input);
108
- expect(result).to.deep.equal({
109
- modelName: 'jelly'
110
- });
111
- });
112
- });
113
-
114
- describe('filterRoute', function () {
115
- const route = {
116
- actions: {
117
- list: {
118
- postFix: ':actionName',
119
- rules: [{
120
- root: true
121
- }, {
122
- auth: true
123
- }, {
124
- auth: false
125
- }]
126
- },
127
- get: {
128
- formData: true,
129
- rules: [{
130
- root: true
131
- }]
132
- },
133
- update: {
134
- formData: false,
135
- auth: true,
136
- role: ['manager']
137
- }
138
- }
139
- };
140
- it('route [{admin},{auth},{!auth}], !auth, \'user\', !admin', function () {
141
- const result = notManifestFilter.filterRoute(route, false, 'user', false);
142
- expect(result).to.deep.equal({
143
- actions: {
144
- list: {
145
- postFix: ':actionName'
146
- }
147
- }
148
- });
149
- });
150
-
151
- it('route [{admin},{auth},{!auth}], !auth, \'user\', admin', function () {
152
- const result = notManifestFilter.filterRoute(route, false, 'user', true);
153
- expect(result).to.deep.equal({
154
- actions: {
155
- list: {
156
- postFix: ':actionName'
157
- },
158
- get: {
159
- formData: true
160
- }
161
- }
162
- });
163
- });
164
-
165
- it('route [{admin},{auth},{!auth}], auth, \'user\', !admin', function () {
166
- const result = notManifestFilter.filterRoute(route, true, 'user', false);
167
- expect(result).to.deep.equal({
168
- actions: {
169
- list: {
170
- postFix: ':actionName'
171
- }
172
- }
173
- });
174
- });
90
+ describe("notManifestFilter", function () {
91
+ describe("clearActionFromRules", function () {
92
+ it("with rules", function () {
93
+ const input = {
94
+ modelName: "jelly",
95
+ rules: [
96
+ {
97
+ auth: true,
98
+ fields: ["name"],
99
+ },
100
+ {
101
+ root: true,
102
+ fields: ["name", "email"],
103
+ },
104
+ ],
105
+ };
106
+ const result = notManifestFilter.clearActionFromRules(input, {
107
+ root: true,
108
+ fields: ["name", "email"],
109
+ });
110
+ expect(result).to.deep.equal({
111
+ modelName: "jelly",
112
+ fields: ["name", "email"],
113
+ });
114
+ });
175
115
 
176
- it('route [{admin},{auth},{!auth}], auth, \'user\', !admin', function () {
177
- const result = notManifestFilter.filterRoute(route, true, 'manager', false);
178
- expect(result).to.deep.equal({
179
- actions: {
180
- list: {
181
- postFix: ':actionName'
182
- },
183
- update: {
184
- formData: false
185
- }
186
- }
187
- });
188
- });
116
+ it("without rules", function () {
117
+ const input = {
118
+ modelName: "jelly",
119
+ auth: true,
120
+ role: ["root"],
121
+ root: true,
122
+ };
123
+ const result = notManifestFilter.clearActionFromRules(input);
124
+ expect(result).to.deep.equal({
125
+ modelName: "jelly",
126
+ });
127
+ });
128
+ });
189
129
 
190
- });
130
+ describe("filterRoute", function () {
131
+ const route = {
132
+ actions: {
133
+ list: {
134
+ postFix: ":actionName",
135
+ rules: [
136
+ {
137
+ root: true,
138
+ },
139
+ {
140
+ auth: true,
141
+ },
142
+ {
143
+ auth: false,
144
+ },
145
+ ],
146
+ },
147
+ get: {
148
+ formData: true,
149
+ rules: [
150
+ {
151
+ root: true,
152
+ },
153
+ ],
154
+ },
155
+ update: {
156
+ formData: false,
157
+ auth: true,
158
+ role: ["manager"],
159
+ },
160
+ },
161
+ };
162
+ it("route [{admin},{auth},{!auth}], !auth, 'user', !admin", function () {
163
+ const result = notManifestFilter.filterRoute(
164
+ route,
165
+ false,
166
+ "user",
167
+ false
168
+ );
169
+ expect(result).to.deep.equal({
170
+ actions: {
171
+ list: {
172
+ postFix: ":actionName",
173
+ },
174
+ },
175
+ });
176
+ });
191
177
 
178
+ it("route [{admin},{auth},{!auth}], !auth, 'user', admin", function () {
179
+ const result = notManifestFilter.filterRoute(
180
+ route,
181
+ false,
182
+ "user",
183
+ true
184
+ );
185
+ expect(result).to.deep.equal({
186
+ actions: {
187
+ list: {
188
+ postFix: ":actionName",
189
+ },
190
+ get: {
191
+ formData: true,
192
+ },
193
+ },
194
+ });
195
+ });
192
196
 
193
- describe('filter', function () {
194
- let filtered = {
195
- admin: {
196
- user: {
197
- model: 'user',
198
- url: '/api/:modelName',
199
- actions: {
200
- list: {
201
- method: 'get'
202
- },
203
- profile: {
204
- method: 'get'
205
- }
206
- }
207
- },
208
- post: {
209
- model: 'post',
210
- url: '/api/:modelName',
211
- actions: {
212
- list: {
213
- method: 'get'
214
- },
215
- listAll: {
216
- method: 'get'
217
- }
218
- }
219
- },
220
- admin: {
221
- model: 'admin',
222
- url: '/api/:modelName',
223
- actions: {
224
- reboot: {
225
- method: 'post'
226
- }
227
- }
228
- }
229
- },
230
- user: {
231
- user: {
232
- model: 'user',
233
- url: '/api/:modelName',
234
- actions: {
235
- profile: {
236
- method: 'get'
237
- }
238
- }
239
- },
240
- post: {
241
- model: 'post',
242
- url: '/api/:modelName',
243
- actions: {
244
- list: {
245
- method: 'get'
246
- }
247
- }
248
- }
249
- },
250
- guest: {
251
- post: {
252
- model: 'post',
253
- url: '/api/:modelName',
254
- actions: {
255
- list: {
256
- method: 'get'
257
- }
258
- }
259
- }
260
- },
261
- notActivated: {
262
- user: {
263
- model: 'user',
264
- url: '/api/:modelName',
265
- actions: {
266
- activate: {
267
- method: 'get'
268
- }
269
- }
270
- },
271
- post: {
272
- model: 'post',
273
- url: '/api/:modelName',
274
- actions: {
275
- list: {
276
- method: 'get'
277
- }
278
- }
279
- }
280
- },
281
- manager: {
282
- user: {
283
- model: 'user',
284
- url: '/api/:modelName',
285
- actions: {
286
- profile: {
287
- method: 'get'
288
- }
289
- }
290
- },
291
- post: {
292
- model: 'post',
293
- url: '/api/:modelName',
294
- actions: {
295
- list: {
296
- method: 'get'
297
- },
298
- listAll: {
299
- method: 'get'
300
- }
301
- }
302
- }
303
- }
304
- };
305
- it('Guest manifest', function () {
306
- let man = rawRoutesManifest,
307
- manAfterFilter = notManifestFilter.filter(man, false, false, false);
308
- expect(manAfterFilter).to.deep.equal(filtered.guest);
309
- });
197
+ it("route [{admin},{auth},{!auth}], auth, 'user', !admin", function () {
198
+ const result = notManifestFilter.filterRoute(
199
+ route,
200
+ true,
201
+ "user",
202
+ false
203
+ );
204
+ expect(result).to.deep.equal({
205
+ actions: {
206
+ list: {
207
+ postFix: ":actionName",
208
+ },
209
+ },
210
+ });
211
+ });
310
212
 
311
- it('Auth manifest', function () {
312
- let man = rawRoutesManifest,
313
- manAfterFilter = notManifestFilter.filter(man, true, false, false);
314
- expect(manAfterFilter).to.deep.equal(filtered.user);
315
- });
213
+ it("route [{admin},{auth},{!auth}], auth, 'manager', !admin", function () {
214
+ const result = notManifestFilter.filterRoute(
215
+ route,
216
+ true,
217
+ "manager",
218
+ false
219
+ );
220
+ expect(result).to.deep.equal({
221
+ actions: {
222
+ list: {
223
+ postFix: ":actionName",
224
+ },
225
+ update: {
226
+ formData: false,
227
+ },
228
+ },
229
+ });
230
+ });
231
+ });
316
232
 
317
- it('Auth with manager role manifest', function () {
318
- let man = rawRoutesManifest,
319
- manAfterFilter = notManifestFilter.filter(man, true, 'manager', false);
320
- expect(manAfterFilter).to.deep.equal(filtered.manager);
321
- });
233
+ describe("filter", function () {
234
+ let filtered = {
235
+ admin: {
236
+ user: {
237
+ model: "user",
238
+ url: "/api/:modelName",
239
+ actions: {
240
+ list: {
241
+ method: "get",
242
+ },
243
+ profile: {
244
+ method: "get",
245
+ },
246
+ },
247
+ },
248
+ post: {
249
+ model: "post",
250
+ url: "/api/:modelName",
251
+ actions: {
252
+ list: {
253
+ method: "get",
254
+ },
255
+ listAll: {
256
+ method: "get",
257
+ },
258
+ },
259
+ },
260
+ admin: {
261
+ model: "admin",
262
+ url: "/api/:modelName",
263
+ actions: {
264
+ reboot: {
265
+ method: "post",
266
+ },
267
+ },
268
+ },
269
+ },
270
+ user: {
271
+ user: {
272
+ model: "user",
273
+ url: "/api/:modelName",
274
+ actions: {
275
+ profile: {
276
+ method: "get",
277
+ },
278
+ },
279
+ },
280
+ post: {
281
+ model: "post",
282
+ url: "/api/:modelName",
283
+ actions: {
284
+ list: {
285
+ method: "get",
286
+ },
287
+ },
288
+ },
289
+ },
290
+ guest: {
291
+ post: {
292
+ model: "post",
293
+ url: "/api/:modelName",
294
+ actions: {
295
+ list: {
296
+ method: "get",
297
+ },
298
+ },
299
+ },
300
+ },
301
+ notActivated: {
302
+ user: {
303
+ model: "user",
304
+ url: "/api/:modelName",
305
+ actions: {
306
+ activate: {
307
+ method: "get",
308
+ },
309
+ },
310
+ },
311
+ post: {
312
+ model: "post",
313
+ url: "/api/:modelName",
314
+ actions: {
315
+ list: {
316
+ method: "get",
317
+ },
318
+ },
319
+ },
320
+ },
321
+ manager: {
322
+ user: {
323
+ model: "user",
324
+ url: "/api/:modelName",
325
+ actions: {
326
+ profile: {
327
+ method: "get",
328
+ },
329
+ },
330
+ },
331
+ post: {
332
+ model: "post",
333
+ url: "/api/:modelName",
334
+ actions: {
335
+ list: {
336
+ method: "get",
337
+ },
338
+ listAll: {
339
+ method: "get",
340
+ },
341
+ },
342
+ },
343
+ },
344
+ };
345
+ it("Guest manifest", function () {
346
+ let man = rawRoutesManifest,
347
+ manAfterFilter = notManifestFilter.filter(
348
+ man,
349
+ false,
350
+ false,
351
+ false
352
+ );
353
+ expect(manAfterFilter).to.deep.equal(filtered.guest);
354
+ });
322
355
 
323
- it('Guest with notActivated role manifest', function () {
324
- let man = rawRoutesManifest,
325
- manAfterFilter = notManifestFilter.filter(man, false, 'notActivated', false);
326
- expect(manAfterFilter).to.deep.equal(filtered.notActivated);
327
- });
356
+ it("Auth manifest", function () {
357
+ let man = rawRoutesManifest,
358
+ manAfterFilter = notManifestFilter.filter(
359
+ man,
360
+ true,
361
+ false,
362
+ false
363
+ );
364
+ expect(manAfterFilter).to.deep.equal(filtered.user);
365
+ });
328
366
 
329
- it('Admin manifest', function () {
330
- let man = rawRoutesManifest,
331
- manAfterFilter = notManifestFilter.filter(man, false, false, true);
332
- expect(manAfterFilter).to.deep.equal(filtered.admin);
333
- });
334
- });
367
+ it("Auth with manager role manifest", function () {
368
+ let man = rawRoutesManifest,
369
+ manAfterFilter = notManifestFilter.filter(
370
+ man,
371
+ true,
372
+ "manager",
373
+ false
374
+ );
375
+ expect(manAfterFilter).to.deep.equal(filtered.manager);
376
+ });
335
377
 
378
+ it("Guest with notActivated role manifest", function () {
379
+ let man = rawRoutesManifest,
380
+ manAfterFilter = notManifestFilter.filter(
381
+ man,
382
+ false,
383
+ "notActivated",
384
+ false
385
+ );
386
+ expect(manAfterFilter).to.deep.equal(filtered.notActivated);
387
+ });
336
388
 
389
+ it("Admin manifest", function () {
390
+ let man = rawRoutesManifest,
391
+ manAfterFilter = notManifestFilter.filter(
392
+ man,
393
+ false,
394
+ false,
395
+ true
396
+ );
397
+ expect(manAfterFilter).to.deep.equal(filtered.admin);
398
+ });
399
+ });
337
400
  });