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,44 +1,42 @@
1
- const InitBodyparser = require('../../src/init/bodyparser');
2
- const mock = require('mock-require');
1
+ const InitBodyparser = require("../../src/init/lib/bodyparser");
2
+ const mock = require("mock-require");
3
3
 
4
- module.exports = ({
5
- expect
6
- }) => {
7
- describe('BodyParser', () => {
8
- describe('run', () => {
9
- it('run, middleware returned and set', async () => {
10
- let useCalled = false;
11
- let middlewareGeneratorCalled = 0;
12
- mock('body-parser', {
13
- json(param){
14
- expect(typeof param).to.be.equal('object');
15
- middlewareGeneratorCalled++;
16
- return ()=>{};
17
- },
18
- urlencoded(param){
19
- expect(typeof param).to.be.equal('object');
20
- middlewareGeneratorCalled++;
21
- return ()=>{};
22
- },
4
+ module.exports = ({ expect }) => {
5
+ describe("BodyParser", () => {
6
+ describe("run", () => {
7
+ it("run, middleware returned and set", async () => {
8
+ let useCalled = false;
9
+ let middlewareGeneratorCalled = 0;
10
+ mock("body-parser", {
11
+ json(param) {
12
+ expect(typeof param).to.be.equal("object");
13
+ middlewareGeneratorCalled++;
14
+ return () => {};
15
+ },
16
+ urlencoded(param) {
17
+ expect(typeof param).to.be.equal("object");
18
+ middlewareGeneratorCalled++;
19
+ return () => {};
20
+ },
21
+ });
22
+ const master = {
23
+ getServer() {
24
+ return {
25
+ use(func) {
26
+ expect(typeof func).to.be.equal("function");
27
+ useCalled = true;
28
+ },
29
+ };
30
+ },
31
+ };
32
+ await new InitBodyparser().run({ master });
33
+ expect(useCalled).to.be.true;
34
+ expect(middlewareGeneratorCalled).to.be.equal(2);
35
+ });
23
36
  });
24
- const master = {
25
- getServer() {
26
- return {
27
- use(func) {
28
- expect(typeof func).to.be.equal('function');
29
- useCalled = true;
30
- }
31
- };
32
- }
33
- };
34
- await (new InitBodyparser()).run({master});
35
- expect(useCalled).to.be.true;
36
- expect(middlewareGeneratorCalled).to.be.equal(2);
37
- });
38
- });
39
37
 
40
- after(()=>{
41
- mock.stop('body-parser');
38
+ after(() => {
39
+ mock.stop("body-parser");
40
+ });
42
41
  });
43
- });
44
42
  };
@@ -1,36 +1,34 @@
1
- const InitCompression = require('../../src/init/compression');
2
- const mock = require('mock-require');
1
+ const InitCompression = require("../../src/init/lib/compression");
2
+ const mock = require("mock-require");
3
3
 
4
- module.exports = ({
5
- expect
6
- }) => {
7
- describe('Compression', () => {
8
- describe('run', () => {
9
- it('run, middleware returned and set', async () => {
10
- let useCalled = false;
11
- let compressionCalled = false;
12
- mock('compression', ()=>{
13
- compressionCalled = true;
14
- return ()=>{};
4
+ module.exports = ({ expect }) => {
5
+ describe("Compression", () => {
6
+ describe("run", () => {
7
+ it("run, middleware returned and set", async () => {
8
+ let useCalled = false;
9
+ let compressionCalled = false;
10
+ mock("compression", () => {
11
+ compressionCalled = true;
12
+ return () => {};
13
+ });
14
+ const master = {
15
+ getServer() {
16
+ return {
17
+ use(func) {
18
+ expect(typeof func).to.be.equal("function");
19
+ useCalled = true;
20
+ },
21
+ };
22
+ },
23
+ };
24
+ await new InitCompression().run({ master });
25
+ expect(useCalled).to.be.true;
26
+ expect(compressionCalled).to.be.true;
27
+ });
15
28
  });
16
- const master = {
17
- getServer() {
18
- return {
19
- use(func) {
20
- expect(typeof func).to.be.equal('function');
21
- useCalled = true;
22
- }
23
- };
24
- }
25
- };
26
- await (new InitCompression()).run({master});
27
- expect(useCalled).to.be.true;
28
- expect(compressionCalled).to.be.true;
29
- });
30
- });
31
29
 
32
- after(()=>{
33
- mock.stop('compression');
30
+ after(() => {
31
+ mock.stop("compression");
32
+ });
34
33
  });
35
- });
36
34
  };
package/test/init/cors.js CHANGED
@@ -1,46 +1,45 @@
1
- const InitCORS = require('../../src/init/cors');
2
- const mock = require('mock-require');
1
+ const InitCORS = require("../../src/init/lib/cors");
2
+ const mock = require("mock-require");
3
3
 
4
- mock('cors', ()=>{
5
- return ()=>{};
4
+ mock("cors", () => {
5
+ return () => {};
6
6
  });
7
7
 
8
- module.exports = ({expect})=>{
9
- describe('InitCORS', ()=>{
10
- it('getOriginFilter', ()=>{
11
- const res = InitCORS.getOriginFilter(['name1', 'name3']);
12
- res('name', (a, b)=>{
13
- expect(a).to.be.null;
14
- expect(b).to.be.false;
8
+ module.exports = ({ expect }) => {
9
+ describe("InitCORS", () => {
10
+ it("getOriginFilter", () => {
11
+ const res = InitCORS.getOriginFilter(["name1", "name3"]);
12
+ res("name", (a, b) => {
13
+ expect(a).to.be.null;
14
+ expect(b).to.be.false;
15
+ });
16
+ res("name1", (a, b) => {
17
+ expect(a).to.be.null;
18
+ expect(b).to.be.true;
19
+ });
15
20
  });
16
- res('name1', (a, b)=>{
17
- expect(a).to.be.null;
18
- expect(b).to.be.true;
19
- });
20
-
21
- });
22
21
 
23
- it('run', async () => {
24
- let mdSet = false;
25
- const config = {
26
- get(str){
27
- return {
28
- 'cors': ['domain1', 'domain2']
29
- }[str];
30
- }
31
- };
32
- const master = {
33
- getServer(){
34
- return {
35
- use(md){
36
- expect(typeof md).to.be.equal('function');
37
- mdSet = true;
38
- }
39
- };
40
- }
41
- };
42
- await new InitCORS().run({config, master});
43
- expect(mdSet).to.be.equal(true);
22
+ it("run", async () => {
23
+ let mdSet = false;
24
+ const config = {
25
+ get(str) {
26
+ return {
27
+ cors: ["domain1", "domain2"],
28
+ }[str];
29
+ },
30
+ };
31
+ const master = {
32
+ getServer() {
33
+ return {
34
+ use(md) {
35
+ expect(typeof md).to.be.equal("function");
36
+ mdSet = true;
37
+ },
38
+ };
39
+ },
40
+ };
41
+ await new InitCORS().run({ config, master });
42
+ expect(mdSet).to.be.equal(true);
43
+ });
44
44
  });
45
- });
46
45
  };
package/test/init/db.js CHANGED
@@ -1,70 +1,66 @@
1
- const path = require('path');
2
- const mock = require('mock-require');
3
- const InitDB = require('../../src/init/db');
4
- const pathToIncrement = path.resolve(__dirname, '../../src/model/increment');
1
+ const path = require("path");
2
+ const mock = require("mock-require");
3
+ const InitDB = require("../../src/init/lib/db");
4
+ const pathToIncrement = path.resolve(__dirname, "../../src/model/increment");
5
5
 
6
- class Schema{
7
- constructor(){
8
- this.statics = {};
9
- }
10
- };
11
-
12
- module.exports = ({
13
- expect
14
- }) => {
6
+ class Schema {
7
+ constructor() {
8
+ this.statics = {};
9
+ }
10
+ }
15
11
 
16
- describe('DB', () => {
17
- describe('run', () => {
18
- it('simple', async () => {
19
- console.log(pathToIncrement);
20
- const config = {
21
- get(str) {
22
- return {
23
- 'mongoose': {
24
- "uri": "mongodb://localhost/base?authSource=base",
25
- "options": {
26
- "host": "localhost",
27
- "autoIndex": false,
28
- "poolSize": 10,
29
- "bufferMaxEntries": 0
30
- }
31
- }
32
- }[str];
33
- }
34
- };
35
- mock('mongoose', {
36
- async connect(uri, opts) {
37
- expect(typeof uri).to.be.equal('string');
38
- expect(typeof opts).to.be.equal('object');
39
- },
40
- model(){
41
- return {
42
- getNext(){},
43
- rebase(){},
44
- };
45
- },
46
- Schema,
47
- fakeMongoose: true
12
+ module.exports = ({ expect }) => {
13
+ describe("DB", () => {
14
+ describe("run", () => {
15
+ it("simple", async () => {
16
+ console.log(pathToIncrement);
17
+ const config = {
18
+ get(str) {
19
+ return {
20
+ mongoose: {
21
+ uri: "mongodb://localhost/base?authSource=base",
22
+ options: {
23
+ host: "localhost",
24
+ autoIndex: false,
25
+ poolSize: 10,
26
+ bufferMaxEntries: 0,
27
+ },
28
+ },
29
+ }[str];
30
+ },
31
+ };
32
+ mock("mongoose", {
33
+ async connect(uri, opts) {
34
+ expect(typeof uri).to.be.equal("string");
35
+ expect(typeof opts).to.be.equal("object");
36
+ },
37
+ model() {
38
+ return {
39
+ getNext() {},
40
+ rebase() {},
41
+ };
42
+ },
43
+ Schema,
44
+ fakeMongoose: true,
45
+ });
46
+ mock(pathToIncrement, {
47
+ init() {},
48
+ });
49
+ const master = {
50
+ setMongoose(itm) {
51
+ expect(itm.fakeMongoose).to.be.true;
52
+ },
53
+ };
54
+ await new InitDB().run({ config, master });
55
+ });
48
56
  });
49
- mock(pathToIncrement, {
50
- init(){}
57
+ after(() => {
58
+ mock.stop("mongoose");
59
+ mock.stop(pathToIncrement);
60
+ const mod = require(pathToIncrement);
61
+ delete mod.model;
62
+ delete mod.next;
63
+ delete mod.rebase;
51
64
  });
52
- const master = {
53
- setMongoose(itm){
54
- expect(itm.fakeMongoose).to.be.true;
55
- }
56
- };
57
- await new InitDB().run({config, master});
58
- });
59
-
60
- });
61
- after(() => {
62
- mock.stop('mongoose');
63
- mock.stop(pathToIncrement);
64
- const mod = require(pathToIncrement);
65
- delete mod.model;
66
- delete mod.next;
67
- delete mod.rebase;
68
65
  });
69
- });
70
66
  };
package/test/init/env.js CHANGED
@@ -1,126 +1,121 @@
1
- const InitEnv = require('../../src/init/env');
1
+ const InitEnv = require("../../src/init/lib/env");
2
2
 
3
-
4
- function getFromLib(vals, path, def){
5
- if(Object.prototype.hasOwnProperty.call(vals, path)){
6
- return vals[path];
7
- }else{
8
- return def;
9
- }
3
+ function getFromLib(vals, path, def) {
4
+ if (Object.prototype.hasOwnProperty.call(vals, path)) {
5
+ return vals[path];
6
+ } else {
7
+ return def;
8
+ }
10
9
  }
11
10
 
11
+ module.exports = ({ expect }) => {
12
+ describe("Envs", () => {
13
+ describe("getProxyPort", () => {
14
+ it("proxy:port - number", () => {
15
+ const config = {
16
+ get(path) {
17
+ return path === "proxy:port" ? 8080 : null;
18
+ },
19
+ };
20
+ const port = InitEnv.getProxyPort(config);
21
+ expect(port).to.be.equal(8080);
22
+ });
12
23
 
13
- module.exports = ({expect})=>{
14
- describe('Envs', ()=>{
15
- describe('getProxyPort', ()=>{
16
- it('proxy:port - number', ()=>{
17
- const config = {
18
- get(path){
19
- return path === 'proxy:port' ? 8080:null;
20
- }
21
- };
22
- const port = InitEnv.getProxyPort(config);
23
- expect(port).to.be.equal(8080);
24
- });
24
+ it("port - string", () => {
25
+ const config = {
26
+ get(path) {
27
+ return path === "port" ? "80" : null;
28
+ },
29
+ };
30
+ const port = InitEnv.getProxyPort(config);
31
+ expect(port).to.be.equal(80);
32
+ });
33
+ });
25
34
 
26
- it('port - string', ()=>{
27
- const config = {
28
- get(path){
29
- return path === 'port' ? '80':null;
30
- }
31
- };
32
- const port = InitEnv.getProxyPort(config);
33
- expect(port).to.be.equal(80);
34
- });
35
- });
35
+ describe("getFullServerName", () => {
36
+ it("proxy:secure - true, proxy:port - 8080", () => {
37
+ const vals = {
38
+ "proxy:secure": true,
39
+ "proxy:port": 8080,
40
+ host: "hostname",
41
+ };
36
42
 
43
+ const config = {
44
+ get(path) {
45
+ return getFromLib(vals, path, null);
46
+ },
47
+ };
48
+ const address = InitEnv.getFullServerName(config);
49
+ expect(address).to.be.equal("https://hostname:8080");
50
+ });
37
51
 
38
- describe('getFullServerName', ()=>{
39
- it('proxy:secure - true, proxy:port - 8080', ()=>{
40
- const vals = {
41
- 'proxy:secure': true,
42
- 'proxy:port': 8080,
43
- 'host': 'hostname'
44
- };
52
+ it("proxy:secure - false, proxy:port - 80", () => {
53
+ const vals = {
54
+ "proxy:secure": false,
55
+ "proxy:port": 80,
56
+ host: "hostname",
57
+ };
45
58
 
46
- const config = {
47
- get(path){
48
- return getFromLib(vals, path, null);
49
- }
50
- };
51
- const address = InitEnv.getFullServerName(config);
52
- expect(address).to.be.equal('https://hostname:8080');
53
- });
59
+ const config = {
60
+ get(path) {
61
+ return getFromLib(vals, path, null);
62
+ },
63
+ };
64
+ const address = InitEnv.getFullServerName(config);
65
+ expect(address).to.be.equal("http://hostname");
66
+ });
67
+ });
54
68
 
55
- it('proxy:secure - false, proxy:port - 80', ()=>{
56
- const vals = {
57
- 'proxy:secure': false,
58
- 'proxy:port': 80,
59
- 'host': 'hostname'
60
- };
69
+ describe("run", () => {
70
+ it("path:ws - empty", async () => {
71
+ const vals = {
72
+ "proxy:secure": true,
73
+ "proxy:port": 8080,
74
+ host: "hostname",
75
+ "path:ws": undefined,
76
+ };
77
+ const master = {
78
+ getAbsolutePath(str) {
79
+ return str + "_fake_absolute";
80
+ },
81
+ };
82
+ const options = {
83
+ pathToApp: "pathToApp__fake",
84
+ pathToNPM: "pathToNPM__fake",
85
+ };
86
+ const config = {
87
+ get(path) {
88
+ return getFromLib(vals, path, null);
89
+ },
90
+ set() {},
91
+ };
92
+ await new InitEnv().run({ master, options, config });
93
+ });
61
94
 
62
- const config = {
63
- get(path){
64
- return getFromLib(vals, path, null);
65
- }
66
- };
67
- const address = InitEnv.getFullServerName(config);
68
- expect(address).to.be.equal('http://hostname');
69
- });
95
+ it("path:ws - not empty", async () => {
96
+ const vals = {
97
+ "proxy:secure": true,
98
+ "proxy:port": 8080,
99
+ host: "hostname",
100
+ "path:ws": "some_path",
101
+ };
102
+ const master = {
103
+ getAbsolutePath(str) {
104
+ return str + "_fake_absolute";
105
+ },
106
+ };
107
+ const options = {
108
+ pathToApp: "pathToApp__fake",
109
+ pathToNPM: "pathToNPM__fake",
110
+ };
111
+ const config = {
112
+ get(path) {
113
+ return getFromLib(vals, path, null);
114
+ },
115
+ set() {},
116
+ };
117
+ await new InitEnv().run({ master, options, config });
118
+ });
119
+ });
70
120
  });
71
-
72
- describe('run', ()=>{
73
- it('path:ws - empty', async ()=>{
74
- const vals = {
75
- 'proxy:secure': true,
76
- 'proxy:port': 8080,
77
- 'host': 'hostname',
78
- 'path:ws': undefined
79
- };
80
- const master = {
81
- getAbsolutePath(str){
82
- return str+'_fake_absolute';
83
- }
84
- };
85
- const options = {
86
- pathToApp: 'pathToApp__fake',
87
- pathToNPM: 'pathToNPM__fake',
88
- };
89
- const config = {
90
- get(path){
91
- return getFromLib(vals, path, null);
92
- },
93
- set(){}
94
- };
95
- await new InitEnv().run({master, options, config});
96
- });
97
-
98
- it('path:ws - not empty', async ()=>{
99
- const vals = {
100
- 'proxy:secure': true,
101
- 'proxy:port': 8080,
102
- 'host': 'hostname',
103
- 'path:ws': 'some_path'
104
- };
105
- const master = {
106
- getAbsolutePath(str){
107
- return str+'_fake_absolute';
108
- }
109
- };
110
- const options = {
111
- pathToApp: 'pathToApp__fake',
112
- pathToNPM: 'pathToNPM__fake',
113
- };
114
- const config = {
115
- get(path){
116
- return getFromLib(vals, path, null);
117
- },
118
- set(){}
119
- };
120
- await new InitEnv().run({master, options, config});
121
- });
122
-
123
- });
124
-
125
- });
126
121
  };