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
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env sh
2
+ . "$(dirname -- "$0")/_/husky.sh"
3
+
4
+ npm test
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "not-node",
3
- "version": "6.2.18",
3
+ "version": "6.2.19",
4
4
  "description": "node complimentary part for client side notFramework.",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -11,7 +11,8 @@
11
11
  "js-watch": "watch 'npm run cover' ./src ./test --interval=5",
12
12
  "watch:build:cover:dev": "npm-run-all --parallel js-watch",
13
13
  "cover": "nyc npm test",
14
- "clear:playground": "rm -rf ./playground"
14
+ "clear:playground": "rm -rf ./playground",
15
+ "prepare": "husky install"
15
16
  },
16
17
  "bin": {
17
18
  "not-node": "./bin/not-node.js",
@@ -35,7 +36,6 @@
35
36
  "url": "https://github.com/interrupter/not-node/issues"
36
37
  },
37
38
  "dependencies": {
38
- "xss": "*",
39
39
  "body-parser": "^1.20.1",
40
40
  "commander": "^9.5.0",
41
41
  "compression": "^1.7.4",
@@ -63,7 +63,8 @@
63
63
  "not-config": "*",
64
64
  "not-error": "*",
65
65
  "not-filter": "*",
66
- "not-locale": "*",
66
+ "not-inform": "*",
67
+ "not-locale": "^0.0.22",
67
68
  "not-log": "*",
68
69
  "not-monitor": "*",
69
70
  "not-path": "*",
@@ -76,6 +77,7 @@
76
77
  "serve-static": "*",
77
78
  "simple-git": "*",
78
79
  "validator": "*",
80
+ "xss": "*",
79
81
  "yargs": "*"
80
82
  },
81
83
  "devDependencies": {
@@ -85,6 +87,7 @@
85
87
  "eslint": "^8.31.0",
86
88
  "eslint-plugin-node": "^11.1.0",
87
89
  "eslint-plugin-sonarjs": "^0.17.0",
90
+ "husky": "^8.0.3",
88
91
  "ink-docstrap": "^1.3.2",
89
92
  "ioredis": "^5.2.4",
90
93
  "jsdoc": "^4.0.0",
package/src/auth/roles.js CHANGED
@@ -16,6 +16,14 @@ function compareRolesArrayAgainstArray(userRoles, actionRoles, strict) {
16
16
  }
17
17
  }
18
18
 
19
+ function compareRolesStrict(userRoles, actionRoles) {
20
+ if (actionRoles.length === 1) {
21
+ return actionRoles.includes(userRoles);
22
+ } else {
23
+ return false;
24
+ }
25
+ }
26
+
19
27
  /**
20
28
  * Compares two list of roles
21
29
  * @param {array|string} userRoles roles of user
@@ -41,7 +49,7 @@ function compareRoles(userRoles, actionRoles, strict = true) {
41
49
  } else {
42
50
  if (Array.isArray(actionRoles)) {
43
51
  if (strict) {
44
- return false;
52
+ return compareRolesStrict(userRoles, actionRoles);
45
53
  } else {
46
54
  return actionRoles.indexOf(userRoles) > -1;
47
55
  }
package/src/auth/rules.js CHANGED
@@ -17,13 +17,13 @@ function compareWithRoot(rule, root) {
17
17
  }
18
18
  }
19
19
 
20
- function compareRuleRoles(rule, role, auth) {
21
- if (ROLES.compareRoles(rule.role, role)) {
22
- if (objHas(rule, "auth")) {
23
- if (rule.auth && auth) {
20
+ function compareRuleRoles(actionRule, userRole, auth) {
21
+ if (ROLES.compareRoles(userRole, actionRule.role)) {
22
+ if (objHas(actionRule, "auth")) {
23
+ if (actionRule.auth && auth) {
24
24
  return true;
25
25
  } else {
26
- return !rule.auth && !auth;
26
+ return !actionRule.auth && !auth;
27
27
  }
28
28
  } else {
29
29
  return true;
@@ -1 +1 @@
1
- export default (program, { CWD }) => {};
1
+ export default (/*program, { /*CWD }*/) => {};
@@ -1 +1 @@
1
- export default (program, { CWD }) => {};
1
+ export default (/*program, { CWD }*/) => {};
@@ -1 +1 @@
1
- export default (program, { CWD }) => {};
1
+ export default (/*program, { CWD }*/) => {};
package/src/common.js CHANGED
@@ -155,7 +155,7 @@ module.exports.executeFunctionAsAsync = executeFunctionAsAsync;
155
155
  * @return {Promise} results of method execution
