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.
Files changed (53) hide show
  1. package/.eslintrc.json +32 -38
  2. package/index.js +6 -0
  3. package/package.json +12 -11
  4. package/src/app.js +2 -2
  5. package/src/auth/index.js +0 -2
  6. package/src/auth/routes.js +25 -61
  7. package/src/auth/rules.js +8 -7
  8. package/src/common.js +19 -0
  9. package/src/identity/exceptions.js +17 -0
  10. package/src/identity/identity.js +61 -0
  11. package/src/identity/index.js +35 -0
  12. package/src/identity/providers/session.js +137 -0
  13. package/src/identity/providers/token.js +255 -0
  14. package/src/manifest/result.filter.js +268 -0
  15. package/src/manifest/route.js +6 -36
  16. package/static2.js +24 -0
  17. package/test/auth/identity.js +0 -0
  18. package/test/auth/routes.js +1 -1
  19. package/test/auth.js +427 -229
  20. package/test/env.js +20 -20
  21. package/test/fields.js +3 -2
  22. package/test/identity/identity.js +1 -0
  23. package/test/identity/index.js +12 -0
  24. package/test/identity/providers/session.js +227 -0
  25. package/test/identity/providers/token.js +244 -0
  26. package/test/identity.js +5 -0
  27. package/test/init/app.js +359 -365
  28. package/test/init/bodyparser.js +37 -39
  29. package/test/init/compression.js +29 -31
  30. package/test/init/cors.js +38 -39
  31. package/test/init/db.js +60 -64
  32. package/test/init/env.js +109 -114
  33. package/test/init/express.js +50 -47
  34. package/test/init/fileupload.js +30 -32
  35. package/test/init/http.js +258 -240
  36. package/test/init/informer.js +20 -24
  37. package/test/init/methodoverride.js +29 -31
  38. package/test/init/middleware.js +56 -58
  39. package/test/init/modules.js +19 -19
  40. package/test/init/monitoring.js +22 -22
  41. package/test/init/routes.js +185 -171
  42. package/test/init/security.js +77 -103
  43. package/test/init/sessions/mongoose.js +56 -57
  44. package/test/init/sessions/redis.js +59 -61
  45. package/test/init/sessions.js +84 -79
  46. package/test/init/static.js +108 -113
  47. package/test/init/template.js +46 -41
  48. package/test/notInit.js +217 -217
  49. package/test/notManifest.js +232 -191
  50. package/test/notRoute.js +1022 -799
  51. package/test/result.filter.js +422 -0
  52. package/src/auth/session.js +0 -151
  53. package/test/auth/session.js +0 -266
@@ -1,205 +1,246 @@
1
- const expect = require('chai').expect,
2
- notManifest = require('../src/manifest/manifest'),
3
- manifest = new notManifest();
1
+ const expect = require("chai").expect,
2
+ notManifest = require("../src/manifest/manifest"),
3
+ manifest = new notManifest();
4
4
 
5
5
  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}}
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('Manifest', function () {
78
- const initSummary = ()=>{
79
- return {
80
- get: [],
81
- post: [],
82
- delete: []
83
- };
84
- };
91
+ describe("Manifest", function () {
92
+ const initSummary = () => {
93
+ return {
94
+ get: [],
95
+ post: [],
96
+ delete: [],
97
+ };
98
+ };
85
99
 
86
- const initFakeApp = (summary)=>{
87
- return {
88
- get(url, cb){
89
- summary.get.push([url, cb]);
90
- },
91
- post(url, cb){
92
- summary.post.push([url, cb]);
93
- },
94
- delete(url, cb){
95
- summary.delete.push([url, cb]);
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
- describe('registerRouteForAction', function () {
101
- it('Guest GET request', function () {
102
- manifest.app = {'get':()=>{}};
103
- let result = manifest.registerRouteForAction('/api/:modelName', 'list', 'list', rawRoutesManifest.post.actions.list);
104
- expect(result).to.be.equal(true);
105
- });
106
- it('Guest GET request to wrong end point', function () {
107
- let result = manifest.registerRouteForAction('/api/:modelName', 'get', 'list', rawRoutesManifest.post.actions.listAlly);
108
- expect(result).to.deep.equal(false);
109
- });
110
- it('Guest POST request', function () {
111
- manifest.app = {'post':()=>{}};
112
- let result = manifest.registerRouteForAction('/api/:modelName', 'admin', 'reboot', rawRoutesManifest.admin.actions.reboot);
113
- expect(result).to.deep.equal(true);
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
- describe('registerRoutes', function () {
118
- it('empty routes', function () {
119
- const summary = initSummary();
120
- const fakeApp = initFakeApp(summary);
121
- manifest.app = fakeApp;
122
- const input = {};
123
- manifest.registerRoutes(input);
124
- expect(summary).to.be.deep.equal(initSummary());
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
- it('empty routes', function () {
128
- const summary = initSummary();
129
- const fakeApp = initFakeApp(summary);
130
- manifest.app = fakeApp;
131
- const input = {
132
- user: {
133
- url: '/api/:modelName',
134
- model: 'user',
135
- actions:{
136
- info: {
137
- method: 'GET'
138
- },
139
- rules: [{auth: false}]
140
- }
141
- },
142
- looser: {
143
- url: '/api/:modelName',
144
- actions:{}
145
- }
146
- };
147
- manifest.registerRoutes(input);
148
- expect(summary.get[0][0]).to.be.equal('/api/user');
149
- expect(typeof summary.get[0][1]).to.be.equal('function');
150
- expect(summary.get.length).to.be.equal(1);
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
- describe('routeHasRoutes', function () {
155
- it('actions', function () {
156
- const result = manifest.routeHasRoutes({actions:{}});
157
- expect(result).to.deep.equal(false);
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
- it('actions, url', function () {
161
- const result = manifest.routeHasRoutes({actions:{}, url: ''});
162
- expect(result).to.deep.equal(false);
163
- });
189
+ it("actions, url", function () {
190
+ const result = manifest.routeHasRoutes({ actions: {}, url: "" });
191
+ expect(result).to.deep.equal(false);
192
+ });
164
193
 
165
- it('actions, url, model not empty', function () {
166
- const result = manifest.routeHasRoutes({actions:{}, url: '', model: 'sadf'});
167
- expect(result).to.deep.equal(true);
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
- it('actions, url, model is empty', function () {
171
- const result = manifest.routeHasRoutes({actions:{}, url: '', model: ''});
172
- expect(result).to.deep.equal(false);
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
- //filterManifest
177
- describe('filterManifest', function () {
178
- it('filter;', function () {
179
-
180
- expect(notManifest.prototype.filterManifest.call({}, rawRoutesManifest, true, 'user', false)).to.deep.equal(
181
- {
182
- post: {
183
- model: 'post',
184
- url: '/api/:modelName',
185
- actions: {
186
- list: {
187
- method: 'get'
188
- }
189
- }
190
- },
191
- user: {
192
- model: 'user',
193
- url: '/api/:modelName',
194
- actions: {
195
- profile: {
196
- method: 'get'
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
  });