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.
- package/.eslintrc.json +32 -38
- package/index.js +6 -0
- package/package.json +12 -11
- package/src/app.js +2 -2
- package/src/auth/index.js +0 -2
- package/src/auth/routes.js +25 -61
- package/src/auth/rules.js +8 -7
- package/src/common.js +19 -0
- package/src/identity/exceptions.js +17 -0
- package/src/identity/identity.js +61 -0
- package/src/identity/index.js +35 -0
- package/src/identity/providers/session.js +137 -0
- package/src/identity/providers/token.js +255 -0
- package/src/manifest/result.filter.js +268 -0
- package/src/manifest/route.js +6 -36
- package/static2.js +24 -0
- package/test/auth/identity.js +0 -0
- package/test/auth/routes.js +1 -1
- package/test/auth.js +427 -229
- package/test/env.js +20 -20
- package/test/fields.js +3 -2
- package/test/identity/identity.js +1 -0
- package/test/identity/index.js +12 -0
- package/test/identity/providers/session.js +227 -0
- package/test/identity/providers/token.js +244 -0
- package/test/identity.js +5 -0
- package/test/init/app.js +359 -365
- package/test/init/bodyparser.js +37 -39
- package/test/init/compression.js +29 -31
- package/test/init/cors.js +38 -39
- package/test/init/db.js +60 -64
- package/test/init/env.js +109 -114
- package/test/init/express.js +50 -47
- package/test/init/fileupload.js +30 -32
- package/test/init/http.js +258 -240
- package/test/init/informer.js +20 -24
- package/test/init/methodoverride.js +29 -31
- package/test/init/middleware.js +56 -58
- package/test/init/modules.js +19 -19
- package/test/init/monitoring.js +22 -22
- package/test/init/routes.js +185 -171
- package/test/init/security.js +77 -103
- package/test/init/sessions/mongoose.js +56 -57
- package/test/init/sessions/redis.js +59 -61
- package/test/init/sessions.js +84 -79
- package/test/init/static.js +108 -113
- package/test/init/template.js +46 -41
- package/test/notInit.js +217 -217
- package/test/notManifest.js +232 -191
- package/test/notRoute.js +1022 -799
- package/test/result.filter.js +422 -0
- package/src/auth/session.js +0 -151
- package/test/auth/session.js +0 -266
package/test/env.js
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
const expect = require(
|
|
2
|
-
|
|
1
|
+
const expect = require("chai").expect,
|
|
2
|
+
Env = require("../src/env");
|
|
3
3
|
|
|
4
|
-
describe(
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
4
|
+
describe("Env", function () {
|
|
5
|
+
describe("getEnv", function () {
|
|
6
|
+
it("key exists", function () {
|
|
7
|
+
const res = Env.getEnv("process");
|
|
8
|
+
expect(res).to.be.equal("development");
|
|
9
|
+
});
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
11
|
+
it("key not exists", function () {
|
|
12
|
+
const res = Env.getEnv("key" + Math.random().toString());
|
|
13
|
+
expect(res).to.be.undefined;
|
|
14
|
+
});
|
|
15
|
+
});
|
|
16
16
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
17
|
+
describe("setEnv", function () {
|
|
18
|
+
it("set", function () {
|
|
19
|
+
const res = Env.setEnv("key", "happy");
|
|
20
|
+
expect(res).to.be.deep.equal(Env);
|
|
21
|
+
expect(res.getEnv("key")).to.be.deep.equal("happy");
|
|
22
|
+
});
|
|
23
|
+
});
|
|
24
24
|
});
|
package/test/fields.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
const InitCore = require("../src/
|
|
1
|
+
const InitCore = require("../src/fields");
|
|
2
2
|
|
|
3
3
|
const expect = require("chai").expect,
|
|
4
4
|
Fields = require("../src/fields");
|
|
5
|
-
|
|
5
|
+
/*
|
|
6
6
|
describe("Fields", function () {
|
|
7
7
|
before(() => {
|
|
8
8
|
Fields.importFromDir(InitCore.paths.fields);
|
|
@@ -295,3 +295,4 @@ describe("Fields", function () {
|
|
|
295
295
|
});
|
|
296
296
|
});
|
|
297
297
|
});
|
|
298
|
+
*/
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = () => {};
|
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
const Provider = require("../../../src/identity/providers/session");
|
|
2
|
+
|
|
3
|
+
const mongoose = require("mongoose");
|
|
4
|
+
|
|
5
|
+
const SESSION_NOT_EXISTS = "session not exists";
|
|
6
|
+
|
|
7
|
+
module.exports = ({ expect }) => {
|
|
8
|
+
describe(`${Provider.constructor.name}`, () => {
|
|
9
|
+
describe("isUser", function () {
|
|
10
|
+
it("check if user exists - true", function () {
|
|
11
|
+
var t = {
|
|
12
|
+
session: {
|
|
13
|
+
user: true,
|
|
14
|
+
},
|
|
15
|
+
};
|
|
16
|
+
var res = new Provider(t).isUser();
|
|
17
|
+
expect(res).to.eql(true);
|
|
18
|
+
});
|
|
19
|
+
it("check if user exists - false", function () {
|
|
20
|
+
var t = {
|
|
21
|
+
session: {},
|
|
22
|
+
};
|
|
23
|
+
var res = new Provider(t).isUser();
|
|
24
|
+
expect(res).to.eql(false);
|
|
25
|
+
});
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
describe("isRoot", function () {
|
|
29
|
+
it("check if user admin - true", function () {
|
|
30
|
+
var t = {
|
|
31
|
+
session: {
|
|
32
|
+
user: mongoose.Types.ObjectId(),
|
|
33
|
+
role: "root",
|
|
34
|
+
},
|
|
35
|
+
};
|
|
36
|
+
var res = new Provider(t).isRoot();
|
|
37
|
+
expect(res).to.eql(true);
|
|
38
|
+
});
|
|
39
|
+
it("check if user admin - false", function () {
|
|
40
|
+
var t = {
|
|
41
|
+
session: {
|
|
42
|
+
user: mongoose.Types.ObjectId(),
|
|
43
|
+
},
|
|
44
|
+
};
|
|
45
|
+
var res = new Provider(t).isRoot();
|
|
46
|
+
expect(res).to.eql(false);
|
|
47
|
+
});
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
describe("getRole", function () {
|
|
51
|
+
it("get role - root", function () {
|
|
52
|
+
var t = {
|
|
53
|
+
session: {
|
|
54
|
+
user: mongoose.Types.ObjectId(),
|
|
55
|
+
role: "root",
|
|
56
|
+
},
|
|
57
|
+
};
|
|
58
|
+
var res = new Provider(t).getRole();
|
|
59
|
+
expect(res).to.eql("root");
|
|
60
|
+
});
|
|
61
|
+
it("get role - undefined", function () {
|
|
62
|
+
var t = {
|
|
63
|
+
session: {
|
|
64
|
+
user: mongoose.Types.ObjectId(),
|
|
65
|
+
},
|
|
66
|
+
};
|
|
67
|
+
var res = new Provider(t).getRole();
|
|
68
|
+
expect(res).to.eql(undefined);
|
|
69
|
+
});
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
describe("setRole", function () {
|
|
73
|
+
it("session exist, set role - root", function () {
|
|
74
|
+
var t = {
|
|
75
|
+
session: {
|
|
76
|
+
user: mongoose.Types.ObjectId(),
|
|
77
|
+
role: "user",
|
|
78
|
+
},
|
|
79
|
+
};
|
|
80
|
+
new Provider(t).setRole("root");
|
|
81
|
+
expect(t.session.role).to.eql("root");
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
it("session not exist, set role - admin", function () {
|
|
85
|
+
var t = {};
|
|
86
|
+
new Provider(t).setRole("admin");
|
|
87
|
+
expect(t).to.be.deep.eql({});
|
|
88
|
+
});
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
describe("setUserId", function () {
|
|
92
|
+
it("session exist, set _id", function () {
|
|
93
|
+
const t = {
|
|
94
|
+
session: {
|
|
95
|
+
role: "user",
|
|
96
|
+
},
|
|
97
|
+
};
|
|
98
|
+
const id = mongoose.Types.ObjectId();
|
|
99
|
+
new Provider(t).setUserId(id);
|
|
100
|
+
expect(t.session.user).to.eql(id);
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
it("session not exist, set _id", function () {
|
|
104
|
+
const t = {};
|
|
105
|
+
const id = mongoose.Types.ObjectId();
|
|
106
|
+
new Provider(t).setUserId(id);
|
|
107
|
+
expect(t).to.be.deep.eql({});
|
|
108
|
+
});
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
describe("getUserId", function () {
|
|
112
|
+
it("session exist, user id exist", function () {
|
|
113
|
+
const t = {
|
|
114
|
+
session: {
|
|
115
|
+
user: mongoose.Types.ObjectId(),
|
|
116
|
+
role: "user",
|
|
117
|
+
},
|
|
118
|
+
};
|
|
119
|
+
const id = new Provider(t).getUserId();
|
|
120
|
+
expect(id.toString()).to.eql(t.session.user.toString());
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
it(SESSION_NOT_EXISTS, function () {
|
|
124
|
+
const t = {};
|
|
125
|
+
const id = new Provider(t).getUserId();
|
|
126
|
+
expect(id).to.be.deep.eql(undefined);
|
|
127
|
+
});
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
describe("getSessionId", function () {
|
|
131
|
+
it("session exist, session id exist", function () {
|
|
132
|
+
const t = {
|
|
133
|
+
session: {
|
|
134
|
+
id: mongoose.Types.ObjectId(),
|
|
135
|
+
role: "user",
|
|
136
|
+
},
|
|
137
|
+
};
|
|
138
|
+
const id = new Provider(t).getSessionId();
|
|
139
|
+
expect(id.toString()).to.eql(t.session.id.toString());
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
it(SESSION_NOT_EXISTS, function () {
|
|
143
|
+
const t = {};
|
|
144
|
+
const id = new Provider(t).getSessionId();
|
|
145
|
+
expect(id).to.be.deep.eql(undefined);
|
|
146
|
+
});
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
describe("setAuth", function () {
|
|
150
|
+
it("session exist", function () {
|
|
151
|
+
const t = {
|
|
152
|
+
session: {},
|
|
153
|
+
};
|
|
154
|
+
const id = mongoose.Types.ObjectId();
|
|
155
|
+
new Provider(t).setAuth(id, "root");
|
|
156
|
+
expect(t.session.user.toString()).to.eql(id.toString());
|
|
157
|
+
expect(t.session.role).to.eql("root");
|
|
158
|
+
});
|
|
159
|
+
|
|
160
|
+
it(SESSION_NOT_EXISTS, function () {
|
|
161
|
+
const t = {};
|
|
162
|
+
const id = mongoose.Types.ObjectId();
|
|
163
|
+
new Provider(t).setAuth(id, "user");
|
|
164
|
+
expect(t).to.be.deep.eql({});
|
|
165
|
+
});
|
|
166
|
+
});
|
|
167
|
+
|
|
168
|
+
describe("setGuest", function () {
|
|
169
|
+
it("session exist", function () {
|
|
170
|
+
const id = mongoose.Types.ObjectId();
|
|
171
|
+
const t = {
|
|
172
|
+
session: { user: id, role: "admin" },
|
|
173
|
+
user: { _id: id },
|
|
174
|
+
};
|
|
175
|
+
new Provider(t).setGuest();
|
|
176
|
+
expect(t.session.user).to.eql(null);
|
|
177
|
+
expect(t.user).to.eql(null);
|
|
178
|
+
expect(t.session.role).to.eql(["guest"]);
|
|
179
|
+
});
|
|
180
|
+
|
|
181
|
+
it(SESSION_NOT_EXISTS, function () {
|
|
182
|
+
const t = {};
|
|
183
|
+
new Provider(t).setGuest();
|
|
184
|
+
expect(t).to.be.deep.eql({});
|
|
185
|
+
});
|
|
186
|
+
});
|
|
187
|
+
|
|
188
|
+
describe("cleanse", function () {
|
|
189
|
+
it("session exist, destroy method exists", function () {
|
|
190
|
+
const id = mongoose.Types.ObjectId();
|
|
191
|
+
let destroyed = false;
|
|
192
|
+
const t = {
|
|
193
|
+
session: {
|
|
194
|
+
user: id,
|
|
195
|
+
role: "admin",
|
|
196
|
+
destroy() {
|
|
197
|
+
destroyed = true;
|
|
198
|
+
},
|
|
199
|
+
},
|
|
200
|
+
};
|
|
201
|
+
new Provider(t).cleanse();
|
|
202
|
+
expect(t.session.user).to.eql(null);
|
|
203
|
+
expect(t.session.role).to.eql(["guest"]);
|
|
204
|
+
expect(destroyed).to.eql(true);
|
|
205
|
+
});
|
|
206
|
+
|
|
207
|
+
it("session exist, destroy method exists", function () {
|
|
208
|
+
const id = mongoose.Types.ObjectId();
|
|
209
|
+
const t = {
|
|
210
|
+
session: {
|
|
211
|
+
user: id,
|
|
212
|
+
role: "admin",
|
|
213
|
+
},
|
|
214
|
+
};
|
|
215
|
+
new Provider(t).cleanse();
|
|
216
|
+
expect(t.session.user).to.eql(null);
|
|
217
|
+
expect(t.session.role).to.eql(["guest"]);
|
|
218
|
+
});
|
|
219
|
+
|
|
220
|
+
it(SESSION_NOT_EXISTS, function () {
|
|
221
|
+
const t = {};
|
|
222
|
+
new Provider(t).cleanse();
|
|
223
|
+
expect(t).to.be.deep.eql({});
|
|
224
|
+
});
|
|
225
|
+
});
|
|
226
|
+
});
|
|
227
|
+
};
|
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
const Provider = require("../../../src/identity/providers/token");
|
|
2
|
+
const mongoose = require("mongoose");
|
|
3
|
+
const JWT = require("jsonwebtoken");
|
|
4
|
+
|
|
5
|
+
function stubReq({ headers }) {
|
|
6
|
+
return {
|
|
7
|
+
get(name) {
|
|
8
|
+
return headers[name];
|
|
9
|
+
},
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
function stubReqWithTokenContent({ tokenContent, secret }) {
|
|
14
|
+
const headers = {
|
|
15
|
+
Authentication: "Bearer " + JWT.toString(tokenContent, secret),
|
|
16
|
+
};
|
|
17
|
+
return {
|
|
18
|
+
get(name) {
|
|
19
|
+
return headers[name];
|
|
20
|
+
},
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
module.exports = ({ expect }) => {
|
|
25
|
+
describe(`${Provider.constructor.name}`, () => {
|
|
26
|
+
/* describe("isUser", function () {
|
|
27
|
+
it("check if user exists - true", function () {
|
|
28
|
+
var t = {
|
|
29
|
+
session: {
|
|
30
|
+
user: true,
|
|
31
|
+
},
|
|
32
|
+
};
|
|
33
|
+
var res = new Provider(t).isUser();
|
|
34
|
+
expect(res).to.eql(true);
|
|
35
|
+
});
|
|
36
|
+
it("check if user exists - false", function () {
|
|
37
|
+
var t = {
|
|
38
|
+
session: {},
|
|
39
|
+
};
|
|
40
|
+
var res = new Provider(t).isUser();
|
|
41
|
+
expect(res).to.eql(false);
|
|
42
|
+
});
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
describe("isRoot", function () {
|
|
46
|
+
it("check if user admin - true", function () {
|
|
47
|
+
var t = {
|
|
48
|
+
session: {
|
|
49
|
+
user: mongoose.Types.ObjectId(),
|
|
50
|
+
role: "root",
|
|
51
|
+
},
|
|
52
|
+
};
|
|
53
|
+
var res = new Provider(t).isRoot();
|
|
54
|
+
expect(res).to.eql(true);
|
|
55
|
+
});
|
|
56
|
+
it("check if user admin - false", function () {
|
|
57
|
+
var t = {
|
|
58
|
+
session: {
|
|
59
|
+
user: mongoose.Types.ObjectId(),
|
|
60
|
+
},
|
|
61
|
+
};
|
|
62
|
+
var res = new Provider(t).isRoot();
|
|
63
|
+
expect(res).to.eql(false);
|
|
64
|
+
});
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
describe("getRole", function () {
|
|
68
|
+
it("get role - root", function () {
|
|
69
|
+
var t = {
|
|
70
|
+
session: {
|
|
71
|
+
user: mongoose.Types.ObjectId(),
|
|
72
|
+
role: "root",
|
|
73
|
+
},
|
|
74
|
+
};
|
|
75
|
+
var res = new Provider(t).getRole();
|
|
76
|
+
expect(res).to.eql("root");
|
|
77
|
+
});
|
|
78
|
+
it("get role - undefined", function () {
|
|
79
|
+
var t = {
|
|
80
|
+
session: {
|
|
81
|
+
user: mongoose.Types.ObjectId(),
|
|
82
|
+
},
|
|
83
|
+
};
|
|
84
|
+
var res = new Provider(t).getRole();
|
|
85
|
+
expect(res).to.eql(undefined);
|
|
86
|
+
});
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
describe("setRole", function () {
|
|
90
|
+
it("session exist, set role - root", function () {
|
|
91
|
+
var t = {
|
|
92
|
+
session: {
|
|
93
|
+
user: mongoose.Types.ObjectId(),
|
|
94
|
+
role: "user",
|
|
95
|
+
},
|
|
96
|
+
};
|
|
97
|
+
new Provider(t).setRole("root");
|
|
98
|
+
expect(t.tokenContent.role).to.eql("root");
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
it("session not exist, set role - admin", function () {
|
|
102
|
+
var t = {};
|
|
103
|
+
new Provider(t).setRole("admin");
|
|
104
|
+
expect(t).to.be.deep.eql({});
|
|
105
|
+
});
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
describe("setUserId", function () {
|
|
109
|
+
it("session exist, set _id", function () {
|
|
110
|
+
const t = {
|
|
111
|
+
session: {
|
|
112
|
+
role: "user",
|
|
113
|
+
},
|
|
114
|
+
};
|
|
115
|
+
const id = mongoose.Types.ObjectId();
|
|
116
|
+
Auth.setUserId(t, id);
|
|
117
|
+
expect(t.session.user).to.eql(id);
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
it("session not exist, set _id", function () {
|
|
121
|
+
const t = {};
|
|
122
|
+
const id = mongoose.Types.ObjectId();
|
|
123
|
+
Auth.setUserId(t, id);
|
|
124
|
+
expect(t).to.be.deep.eql({});
|
|
125
|
+
});
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
describe("getUserId", function () {
|
|
129
|
+
it("session exist, user id exist", function () {
|
|
130
|
+
const t = {
|
|
131
|
+
session: {
|
|
132
|
+
user: mongoose.Types.ObjectId(),
|
|
133
|
+
role: "user",
|
|
134
|
+
},
|
|
135
|
+
};
|
|
136
|
+
const id = Auth.getUserId(t);
|
|
137
|
+
expect(id.toString()).to.eql(t.session.user.toString());
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
it("session not exist", function () {
|
|
141
|
+
const t = {};
|
|
142
|
+
const id = Auth.getUserId(t);
|
|
143
|
+
expect(id).to.be.deep.eql(undefined);
|
|
144
|
+
});
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
describe("getSessionId", function () {
|
|
148
|
+
it("session exist, session id exist", function () {
|
|
149
|
+
const t = {
|
|
150
|
+
session: {
|
|
151
|
+
id: mongoose.Types.ObjectId(),
|
|
152
|
+
role: "user",
|
|
153
|
+
},
|
|
154
|
+
};
|
|
155
|
+
const id = Auth.getSessionId(t);
|
|
156
|
+
expect(id.toString()).to.eql(t.session.id.toString());
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
it("session not exist", function () {
|
|
160
|
+
const t = {};
|
|
161
|
+
const id = Auth.getSessionId(t);
|
|
162
|
+
expect(id).to.be.deep.eql(undefined);
|
|
163
|
+
});
|
|
164
|
+
});
|
|
165
|
+
|
|
166
|
+
describe("setAuth", function () {
|
|
167
|
+
it("session exist", function () {
|
|
168
|
+
const t = {
|
|
169
|
+
session: {},
|
|
170
|
+
};
|
|
171
|
+
const id = mongoose.Types.ObjectId();
|
|
172
|
+
Auth.setAuth(t, id, "root");
|
|
173
|
+
expect(t.session.user.toString()).to.eql(id.toString());
|
|
174
|
+
expect(t.session.role).to.eql("root");
|
|
175
|
+
});
|
|
176
|
+
|
|
177
|
+
it("session not exist", function () {
|
|
178
|
+
const t = {};
|
|
179
|
+
const id = mongoose.Types.ObjectId();
|
|
180
|
+
Auth.setAuth(t, id, "user");
|
|
181
|
+
expect(t).to.be.deep.eql({});
|
|
182
|
+
});
|
|
183
|
+
});
|
|
184
|
+
|
|
185
|
+
describe("setGuest", function () {
|
|
186
|
+
it("session exist", function () {
|
|
187
|
+
const id = mongoose.Types.ObjectId();
|
|
188
|
+
const t = {
|
|
189
|
+
session: { user: id, role: "admin" },
|
|
190
|
+
user: { _id: id },
|
|
191
|
+
};
|
|
192
|
+
Auth.setGuest(t);
|
|
193
|
+
expect(t.session.user).to.eql(null);
|
|
194
|
+
expect(t.user).to.eql(null);
|
|
195
|
+
expect(t.session.role).to.eql(["guest"]);
|
|
196
|
+
});
|
|
197
|
+
|
|
198
|
+
it("session not exist", function () {
|
|
199
|
+
const t = {};
|
|
200
|
+
Auth.setGuest(t);
|
|
201
|
+
expect(t).to.be.deep.eql({});
|
|
202
|
+
});
|
|
203
|
+
});
|
|
204
|
+
|
|
205
|
+
describe("cleanse", function () {
|
|
206
|
+
it("session exist, destroy method exists", function () {
|
|
207
|
+
const id = mongoose.Types.ObjectId();
|
|
208
|
+
let destroyed = false;
|
|
209
|
+
const t = {
|
|
210
|
+
session: {
|
|
211
|
+
user: id,
|
|
212
|
+
role: "admin",
|
|
213
|
+
destroy() {
|
|
214
|
+
destroyed = true;
|
|
215
|
+
},
|
|
216
|
+
},
|
|
217
|
+
};
|
|
218
|
+
Auth.cleanse(t);
|
|
219
|
+
expect(t.session.user).to.eql(null);
|
|
220
|
+
expect(t.session.role).to.eql(["guest"]);
|
|
221
|
+
expect(destroyed).to.eql(true);
|
|
222
|
+
});
|
|
223
|
+
|
|
224
|
+
it("session exist, destroy method exists", function () {
|
|
225
|
+
const id = mongoose.Types.ObjectId();
|
|
226
|
+
const t = {
|
|
227
|
+
session: {
|
|
228
|
+
user: id,
|
|
229
|
+
role: "admin",
|
|
230
|
+
},
|
|
231
|
+
};
|
|
232
|
+
Auth.cleanse(t);
|
|
233
|
+
expect(t.session.user).to.eql(null);
|
|
234
|
+
expect(t.session.role).to.eql(["guest"]);
|
|
235
|
+
});
|
|
236
|
+
|
|
237
|
+
it("session not exist", function () {
|
|
238
|
+
const t = {};
|
|
239
|
+
Auth.cleanse(t);
|
|
240
|
+
expect(t).to.be.deep.eql({});
|
|
241
|
+
});
|
|
242
|
+
});*/
|
|
243
|
+
});
|
|
244
|
+
};
|