156
156
  **/
157
157
  module.exports.executeObjectFunction = async (obj, name, params) => {
158
- if (obj) {
158
+ if (!obj) {
159
159
  return;
160
160
  }
161
161
  if (name.indexOf(".") > -1) {
package/src/domain.js CHANGED
@@ -63,19 +63,27 @@ class notDomain extends EventEmitter {
63
63
  return this;
64
64
  }
65
65
 
66
- getOptions() {
66
+ get modules() {
67
+ return this.#modules;
68
+ }
69
+
70
+ get options() {
67
71
  return this.#options;
68
72
  }
69
73
 
74
+ getOptions() {
75
+ return this.options;
76
+ }
77
+
70
78
  /**
71
79
  * Cycles throu all imported modules, passes name, module, and itself
72
80
  * to argument function
73
81
  * @param {function} func function to perfom some action with module
74
82
  **/
75
83
  forEachMod(func) {
76
- if (this.#modules) {
77
- for (let t of Object.keys(this.#modules)) {
78
- let mod = this.#modules[t];
84
+ if (this.modules) {
85
+ for (let t of Object.keys(this.modules)) {
86
+ let mod = this.modules[t];
79
87
  if (mod) {
80
88
  func(t, mod, this);
81
89
  }
@@ -105,14 +113,18 @@ class notDomain extends EventEmitter {
105
113
  let mod = new notModule({
106
114
  modPath: modulePath,
107
115
  modObject: null,
108
- mongoose: this.#options.mongoose,
116
+ mongoose: this.options.mongoose,
109
117
  notApp: this,
110
- fields: this.#options.fields,
118
+ fields: this.options.fields,
111
119
  });
112
120
  this.importModule(mod, mod.getName() || moduleName);
113
121
  return this;
114
122
  }
115
123
 
124
+ setModule(name, val) {
125
+ this.#modules[name] = val;
126
+ }
127
+
116
128
  /**
117
129
  * Import module object. Chainable.
118
130
  * @param {object} mod notModule instance
@@ -120,7 +132,7 @@ class notDomain extends EventEmitter {
120
132
  * @return {object} notDomain
121
133
  **/
122
134
  importModule(mod, moduleName) {
123
- this.#modules[moduleName] = mod;
135
+ this.setModule(moduleName, mod);
124
136
  return this;
125
137
  }
126
138
 
@@ -132,8 +144,8 @@ class notDomain extends EventEmitter {
132
144
  getRoute(name) {
133
145
  if (name.indexOf("//") > 0) {
134
146
  let [moduleName, routeName, routeFunctionName] = name.split("//");
135
- if (this.#modules && objHas(this.#modules, moduleName)) {
136
- let route = this.#modules[moduleName].getRoute(routeName);
147
+ if (this.modules && objHas(this.modules, moduleName)) {
148
+ let route = this.getModule(moduleName).getRoute(routeName);
137
149
  if (objHas(route, routeFunctionName)) {
138
150
  return route[routeFunctionName];
139
151
  }
@@ -177,8 +189,8 @@ class notDomain extends EventEmitter {
177
189
 
178
190
  getByFullPath(name, type) {
179
191
  let [moduleName, resourceName] = name.split("//");
180
- if (this.#modules && objHas(this.#modules, moduleName)) {
181
- return this.#modules[moduleName][`get${firstLetterToUpper(type)}`](
192
+ if (this.modules && objHas(this.modules, moduleName)) {
193
+ return this.getModule(moduleName)[`get${firstLetterToUpper(type)}`](
182
194
  resourceName
183
195
  );
184
196
  } else {
@@ -188,9 +200,9 @@ class notDomain extends EventEmitter {
188
200
  }
189
201
 
190
202
  getByShortPath(resourceName, type) {
191
- for (let moduleName of Object.keys(this.#modules)) {
203
+ for (let moduleName of Object.keys(this.modules)) {
192
204
  const res =
193
- this.#modules[moduleName][`get${firstLetterToUpper(type)}`](
205
+ this.getModule(moduleName)[`get${firstLetterToUpper(type)}`](
194
206
  resourceName
195
207
  );
196
208
  if (res) {
@@ -257,12 +269,12 @@ class notDomain extends EventEmitter {
257
269
  * @return {object} module
258
270
  **/
259
271
  getModule(moduleName) {
260
- if (this.#modules && objHas(this.#modules, moduleName)) {
261
- return this.#modules[moduleName];
272
+ if (this.modules && objHas(this.modules, moduleName)) {
273
+ return this.modules[moduleName];
262
274
  } else {
263
- for (let t in this.#modules) {
264
- if (this.#modules[t].getName() === moduleName) {
265
- return this.#modules[t];
275
+ for (let t in this.modules) {
276
+ if (this.modules[t].getName() === moduleName) {
277
+ return this.modules[t];
266
278
  }
267
279
  }
268
280
  return null;
@@ -275,7 +287,7 @@ class notDomain extends EventEmitter {
275
287
  * @param {Object} params params to pass to method
276
288
  **/
277
289
  async execInModules(methodName, params) {
278
- for (let mod of Object.values(this.#modules)) {
290
+ for (let mod of Object.values(this.modules)) {
279
291
  try {
280
292
  await executeObjectFunction(mod, "exec", [methodName, params]);
281
293
  } catch (e) {
@@ -289,7 +301,7 @@ class notDomain extends EventEmitter {
289
301
  * Create mongoose models.
290
302
  **/
291
303
  fabricate() {
292
- for (let mod of Object.values(this.#modules)) {
304
+ for (let mod of Object.values(this.modules)) {
293
305
  mod.fabricateModels && mod.fabricateModels();
294
306
  }
295
307
  }
@@ -406,7 +418,7 @@ class notDomain extends EventEmitter {
406
418
  * @return {Object} complex object with results
407
419
  **/
408
420
  getStatus() {
409
- const mods = Object.keys(this.#modules);
421
+ const mods = Object.keys(this.modules);
410
422
  let stats = {
411
423
  modules: {
412
424
  count: mods.length,
@@ -434,8 +446,8 @@ class notDomain extends EventEmitter {
434
446
  list: [],
435
447
  },
436
448
  };
437
- for (let modName in this.#modules) {
438
- const mod = this.#modules[modName];
449
+ for (let modName in this.modules) {
450
+ const mod = this.modules[modName];
439
451
  let modStatus = mod.getStatus();
440
452
  stats.modules.content[modName] = modStatus;
441
453
  stats.routes.count += modStatus.routes.count;
@@ -469,7 +481,7 @@ class notDomain extends EventEmitter {
469
481
  }
470
482
 
471
483
  getModulesNames() {
472
- return Object.keys(this.#modules);
484
+ return Object.keys(this.modules);
473
485
  }
474
486
  }
475
487
 
@@ -43,6 +43,9 @@ module.exports = class IdentityProviderSession {
43
43
  const roles = this.getRole();
44
44
  for (let role of roles) {
45
45
  if (
46
+ Array.isArray(
47
+ IdentityProviderSession.#getOptions().primaryRoles
48
+ ) &&
46
49
  IdentityProviderSession.#getOptions().primaryRoles.includes(
47
50
  role
48
51
  )
@@ -8,6 +8,10 @@ module.exports = class BatchRunner {
8
8
  this.setProcessors(processors);
9
9
  }
10
10
 
11
+ get processors() {
12
+ return this.#processors;
13
+ }
14
+
11
15
  setProcessors(list = []) {
12
16
  this.#processors = [...list];
13
17
  }
@@ -24,7 +28,7 @@ module.exports = class BatchRunner {
24
28
  * @return {boolean} true - executed, false - no paths
25
29
  **/
26
30
  exec({ nModule }) {
27
- if (!nModule.module.paths) {
31
+ if (!nModule?.module?.paths) {
28
32
  return false;
29
33
  }
30
34
  //starting from simpliest forms and moving upwards
@@ -87,12 +87,12 @@ module.exports = class notModuleRegistratorFields {
87
87
  }
88
88
 
89
89
  register({ nModule, fromPath }) {
90
- let fields = notModuleRegistratorFields.openFile(fromPath);
91
- if (fields && objHas(fields, "FIELDS")) {
90
+ let file = notModuleRegistratorFields.openFile(fromPath);
91
+ if (file && objHas(file, "FIELDS")) {
92
92
  //collection
93
93
  this.registerFields({
94
94
  nModule,
95
- lib: fields.FIELDS, //fields dictionary
95
+ lib: file.FIELDS, //fields dictionary
96
96
  fromPath,
97
97
  });
98
98
  } else {
@@ -101,7 +101,7 @@ module.exports = class notModuleRegistratorFields {
101
101
  this.registerField({
102
102
  nModule,
103
103
  name: parts.name, //fields name
104
- field: fields, //field description
104
+ field: file, //field description
105
105
  fromPath,
106
106
  });
107
107
  }
@@ -108,6 +108,7 @@ class notRoute {
108
108
  )
109
109
  );
110
110
  }
111
+ console.log(rule);
111
112
  obsoleteWarning(rule, req.originalUrl);
112
113
  let actionName = this.selectActionName(rule);
113
114
  let mod = this.notApp.getModule(this.moduleName);
@@ -7,13 +7,13 @@ class VersioningExceptionSameOldData extends notError {
7
7
  }
8
8
  module.exports.VersioningExceptionSameOldData = VersioningExceptionSameOldData;
9
9
 
10
- class VersioningExceptionNoPpreviousVersions extends notError {
10
+ class VersioningExceptionNoPreviousVersions extends notError {
11
11
  constructor() {
12
12
  super("not-node:versioning_error_no_previous_versions");
13
13
  }
14
14
  }
15
- module.exports.VersioningExceptionNoPpreviousVersions =
16
- VersioningExceptionNoPpreviousVersions;
15
+ module.exports.VersioningExceptionNoPreviousVersions =
16
+ VersioningExceptionNoPreviousVersions;
17
17
 
18
18
  class IncrementExceptionIDGeneratorRebaseFailed extends notError {
19
19
  constructor() {
@@ -16,7 +16,7 @@ function toObject(obj) {
16
16
  }
17
17
 
18
18
  const {
19
- VersioningExceptioNoPpreviousVersions,
19
+ VersioningExceptionNoPreviousVersions,
20
20
  VersioningExceptionSameOldData,
21
21
  } = require("./exceptions.js");
22
22
 
@@ -78,7 +78,7 @@ class ModelVersioning {
78
78
  toObject(previous)
79
79
  );
80
80
  } else {
81
- throw new VersioningExceptioNoPpreviousVersions();
81
+ throw new VersioningExceptionNoPreviousVersions();
82
82
  }
83
83
  }
84
84
 
@@ -3,6 +3,8 @@ const {
3
3
  HttpExceptionForbidden,
4
4
  } = require("../../src/exceptions/http");
5
5
 
6
+ const notAppIdentity = require("../../src/identity/index");
7
+
6
8
  module.exports = ({ Auth, expect }) => {
7
9
  describe("Routes", () => {
8
10
  describe("getIP", () => {
@@ -31,6 +33,7 @@ module.exports = ({ Auth, expect }) => {
31
33
  socket: {
32
34
  remoteAddress: "127.0.0.1",
33
35
  },
36
+ get() {},
34
37
  };
35
38
  let result = Auth.getIP(req);
36
39
  expect(result).to.deep.equal("127.0.0.1");
@@ -55,15 +58,19 @@ module.exports = ({ Auth, expect }) => {
55
58
  headers: {
56
59
  "x-forwarded-for": "127.0.0.1",
57
60
  },
61
+ get() {},
58
62
  user: {},
59
- session: {},
63
+ session: {
64
+ save() {},
65
+ },
60
66
  };
61
67
  let result = Auth.extractAuthData(req);
62
68
  expect(result).to.deep.equal({
63
69
  root: false,
64
70
  auth: false,
65
- role: undefined,
66
- uid: undefined,
71
+ role: [Auth.DEFAULT_USER_ROLE_FOR_GUEST],
72
+ primaryRole: Auth.DEFAULT_USER_ROLE_FOR_GUEST,
73
+ uid: null,
67
74
  sid: undefined,
68
75
  ip: "127.0.0.1",
69
76
  });
@@ -76,6 +83,7 @@ module.exports = ({ Auth, expect }) => {
76
83
  session: {
77
84
  user: true,
78
85
  },
86
+ get() {},
79
87
  },
80
88
  next = function (val) {
81
89
  return val;
@@ -89,6 +97,7 @@ module.exports = ({ Auth, expect }) => {
89
97
  session: {
90
98
  user: false,
91
99
  },
100
+ get() {},
92
101
  },
93
102
  next = function (val) {
94
103
  return val;
@@ -101,6 +110,7 @@ module.exports = ({ Auth, expect }) => {
101
110
  describe("checkRoot", function () {
102
111
  it("check if admin exists and continues", function () {
103
112
  const req = {
113
+ get() {},
104
114
  session: {
105
115
  user: true,
106
116
  role: [Auth.DEFAULT_USER_ROLE_FOR_ADMIN],
@@ -119,6 +129,7 @@ module.exports = ({ Auth, expect }) => {
119
129
  user: true,
120
130
  role: "manager",
121
131
  },
132
+ get() {},
122
133
  },
123
134
  next = function (val) {
124
135
  return val;
@@ -135,24 +146,33 @@ module.exports = ({ Auth, expect }) => {
135
146
  user: true,
136
147
  role: [Auth.DEFAULT_USER_ROLE_FOR_ADMIN],
137
148
  },
149
+ get() {},
138
150
  },
139
151
  next = function (val) {
140
152
  return val;
141
153
  };
142
- let result = Auth.checkAdmin(req, false, next);
154
+ let result = Auth.checkRoot(req, false, next);
143
155
  expect(result).to.deep.equal();
144
156
  });
145
157
  });
146
158
 
147
159
  describe("checkRoleBuilder", function () {
148
160
  it("Role", function () {
161
+ notAppIdentity.identity = class {
162
+ static of() {
163
+ return class {
164
+ static getRole() {
165
+ return "user";
166
+ }
167
+ static getUserId() {}
168
+ static isUser() {
169
+ return true;
170
+ }
171
+ };
172
+ }
173
+ };
149
174
  const role = "user",
150
- req = {
151
- session: {
152
- user: true,
153
- role: "user",
154
- },
155
- },
175
+ req = {},
156
176
  next = function (val) {
157
177
  return val;
158
178
  };
@@ -162,9 +182,13 @@ module.exports = ({ Auth, expect }) => {
162
182
  });
163
183
 
164
184
  it("Role with error", function () {
185
+ let saved = false;
165
186
  const role = "manager",
166
187
  req = {
167
188
  session: {
189
+ save() {
190
+ saved = true;
191
+ },
168
192
  user: true,
169
193
  role: "user",
170
194
  },
package/test/fakes.js ADDED
@@ -0,0 +1,52 @@
1
+ const { DEFAULT_USER_ROLE_FOR_GUEST } = require("../src/auth");
2
+
3
+ module.exports = {
4
+ createFakeEmit: (val, err) => {
5
+ return async () => {
6
+ if (err) {
7
+ throw err;
8
+ } else {
9
+ return val;
10
+ }
11
+ };
12
+ },
13
+ fakeIdentity: (
14
+ id = {
15
+ root: false,
16
+ auth: false,
17
+ role: [DEFAULT_USER_ROLE_FOR_GUEST],
18
+ primaryRole: DEFAULT_USER_ROLE_FOR_GUEST,
19
+ uid: undefined,
20
+ sid: undefined,
21
+ ip: undefined,
22
+ }
23
+ ) => {
24
+ return class {
25
+ static of() {
26
+ return class {
27
+ static isRoot() {
28
+ return id.root;
29
+ }
30
+ static isUser() {
31
+ return id.auth;
32
+ }
33
+ static getRole() {
34
+ return id.role;
35
+ }
36
+ static getPrimaryRole() {
37
+ return id.primaryRole;
38
+ }
39
+ static getUserId() {
40
+ return id.uid;
41
+ }
42
+ static getSessionId() {
43
+ return id.sid;
44
+ }
45
+ static getIP() {
46
+ return id.ip;
47
+ }
48
+ };
49
+ }
50
+ };
51
+ },
52
+ };
@@ -1,11 +1,11 @@
1
1
  const Provider = require("../../../src/identity/providers/session");
2
-
2
+ const { DEFAULT_USER_ROLE_FOR_GUEST } = require("../../../src/auth/const");
3
3
  const mongoose = require("mongoose");
4
4
 
5
5
  const SESSION_NOT_EXISTS = "session not exists";
6
6
 
7
7
  module.exports = ({ expect }) => {
8
- describe(`${Provider.constructor.name}`, () => {
8
+ describe(`${Provider.name}`, () => {
9
9
  describe("isUser", function () {
10
10
  it("check if user exists - true", function () {
11
11
  var t = {
@@ -40,6 +40,7 @@ module.exports = ({ expect }) => {
40
40
  var t = {
41
41
  session: {
42
42
  user: mongoose.Types.ObjectId(),
43
+ save() {},
43
44
  },
44
45
  };
45
46
  var res = new Provider(t).isRoot();
@@ -53,6 +54,7 @@ module.exports = ({ expect }) => {
53
54
  session: {
54
55
  user: mongoose.Types.ObjectId(),
55
56
  role: "root",
57
+ save() {},
56
58
  },
57
59
  };
58
60
  var res = new Provider(t).getRole();
@@ -62,10 +64,11 @@ module.exports = ({ expect }) => {
62
64
  var t = {
63
65
  session: {
64
66
  user: mongoose.Types.ObjectId(),
67
+ save() {},
65
68
  },
66
69
  };
67
70
  var res = new Provider(t).getRole();
68
- expect(res).to.eql(undefined);
71
+ expect(res).to.eql([DEFAULT_USER_ROLE_FOR_GUEST]);
69
72
  });
70
73
  });
71
74
 
@@ -75,6 +78,7 @@ module.exports = ({ expect }) => {
75
78
  session: {
76
79
  user: mongoose.Types.ObjectId(),
77
80
  role: "user",
81
+ save() {},
78
82
  },
79
83
  };
80
84
  new Provider(t).setRole("root");
@@ -93,6 +97,7 @@ module.exports = ({ expect }) => {
93
97
  const t = {
94
98
  session: {
95
99
  role: "user",
100
+ save() {},
96
101
  },
97
102
  };
98
103
  const id = mongoose.Types.ObjectId();
@@ -114,6 +119,7 @@ module.exports = ({ expect }) => {
114
119
  session: {
115
120
  user: mongoose.Types.ObjectId(),
116
121
  role: "user",
122
+ save() {},
117
123
  },
118
124
  };
119
125
  const id = new Provider(t).getUserId();
@@ -133,6 +139,7 @@ module.exports = ({ expect }) => {
133
139
  session: {
134
140
  id: mongoose.Types.ObjectId(),
135
141
  role: "user",
142
+ save() {},
136
143
  },
137
144
  };
138
145
  const id = new Provider(t).getSessionId();
@@ -149,7 +156,7 @@ module.exports = ({ expect }) => {
149
156
  describe("setAuth", function () {
150
157
  it("session exist", function () {
151
158
  const t = {
152
- session: {},
159
+ session: { save() {} },
153
160
  };
154
161
  const id = mongoose.Types.ObjectId();
155
162
  new Provider(t).setAuth(id, "root");
@@ -169,7 +176,7 @@ module.exports = ({ expect }) => {
169
176
  it("session exist", function () {
170
177
  const id = mongoose.Types.ObjectId();
171
178
  const t = {
172
- session: { user: id, role: "admin" },
179
+ session: { user: id, role: "admin", save() {} },
173
180
  user: { _id: id },
174
181
  };
175
182
  new Provider(t).setGuest();
@@ -193,6 +200,7 @@ module.exports = ({ expect }) => {
193
200
  session: {
194
201
  user: id,
195
202
  role: "admin",
203
+ save() {},
196
204
  destroy() {
197
205
  destroyed = true;
198
206
  },
@@ -210,6 +218,7 @@ module.exports = ({ expect }) => {
210
218
  session: {
211
219
  user: id,
212
220
  role: "admin",
221
+ save() {},
213
222
  },
214
223
  };
215
224
  new Provider(t).cleanse();
@@ -22,7 +22,7 @@ function stubReqWithTokenContent({ tokenContent, secret }) {
22
22
  }
23
23
 
24
24
  module.exports = ({ expect }) => {
25
- describe(`${Provider.constructor.name}`, () => {
25
+ describe(`${Provider.name}`, () => {
26
26
  /* describe("isUser", function () {
27
27
  it("check if user exists - true", function () {
28
28
  var t = {