@seidor-cloud-produtos/orbit-backend-lib 0.0.39 → 0.0.41
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/dist/frameworks/express/api-gateway/mapping-model.d.ts +1 -0
- package/dist/frameworks/express/api-gateway/mapping-model.js +5 -0
- package/dist/infra/authorizations/validator/auth-validator.spec.js +25 -0
- package/dist/infra/http/api-gateway/mapping-model.d.ts +3 -1
- package/dist/infra/http/api-gateway/mapping-model.js +1 -0
- package/dist/infra/http/api-gateway/mapping-model.spec.js +3 -0
- package/package.json +1 -1
|
@@ -10,5 +10,6 @@ export declare class ExpressMappingModel extends MappingModel {
|
|
|
10
10
|
protected setQuery(key: string, value: string | string[]): this;
|
|
11
11
|
protected setPathParams(key: string, value: string): this;
|
|
12
12
|
protected deleteParams(): this;
|
|
13
|
+
protected setBody(): this;
|
|
13
14
|
protected next(): void;
|
|
14
15
|
}
|
|
@@ -31,6 +31,11 @@ class ExpressMappingModel extends mapping_model_1.MappingModel {
|
|
|
31
31
|
delete this.getBody()['api-gateway-params'];
|
|
32
32
|
return this;
|
|
33
33
|
}
|
|
34
|
+
setBody() {
|
|
35
|
+
this.controller.request.body =
|
|
36
|
+
this.controller.request.body['body-json'] || this.controller.request.body;
|
|
37
|
+
return this;
|
|
38
|
+
}
|
|
34
39
|
next() {
|
|
35
40
|
return this.controller.next();
|
|
36
41
|
}
|
|
@@ -69,5 +69,30 @@ const mockAuthMatcher = {
|
|
|
69
69
|
);
|
|
70
70
|
},
|
|
71
71
|
);
|
|
72
|
+
(0, vitest_1.it)('should authorize if authorizations is null', async () => {
|
|
73
|
+
mockAuthMatcher.isMatch.mockReturnValue(false);
|
|
74
|
+
await authValidator.setup();
|
|
75
|
+
authValidator['requestData'].authorizations = null;
|
|
76
|
+
const result = await authValidator.validate();
|
|
77
|
+
(0, vitest_1.expect)(result).toBe('Authorized');
|
|
78
|
+
(0, vitest_1.expect)(mockAuthMatcher.isMatch).toHaveBeenCalledWith(
|
|
79
|
+
query,
|
|
80
|
+
['auth1', 'auth2'],
|
|
81
|
+
);
|
|
82
|
+
});
|
|
83
|
+
(0, vitest_1.it)(
|
|
84
|
+
'should authorize if authorizations is undefined',
|
|
85
|
+
async () => {
|
|
86
|
+
mockAuthMatcher.isMatch.mockReturnValue(false);
|
|
87
|
+
await authValidator.setup();
|
|
88
|
+
authValidator['requestData'].authorizations = undefined;
|
|
89
|
+
const result = await authValidator.validate();
|
|
90
|
+
(0, vitest_1.expect)(result).toBe('Authorized');
|
|
91
|
+
(0, vitest_1.expect)(mockAuthMatcher.isMatch).toHaveBeenCalledWith(
|
|
92
|
+
query,
|
|
93
|
+
['auth1', 'auth2'],
|
|
94
|
+
);
|
|
95
|
+
},
|
|
96
|
+
);
|
|
72
97
|
});
|
|
73
98
|
});
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
export interface IMappedBody
|
|
1
|
+
export interface IMappedBody {
|
|
2
|
+
['body-json']: any;
|
|
2
3
|
['api-gateway-params']?: {
|
|
3
4
|
path: Record<string, string>;
|
|
4
5
|
querystring: Record<string, string>;
|
|
@@ -21,6 +22,7 @@ export declare abstract class MappingModel {
|
|
|
21
22
|
key: string,
|
|
22
23
|
value: string | string[],
|
|
23
24
|
): MappingModel;
|
|
25
|
+
protected abstract setBody(): MappingModel;
|
|
24
26
|
protected abstract deleteParams(): MappingModel;
|
|
25
27
|
protected abstract setPathParams(key: string, value: string): MappingModel;
|
|
26
28
|
protected abstract next(): any;
|
|
@@ -2,6 +2,9 @@
|
|
|
2
2
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
3
3
|
const mapping_model_1 = require('./mapping-model');
|
|
4
4
|
class MockMappingModel extends mapping_model_1.MappingModel {
|
|
5
|
+
setBody() {
|
|
6
|
+
return this;
|
|
7
|
+
}
|
|
5
8
|
getBody() {
|
|
6
9
|
throw new Error('Method not implemented.');
|
|
7
10
|
}
|