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
package/test/init/app.js CHANGED
@@ -1,376 +1,370 @@
1
- const ADDS = require('../../src/init/additional');
2
- const InitApp = require('../../src/init/app');
3
-
4
- module.exports = ({expect})=>{
5
- describe('App', ()=>{
6
- describe('createApp', ()=>{
7
- it('not emits to call', async()=>{
8
- let constructorCalled = false;
9
- const fakeMongoose = {
10
- this:'is fake indeed'
11
- };
12
- const config = {fake: 'config'};
13
- const options = {fake: 'options'};
14
- class FakeApp{
15
- constructor({mongoose}){
16
- expect(mongoose).to.be.deep.equal(fakeMongoose);
17
- constructorCalled = true;
18
- }
19
- };
20
- InitApp.AppConstructor = FakeApp;
21
- const master = {
22
- setApp(app){expect(app).to.be.instanceof(FakeApp);},
23
- getMongoose(){return fakeMongoose; }
24
- };
25
-
26
- await InitApp.createApp({master, config, options});
27
- expect(constructorCalled).to.be.true;
28
- });
29
-
30
-
31
- it('calls emit', async()=>{
32
- let constructorCalled = false;
33
- let preCalled = false;
34
- let postCalled = false;
35
- ADDS.init({
36
- app:{
37
- create:{
38
- pre(){
39
- preCalled = true;
40
- },
41
- post(){
42
- postCalled = true;
43
- }
44
- }
45
- }
1
+ const ADDS = require("../../src/init/additional");
2
+ const InitApp = require("../../src/init/lib/app");
3
+
4
+ module.exports = ({ expect }) => {
5
+ describe("App", () => {
6
+ describe("createApp", () => {
7
+ it("not emits to call", async () => {
8
+ let constructorCalled = false;
9
+ const fakeMongoose = {
10
+ this: "is fake indeed",
11
+ };
12
+ const config = { fake: "config" };
13
+ const options = { fake: "options" };
14
+ class FakeApp {
15
+ constructor({ mongoose }) {
16
+ expect(mongoose).to.be.deep.equal(fakeMongoose);
17
+ constructorCalled = true;
18
+ }
19
+ }
20
+ InitApp.AppConstructor = FakeApp;
21
+ const master = {
22
+ setApp(app) {
23
+ expect(app).to.be.instanceof(FakeApp);
24
+ },
25
+ getMongoose() {
26
+ return fakeMongoose;
27
+ },
28
+ };
29
+
30
+ await InitApp.createApp({ master, config, options });
31
+ expect(constructorCalled).to.be.true;
32
+ });
33
+
34
+ it("calls emit", async () => {
35
+ let constructorCalled = false;
36
+ let preCalled = false;
37
+ let postCalled = false;
38
+ ADDS.init({
39
+ app: {
40
+ create: {
41
+ pre() {
42
+ preCalled = true;
43
+ },
44
+ post() {
45
+ postCalled = true;
46
+ },
47
+ },
48
+ },
49
+ });
50
+ const fakeMongoose = {
51
+ this: "is fake indeed",
52
+ };
53
+ const config = { fake: "config" };
54
+ const options = { fake: "options" };
55
+ class FakeApp {
56
+ constructor({ mongoose }) {
57
+ expect(mongoose).to.be.deep.equal(fakeMongoose);
58
+ constructorCalled = true;
59
+ }
60
+ }
61
+ InitApp.AppConstructor = FakeApp;
62
+ const master = {
63
+ setApp(app) {
64
+ expect(app).to.be.instanceof(FakeApp);
65
+ },
66
+ getMongoose() {
67
+ return fakeMongoose;
68
+ },
69
+ };
70
+
71
+ await InitApp.createApp({ master, config, options });
72
+ expect(constructorCalled).to.be.true;
73
+ expect(preCalled).to.be.true;
74
+ expect(postCalled).to.be.true;
75
+ });
46
76
  });
47
- const fakeMongoose = {
48
- this:'is fake indeed'
49
- };
50
- const config = {fake: 'config'};
51
- const options = {fake: 'options'};
52
- class FakeApp{
53
- constructor({mongoose}){
54
- expect(mongoose).to.be.deep.equal(fakeMongoose);
55
- constructorCalled = true;
56
- }
57
- };
58
- InitApp.AppConstructor = FakeApp;
59
- const master = {
60
- setApp(app){expect(app).to.be.instanceof(FakeApp);},
61
- getMongoose(){return fakeMongoose; }
62
- };
63
77
 
64
- await InitApp.createApp({master, config, options});
65
- expect(constructorCalled).to.be.true;
66
- expect(preCalled).to.be.true;
67
- expect(postCalled).to.be.true;
68
- });
69
- });
70
-
71
- describe('setAppEnvs', ()=>{
72
- const fakeManifest = {
73
- targets:{
74
- server:{
75
- roles: ['root', 'guest']
76
- }
77
- }
78
- };
79
- it('runs ok and emits', async()=>{
80
- let preCalled = false;
81
- let postCalled = false;
82
- ADDS.init({
83
- app:{
84
- setEnv:{
85
- pre(){
86
- preCalled = true;
87
- },
88
- post(){
89
- postCalled = true;
90
- }
91
- }
92
- }
78
+ describe("setAppEnvs", () => {
79
+ const fakeManifest = {
80
+ targets: {
81
+ server: {
82
+ roles: ["root", "guest"],
83
+ },
84
+ },
85
+ };
86
+ it("runs ok and emits", async () => {
87
+ let preCalled = false;
88
+ let postCalled = false;
89
+ ADDS.init({
90
+ app: {
91
+ setEnv: {
92
+ pre() {
93
+ preCalled = true;
94
+ },
95
+ post() {
96
+ postCalled = true;
97
+ },
98
+ },
99
+ },
100
+ });
101
+
102
+ const config = { get: (str) => str + "_fake" };
103
+ const options = { fake: "options" };
104
+ const fakeApp = {
105
+ setEnv() {},
106
+ };
107
+ const master = {
108
+ getApp() {
109
+ return fakeApp;
110
+ },
111
+ getManifest() {
112
+ return fakeManifest;
113
+ },
114
+ setEnv() {},
115
+ };
116
+
117
+ await InitApp.setAppEnvs({ master, config, options });
118
+
119
+ expect(preCalled).to.be.true;
120
+ expect(postCalled).to.be.true;
121
+ });
93
122
  });
94
123
 
95
-
96
- const config = {get:str => str + '_fake' };
97
- const options = {fake: 'options'};
98
- const fakeApp = {
99
- setEnv(){
100
-
101
- }
102
- };
103
- const master = {
104
- getApp(){
105
- return fakeApp;
106
- },
107
- getManifest(){
108
- return fakeManifest;
109
- },
110
- setEnv(){
111
-
112
- }
113
- };
114
-
115
- await InitApp.setAppEnvs({master, config, options});
116
-
117
- expect(preCalled).to.be.true;
118
- expect(postCalled).to.be.true;
119
- });
120
- });
121
-
122
-
123
- describe('importModules', ()=>{
124
- const fakeManifest = {
125
- targets:{
126
- server:{
127
- roles: ['root', 'guest']
128
- }
129
- }
130
- };
131
- it('runs ok and emits', async()=>{
132
- let preCalled = false;
133
- let postCalled = false;
134
- ADDS.init({
135
- app:{
136
- importModules:{
137
- pre(){
138
- preCalled = true;
139
- },
140
- post(){
141
- postCalled = true;
142
- }
143
- }
144
- }
124
+ describe("importModules", () => {
125
+ const fakeManifest = {
126
+ targets: {
127
+ server: {
128
+ roles: ["root", "guest"],
129
+ },
130
+ },
131
+ };
132
+ it("runs ok and emits", async () => {
133
+ let preCalled = false;
134
+ let postCalled = false;
135
+ ADDS.init({
136
+ app: {
137
+ importModules: {
138
+ pre() {
139
+ preCalled = true;
140
+ },
141
+ post() {
142
+ postCalled = true;
143
+ },
144
+ },
145
+ },
146
+ });
147
+
148
+ const config = {
149
+ get: (str) => {
150
+ if (str === "importModulesFromNPM") {
151
+ return ["fakeMod", "fakeMod2"];
152
+ } else {
153
+ return str + "_fake";
154
+ }
155
+ },
156
+ };
157
+ const options = { fake: "options" };
158
+ const fakeApp = {
159
+ setEnv() {},
160
+ importModulesFrom(modsPath) {
161
+ expect(modsPath).to.be.equal("modulesPath_fake");
162
+ },
163
+ importModuleFrom(modPath, modName) {
164
+ expect(modPath).to.be.equal("npmPath_fake/" + modName);
165
+ },
166
+ };
167
+ const master = {
168
+ getApp() {
169
+ return fakeApp;
170
+ },
171
+ getManifest() {
172
+ return fakeManifest;
173
+ },
174
+ };
175
+
176
+ await InitApp.importModules({ master, config, options });
177
+
178
+ expect(preCalled).to.be.true;
179
+ expect(postCalled).to.be.true;
180
+ });
181
+
182
+ it("runs ok and emits, not config.importModulesFromNPM", async () => {
183
+ let preCalled = false;
184
+ let postCalled = false;
185
+ ADDS.init({
186
+ app: {
187
+ importModules: {
188
+ pre() {
189
+ preCalled = true;
190
+ },
191
+ post() {
192
+ postCalled = true;
193
+ },
194
+ },
195
+ },
196
+ });
197
+
198
+ const config = {
199
+ get: (str) => {
200
+ return str + "_fake";
201
+ },
202
+ };
203
+ const options = { fake: "options" };
204
+ const fakeApp = {
205
+ setEnv() {},
206
+ importModulesFrom(modsPath) {
207
+ expect(modsPath).to.be.equal("modulesPath_fake");
208
+ },
209
+ importModuleFrom(modPath, modName) {
210
+ expect(modPath).to.be.equal("npmPath_fake/" + modName);
211
+ },
212
+ };
213
+ const master = {
214
+ getApp() {
215
+ return fakeApp;
216
+ },
217
+ getManifest() {
218
+ return fakeManifest;
219
+ },
220
+ };
221
+ await InitApp.importModules({ master, config, options });
222
+ expect(preCalled).to.be.true;
223
+ expect(postCalled).to.be.true;
224
+ });
145
225
  });
146
226
 
147
-
148
- const config = {
149
- get:(str) =>{
150
- if(str === 'importModulesFromNPM'){
151
- return ['fakeMod', 'fakeMod2'];
152
- }else{
153
- return str + '_fake';
154
- }
155
- }
156
- };
157
- const options = {fake: 'options'};
158
- const fakeApp = {
159
- setEnv(){
160
-
161
- },
162
- importModulesFrom(modsPath){
163
- expect(modsPath).to.be.equal('modulesPath_fake');
164
- },
165
- importModuleFrom(modPath, modName){
166
- expect(modPath).to.be.equal('npmPath_fake/'+modName);
167
- }
168
- };
169
- const master = {
170
- getApp(){
171
- return fakeApp;
172
- },
173
- getManifest(){
174
- return fakeManifest;
175
- }
176
- };
177
-
178
- await InitApp.importModules({master, config, options});
179
-
180
- expect(preCalled).to.be.true;
181
- expect(postCalled).to.be.true;
182
- });
183
-
184
- it('runs ok and emits, not config.importModulesFromNPM', async()=>{
185
- let preCalled = false;
186
- let postCalled = false;
187
- ADDS.init({
188
- app:{
189
- importModules:{
190
- pre(){
191
- preCalled = true;
192
- },
193
- post(){
194
- postCalled = true;
195
- }
196
- }
197
- }
227
+ describe("createReporter", () => {
228
+ it("ok", async () => {
229
+ let reporterConstructed = false;
230
+ class FakeReporter {
231
+ constructor(opts) {
232
+ expect(opts.origin.server).to.be.equal("host_fake");
233
+ reporterConstructed = true;
234
+ }
235
+ }
236
+ InitApp.ReporterConstructor = FakeReporter;
237
+ const config = { get: (str) => str + "_fake" };
238
+ const options = { fake: "options" };
239
+ const fakeApp = {
240
+ setEnv() {},
241
+ };
242
+ const master = {
243
+ getApp() {
244
+ return fakeApp;
245
+ },
246
+ getManifest() {
247
+ return fakeManifest;
248
+ },
249
+ };
250
+ await InitApp.createReporter({ master, config, options });
251
+ expect(reporterConstructed).to.be.true;
252
+ });
253
+
254
+ it("failure", async () => {
255
+ let reporterConstructed = false;
256
+ class FakeReporter {
257
+ constructor(opts) {
258
+ expect(opts.origin.server).to.be.equal("host_fake");
259
+ reporterConstructed = true;
260
+ throw new Error("constructor throwed");
261
+ }
262
+ }
263
+ InitApp.ReporterConstructor = FakeReporter;
264
+ const config = { get: (str) => str + "_fake" };
265
+ const options = { fake: "options" };
266
+ const fakeApp = {
267
+ setEnv() {},
268
+ };
269
+ const master = {
270
+ getApp() {
271
+ return fakeApp;
272
+ },
273
+ getManifest() {
274
+ return fakeManifest;
275
+ },
276
+ };
277
+ try {
278
+ await InitApp.createReporter({ master, config, options });
279
+ } catch (e) {
280
+ expect(reporterConstructed).to.be.true;
281
+ expect(e.message).to.be.equal("constructor throwed");
282
+ }
283
+ });
198
284
  });
199
285
 
200
-
201
- const config = {
202
- get:(str) =>{
203
- return str + '_fake';
204
- }
205
- };
206
- const options = {fake: 'options'};
207
- const fakeApp = {
208
- setEnv(){
209
-
210
- },
211
- importModulesFrom(modsPath){
212
- expect(modsPath).to.be.equal('modulesPath_fake');
213
- },
214
- importModuleFrom(modPath, modName){
215
- expect(modPath).to.be.equal('npmPath_fake/'+modName);
216
- }
217
- };
218
- const master = {
219
- getApp(){
220
- return fakeApp;
221
- },
222
- getManifest(){
223
- return fakeManifest;
224
- }
225
- };
226
- await InitApp.importModules({master, config, options});
227
- expect(preCalled).to.be.true;
228
- expect(postCalled).to.be.true;
229
- });
230
- });
231
-
232
- describe('createReporter', ()=>{
233
- it('ok', async()=>{
234
- let reporterConstructed = false;
235
- class FakeReporter{
236
- constructor(opts){
237
- expect(opts.origin.server).to.be.equal('host_fake');
238
- reporterConstructed = true;
239
- }
240
- }
241
- InitApp.ReporterConstructor = FakeReporter;
242
- const config = {get:str => str + '_fake' };
243
- const options = {fake: 'options'};
244
- const fakeApp = {
245
- setEnv(){}
246
- };
247
- const master = {
248
- getApp(){
249
- return fakeApp;
250
- },
251
- getManifest(){
252
- return fakeManifest;
253
- }
254
- };
255
- await InitApp.createReporter({master, config, options});
256
- expect(reporterConstructed).to.be.true;
257
- });
258
-
259
- it('failure', async()=>{
260
- let reporterConstructed = false;
261
- class FakeReporter{
262
- constructor(opts){
263
- expect(opts.origin.server).to.be.equal('host_fake');
264
- reporterConstructed = true;
265
- throw new Error('constructor throwed');
266
- }
267
- }
268
- InitApp.ReporterConstructor = FakeReporter;
269
- const config = {get:str => str + '_fake' };
270
- const options = {fake: 'options'};
271
- const fakeApp = {
272
- setEnv(){}
273
- };
274
- const master = {
275
- getApp(){
276
- return fakeApp;
277
- },
278
- getManifest(){
279
- return fakeManifest;
280
- }
281
- };
282
- try {
283
- await InitApp.createReporter({master, config, options});
284
- } catch (e) {
285
- expect(reporterConstructed).to.be.true;
286
- expect(e.message).to.be.equal('constructor throwed');
287
- }
288
- });
289
- });
290
-
291
- describe('run', ()=>{
292
- const fakeManifest = {
293
- targets:{
294
- server:{
295
- roles: ['root', 'guest']
296
- }
297
- }
298
- };
299
-
300
- it('ok, emits pre - ok, throws from post emit', async()=>{
301
- let constructorCalled = false;
302
- let preCalled = false;
303
- let postCalled = false;
304
-
305
- ADDS.init({
306
- app:{
307
- pre(){
308
- preCalled = true;
309
- },
310
- post(){
311
- postCalled = true;
312
- throw new Error('Post throwed');
313
- }
314
- }
286
+ describe("run", () => {
287
+ const fakeManifest = {
288
+ targets: {
289
+ server: {
290
+ roles: ["root", "guest"],
291
+ },
292
+ },
293
+ };
294
+
295
+ it("ok, emits pre - ok, throws from post emit", async () => {
296
+ let constructorCalled = false;
297
+ let preCalled = false;
298
+ let postCalled = false;
299
+
300
+ ADDS.init({
301
+ app: {
302
+ pre() {
303
+ preCalled = true;
304
+ },
305
+ post() {
306
+ postCalled = true;
307
+ throw new Error("Post throwed");
308
+ },
309
+ },
310
+ });
311
+ const fakeMongoose = {
312
+ this: "is fake indeed",
313
+ };
314
+ class FakeApp {
315
+ constructor({ mongoose }) {
316
+ expect(mongoose).to.be.deep.equal(fakeMongoose);
317
+ constructorCalled = true;
318
+ }
319
+ }
320
+ InitApp.AppConstructor = FakeApp;
321
+
322
+ const config = {
323
+ get: (str) => {
324
+ if (str === "importModulesFromNPM") {
325
+ return ["fakeMod", "fakeMod2"];
326
+ } else {
327
+ return str + "_fake";
328
+ }
329
+ },
330
+ };
331
+ const options = { fake: "options" };
332
+ const fakeApp = {
333
+ setEnv() {},
334
+ importModulesFrom(modsPath) {
335
+ expect(modsPath).to.be.equal("modulesPath_fake");
336
+ },
337
+ importModuleFrom(modPath, modName) {
338
+ expect(modPath).to.be.equal("npmPath_fake/" + modName);
339
+ },
340
+ };
341
+ const master = {
342
+ setEnv() {},
343
+ setApp(app) {
344
+ expect(app).to.be.instanceof(FakeApp);
345
+ },
346
+ throwError(e) {
347
+ throw new Error(e);
348
+ },
349
+ getMongoose() {
350
+ return fakeMongoose;
351
+ },
352
+ getApp() {
353
+ return fakeApp;
354
+ },
355
+ getManifest() {
356
+ return fakeManifest;
357
+ },
358
+ };
359
+ try {
360
+ await new InitApp().run({ master, config, options });
361
+ } catch (e) {
362
+ expect(constructorCalled).to.be.true;
363
+ expect(preCalled).to.be.true;
364
+ expect(postCalled).to.be.true;
365
+ expect(e.message).to.be.equal("Post throwed");
366
+ }
367
+ });
315
368
  });
316
- const fakeMongoose = {
317
- this:'is fake indeed'
318
- };
319
- class FakeApp{
320
- constructor({mongoose}){
321
- expect(mongoose).to.be.deep.equal(fakeMongoose);
322
- constructorCalled = true;
323
- }
324
- };
325
- InitApp.AppConstructor = FakeApp;
326
-
327
- const config = {
328
- get:(str) =>{
329
- if(str === 'importModulesFromNPM'){
330
- return ['fakeMod', 'fakeMod2'];
331
- }else{
332
- return str + '_fake';
333
- }
334
- }
335
- };
336
- const options = {fake: 'options'};
337
- const fakeApp = {
338
- setEnv(){},
339
- importModulesFrom(modsPath){
340
- expect(modsPath).to.be.equal('modulesPath_fake');
341
- },
342
- importModuleFrom(modPath, modName){
343
- expect(modPath).to.be.equal('npmPath_fake/'+modName);
344
- }
345
- };
346
- const master = {
347
- setEnv(){},
348
- setApp(app){expect(app).to.be.instanceof(FakeApp);},
349
- throwError(e){
350
- throw new Error(e)
351
- },
352
- getMongoose(){return fakeMongoose; },
353
- getApp(){
354
- return fakeApp;
355
- },
356
- getManifest(){
357
- return fakeManifest;
358
- }
359
- };
360
- try {
361
- await (new InitApp()).run({master, config, options});
362
- } catch (e) {
363
- expect(constructorCalled).to.be.true;
364
- expect(preCalled).to.be.true;
365
- expect(postCalled).to.be.true;
366
- expect(e.message).to.be.equal('Post throwed');
367
- }
368
-
369
-
370
-
371
- });
372
369
  });
373
-
374
-
375
- });
376
370
  };