@modular-rest/server 1.18.1 → 1.20.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/.nvmrc +1 -1
- package/dist/application.js +5 -4
- package/dist/class/collection_definition.d.ts +28 -3
- package/dist/class/collection_definition.js +72 -2
- package/dist/class/combinator.js +7 -3
- package/dist/class/directory.d.ts +2 -4
- package/dist/class/directory.js +42 -64
- package/dist/helper/data_insertion.js +93 -26
- package/dist/index.d.ts +12 -1
- package/dist/index.js +13 -1
- package/dist/services/data_provider/model_registry.d.ts +72 -0
- package/dist/services/data_provider/model_registry.js +214 -0
- package/dist/services/data_provider/service.js +73 -14
- package/dist/services/file/service.d.ts +47 -78
- package/dist/services/file/service.js +114 -155
- package/dist/services/functions/service.js +4 -4
- package/dist/services/jwt/router.js +2 -1
- package/dist/services/user_manager/router.js +1 -1
- package/dist/services/user_manager/service.js +48 -17
- package/jest.config.ts +18 -0
- package/package.json +11 -2
- package/src/application.ts +5 -4
- package/src/class/collection_definition.ts +94 -4
- package/src/class/combinator.ts +10 -3
- package/src/class/directory.ts +40 -58
- package/src/helper/data_insertion.ts +101 -27
- package/src/index.ts +13 -1
- package/src/services/data_provider/model_registry.ts +243 -0
- package/src/services/data_provider/service.ts +74 -14
- package/src/services/file/service.ts +136 -178
- package/src/services/functions/service.ts +4 -4
- package/src/services/jwt/router.ts +2 -1
- package/src/services/user_manager/router.ts +1 -1
- package/src/services/user_manager/service.ts +49 -20
- package/tests/helpers/test-app.ts +182 -0
- package/tests/router/data-provider.router.int.test.ts +192 -0
- package/tests/router/file.router.int.test.ts +104 -0
- package/tests/router/functions.router.int.test.ts +91 -0
- package/tests/router/jwt.router.int.test.ts +69 -0
- package/tests/router/user-manager.router.int.test.ts +85 -0
- package/tests/setup/jest.setup.ts +5 -0
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { TestAppContext, createIntegrationTestApp } from '../helpers/test-app';
|
|
2
|
+
import * as userManager from '../../src/services/user_manager/service';
|
|
3
|
+
|
|
4
|
+
describe('user-manager router integration', () => {
|
|
5
|
+
let ctx: TestAppContext;
|
|
6
|
+
|
|
7
|
+
beforeAll(async () => {
|
|
8
|
+
ctx = await createIntegrationTestApp();
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
afterAll(async () => {
|
|
12
|
+
if (ctx) {
|
|
13
|
+
await ctx.cleanup();
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
it('POST /user/login fails with wrong credentials', async () => {
|
|
18
|
+
const res = await ctx.request.post('/user/login').send({
|
|
19
|
+
id: 'admin@email.com',
|
|
20
|
+
idType: 'email',
|
|
21
|
+
password: 'wrong-password',
|
|
22
|
+
});
|
|
23
|
+
expect(res.status).toBe(412);
|
|
24
|
+
expect(res.body.status).toBe('error');
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
it('POST /user/login succeeds with admin credentials', async () => {
|
|
28
|
+
const res = await ctx.request.post('/user/login').send({
|
|
29
|
+
id: 'admin@email.com',
|
|
30
|
+
idType: 'email',
|
|
31
|
+
password: '@dmin',
|
|
32
|
+
});
|
|
33
|
+
expect(res.status).toBe(200);
|
|
34
|
+
expect(res.body.status).toBe('success');
|
|
35
|
+
expect(res.body.token).toBeDefined();
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
it('GET /user/loginAnonymous succeeds', async () => {
|
|
39
|
+
const res = await ctx.request.get('/user/loginAnonymous');
|
|
40
|
+
expect(res.status).toBe(200);
|
|
41
|
+
expect(res.body.status).toBe('success');
|
|
42
|
+
expect(res.body.token).toBeDefined();
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
it('handles registration flow', async () => {
|
|
46
|
+
const email = 'new-user@email.com';
|
|
47
|
+
const password = 'new-password';
|
|
48
|
+
|
|
49
|
+
// 1. Register ID
|
|
50
|
+
const regRes = await ctx.request.post('/user/register_id').send({
|
|
51
|
+
id: email,
|
|
52
|
+
idType: 'email',
|
|
53
|
+
});
|
|
54
|
+
expect(regRes.status).toBe(200);
|
|
55
|
+
expect(regRes.body.status).toBe('success');
|
|
56
|
+
|
|
57
|
+
// 2. Validate Code (default is '123')
|
|
58
|
+
const valRes = await ctx.request.post('/user/validateCode').send({
|
|
59
|
+
id: email,
|
|
60
|
+
code: '123',
|
|
61
|
+
});
|
|
62
|
+
expect(valRes.status).toBe(200);
|
|
63
|
+
expect(valRes.body.status).toBe('success');
|
|
64
|
+
expect(valRes.body.isValid).toBe(true);
|
|
65
|
+
|
|
66
|
+
// 3. Submit Password
|
|
67
|
+
const subRes = await ctx.request.post('/user/submit_password').send({
|
|
68
|
+
id: email,
|
|
69
|
+
password: password,
|
|
70
|
+
code: '123',
|
|
71
|
+
});
|
|
72
|
+
expect(subRes.status).toBe(200);
|
|
73
|
+
expect(subRes.body.status).toBe('success');
|
|
74
|
+
|
|
75
|
+
// 4. Login with new credentials
|
|
76
|
+
const loginRes = await ctx.request.post('/user/login').send({
|
|
77
|
+
id: email,
|
|
78
|
+
idType: 'email',
|
|
79
|
+
password: password,
|
|
80
|
+
});
|
|
81
|
+
expect(loginRes.status).toBe(200);
|
|
82
|
+
expect(loginRes.body.status).toBe('success');
|
|
83
|
+
expect(loginRes.body.token).toBeDefined();
|
|
84
|
+
});
|
|
85
|
+
});
|