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/auth/session.js
DELETED
|
@@ -1,266 +0,0 @@
|
|
|
1
|
-
const mongoose = require('mongoose');
|
|
2
|
-
|
|
3
|
-
module.exports = ({
|
|
4
|
-
Auth,
|
|
5
|
-
expect
|
|
6
|
-
}) => {
|
|
7
|
-
describe('Session', () => {
|
|
8
|
-
describe('isUser', function() {
|
|
9
|
-
it('check if user exists - true', function() {
|
|
10
|
-
var t = {
|
|
11
|
-
session: {
|
|
12
|
-
user: true
|
|
13
|
-
}
|
|
14
|
-
};
|
|
15
|
-
var res = Auth.isUser(t);
|
|
16
|
-
expect(res).to.eql(true);
|
|
17
|
-
});
|
|
18
|
-
it('check if user exists - false', function() {
|
|
19
|
-
var t = {
|
|
20
|
-
session: {}
|
|
21
|
-
};
|
|
22
|
-
var res = Auth.isUser(t);
|
|
23
|
-
expect(res).to.eql(false);
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
it('obsolete version ifUser', () => {
|
|
27
|
-
var t = {
|
|
28
|
-
session: {}
|
|
29
|
-
};
|
|
30
|
-
var res = Auth.ifUser(t);
|
|
31
|
-
expect(res).to.eql(false);
|
|
32
|
-
});
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
describe('isRoot', function() {
|
|
38
|
-
it('check if user admin - true', function() {
|
|
39
|
-
var t = {
|
|
40
|
-
session: {
|
|
41
|
-
user: mongoose.Types.ObjectId(),
|
|
42
|
-
role: 'root'
|
|
43
|
-
}
|
|
44
|
-
};
|
|
45
|
-
var res = Auth.isRoot(t);
|
|
46
|
-
expect(res).to.eql(true);
|
|
47
|
-
});
|
|
48
|
-
it('check if user admin - false', function() {
|
|
49
|
-
var t = {
|
|
50
|
-
session: {
|
|
51
|
-
user: mongoose.Types.ObjectId()
|
|
52
|
-
}
|
|
53
|
-
};
|
|
54
|
-
var res = Auth.isRoot(t);
|
|
55
|
-
expect(res).to.eql(false);
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
it('obsolete version ifAdmin', function() {
|
|
59
|
-
var t = {
|
|
60
|
-
session: {
|
|
61
|
-
user: mongoose.Types.ObjectId()
|
|
62
|
-
}
|
|
63
|
-
};
|
|
64
|
-
var res = Auth.ifAdmin(t);
|
|
65
|
-
expect(res).to.eql(false);
|
|
66
|
-
});
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
describe('getRole', function() {
|
|
70
|
-
it('get role - root', function() {
|
|
71
|
-
var t = {
|
|
72
|
-
session:{
|
|
73
|
-
user: mongoose.Types.ObjectId(),
|
|
74
|
-
role: 'root'
|
|
75
|
-
}
|
|
76
|
-
};
|
|
77
|
-
var res = Auth.getRole(t);
|
|
78
|
-
expect(res).to.eql('root');
|
|
79
|
-
});
|
|
80
|
-
it('get role - undefined', function() {
|
|
81
|
-
var t = {
|
|
82
|
-
session:{
|
|
83
|
-
user: mongoose.Types.ObjectId()
|
|
84
|
-
}
|
|
85
|
-
};
|
|
86
|
-
var res = Auth.getRole(t);
|
|
87
|
-
expect(res).to.eql(undefined);
|
|
88
|
-
});
|
|
89
|
-
});
|
|
90
|
-
|
|
91
|
-
describe('setRole', function() {
|
|
92
|
-
it('session exist, set role - root', function() {
|
|
93
|
-
var t = {
|
|
94
|
-
session:{
|
|
95
|
-
user: mongoose.Types.ObjectId(),
|
|
96
|
-
role: 'user'
|
|
97
|
-
}
|
|
98
|
-
};
|
|
99
|
-
Auth.setRole(t, 'root');
|
|
100
|
-
expect(t.session.role).to.eql('root');
|
|
101
|
-
});
|
|
102
|
-
|
|
103
|
-
it('session not exist, set role - admin', function() {
|
|
104
|
-
var t = {};
|
|
105
|
-
Auth.setRole(t, 'admin');
|
|
106
|
-
expect(t).to.be.deep.eql({});
|
|
107
|
-
});
|
|
108
|
-
});
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
describe('setUserId', function() {
|
|
112
|
-
it('session exist, set _id', function() {
|
|
113
|
-
const t = {
|
|
114
|
-
session:{
|
|
115
|
-
role: 'user'
|
|
116
|
-
}
|
|
117
|
-
};
|
|
118
|
-
const id = mongoose.Types.ObjectId();
|
|
119
|
-
Auth.setUserId(t, id);
|
|
120
|
-
expect(t.session.user).to.eql(id);
|
|
121
|
-
});
|
|
122
|
-
|
|
123
|
-
it('session not exist, set _id', function() {
|
|
124
|
-
const t = {};
|
|
125
|
-
const id = mongoose.Types.ObjectId();
|
|
126
|
-
Auth.setUserId(t, id);
|
|
127
|
-
expect(t).to.be.deep.eql({});
|
|
128
|
-
});
|
|
129
|
-
|
|
130
|
-
it('obsolete version setId', function() {
|
|
131
|
-
const t = {};
|
|
132
|
-
const id = mongoose.Types.ObjectId();
|
|
133
|
-
Auth.setId(t, id);
|
|
134
|
-
expect(t).to.be.deep.eql({});
|
|
135
|
-
});
|
|
136
|
-
});
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
describe('getUserId', function() {
|
|
140
|
-
it('session exist, user id exist', function() {
|
|
141
|
-
const t = {
|
|
142
|
-
session:{
|
|
143
|
-
user: mongoose.Types.ObjectId(),
|
|
144
|
-
role: 'user'
|
|
145
|
-
}
|
|
146
|
-
};
|
|
147
|
-
const id = Auth.getUserId(t);
|
|
148
|
-
expect(id.toString()).to.eql(t.session.user.toString());
|
|
149
|
-
});
|
|
150
|
-
|
|
151
|
-
it('session not exist', function() {
|
|
152
|
-
const t = {};
|
|
153
|
-
const id = Auth.getUserId(t);
|
|
154
|
-
expect(id).to.be.deep.eql(undefined);
|
|
155
|
-
});
|
|
156
|
-
});
|
|
157
|
-
|
|
158
|
-
describe('getSessionId', function() {
|
|
159
|
-
it('session exist, session id exist', function() {
|
|
160
|
-
const t = {
|
|
161
|
-
session:{
|
|
162
|
-
id: mongoose.Types.ObjectId(),
|
|
163
|
-
role: 'user'
|
|
164
|
-
}
|
|
165
|
-
};
|
|
166
|
-
const id = Auth.getSessionId(t);
|
|
167
|
-
expect(id.toString()).to.eql(t.session.id.toString());
|
|
168
|
-
});
|
|
169
|
-
|
|
170
|
-
it('session not exist', function() {
|
|
171
|
-
const t = {};
|
|
172
|
-
const id = Auth.getSessionId(t);
|
|
173
|
-
expect(id).to.be.deep.eql(undefined);
|
|
174
|
-
});
|
|
175
|
-
});
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
describe('setAuth', function() {
|
|
179
|
-
it('session exist', function() {
|
|
180
|
-
const t = {
|
|
181
|
-
session:{}
|
|
182
|
-
};
|
|
183
|
-
const id = mongoose.Types.ObjectId();
|
|
184
|
-
Auth.setAuth(t, id, 'root');
|
|
185
|
-
expect(t.session.user.toString()).to.eql(id.toString());
|
|
186
|
-
expect(t.session.role).to.eql('root');
|
|
187
|
-
});
|
|
188
|
-
|
|
189
|
-
it('session not exist', function() {
|
|
190
|
-
const t = {};
|
|
191
|
-
const id = mongoose.Types.ObjectId();
|
|
192
|
-
Auth.setAuth(t, id, 'user');
|
|
193
|
-
expect(t).to.be.deep.eql({});
|
|
194
|
-
});
|
|
195
|
-
});
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
describe('setGuest', function() {
|
|
199
|
-
it('session exist', function() {
|
|
200
|
-
const id = mongoose.Types.ObjectId();
|
|
201
|
-
const t = {
|
|
202
|
-
session:{user: id, role: 'admin'},
|
|
203
|
-
user: {_id:id}
|
|
204
|
-
};
|
|
205
|
-
Auth.setGuest(t);
|
|
206
|
-
expect(t.session.user).to.eql(null);
|
|
207
|
-
expect(t.user).to.eql(null);
|
|
208
|
-
expect(t.session.role).to.eql(['guest']);
|
|
209
|
-
});
|
|
210
|
-
|
|
211
|
-
it('session not exist', function() {
|
|
212
|
-
const t = {};
|
|
213
|
-
Auth.setGuest(t);
|
|
214
|
-
expect(t).to.be.deep.eql({});
|
|
215
|
-
});
|
|
216
|
-
});
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
describe('cleanse', function() {
|
|
220
|
-
it('session exist, destroy method exists', function() {
|
|
221
|
-
const id = mongoose.Types.ObjectId();
|
|
222
|
-
let destroyed = false;
|
|
223
|
-
const t = {
|
|
224
|
-
session:{
|
|
225
|
-
user: id,
|
|
226
|
-
role: 'admin',
|
|
227
|
-
destroy(){
|
|
228
|
-
destroyed = true;
|
|
229
|
-
}
|
|
230
|
-
}
|
|
231
|
-
};
|
|
232
|
-
Auth.cleanse(t);
|
|
233
|
-
expect(t.session.user).to.eql(null);
|
|
234
|
-
expect(t.session.role).to.eql(['guest']);
|
|
235
|
-
expect(destroyed).to.eql(true);
|
|
236
|
-
});
|
|
237
|
-
|
|
238
|
-
it('session exist, destroy method exists', function() {
|
|
239
|
-
const id = mongoose.Types.ObjectId();
|
|
240
|
-
const t = {
|
|
241
|
-
session:{
|
|
242
|
-
user: id,
|
|
243
|
-
role: 'admin'
|
|
244
|
-
}
|
|
245
|
-
};
|
|
246
|
-
Auth.cleanse(t);
|
|
247
|
-
expect(t.session.user).to.eql(null);
|
|
248
|
-
expect(t.session.role).to.eql(['guest']);
|
|
249
|
-
});
|
|
250
|
-
|
|
251
|
-
it('session not exist', function() {
|
|
252
|
-
const t = {};
|
|
253
|
-
Auth.cleanse(t);
|
|
254
|
-
expect(t).to.be.deep.eql({});
|
|
255
|
-
});
|
|
256
|
-
});
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
});
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
};
|