@contrail/flexplm 1.7.4-alpha.b0c1671 → 1.7.4-alpha.b869ea5
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.
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const flexplm_connect_1 = require("./flexplm-connect");
|
|
4
|
-
const app_framework_1 = require("@contrail/app-framework");
|
|
5
4
|
const mockJsonData = { items: [{ id: '123', name: 'test' }] };
|
|
6
5
|
const mockResponse = (status, json = mockJsonData) => ({
|
|
7
6
|
status,
|
|
@@ -88,22 +87,3 @@ describe('FlexPLMConnect.getRequest', () => {
|
|
|
88
87
|
await expect(connect.getRequest()).rejects.toThrow('Error getting json data from FlexPLM: Invalid JSON');
|
|
89
88
|
});
|
|
90
89
|
});
|
|
91
|
-
describe('FlexPLMConnect.sendRequest', () => {
|
|
92
|
-
it('should mask csrf nonce value in logged request options', async () => {
|
|
93
|
-
const loggerIsInfoOnSpy = jest.spyOn(app_framework_1.Logger, 'isInfoOn').mockReturnValue(true);
|
|
94
|
-
const consoleInfoSpy = jest.spyOn(console, 'info').mockImplementation();
|
|
95
|
-
const csrf = { nonce_key: 'CSRF_NONCE', nonce: 'raw-secret-nonce' };
|
|
96
|
-
const payload = { id: '123' };
|
|
97
|
-
const connect = new flexplm_connect_1.FlexPLMConnect(createConfig());
|
|
98
|
-
await connect.sendRequest(csrf, payload);
|
|
99
|
-
const csrfOptionsLogMessages = consoleInfoSpy.mock.calls
|
|
100
|
-
.map(([message]) => String(message ?? ''))
|
|
101
|
-
.filter(message => message.startsWith('csrfOptions: '));
|
|
102
|
-
const sendRequestOptionsLogMessage = csrfOptionsLogMessages.find(message => message.includes('"CSRF_NONCE":'));
|
|
103
|
-
expect(sendRequestOptionsLogMessage).toBeDefined();
|
|
104
|
-
expect(sendRequestOptionsLogMessage ?? '').not.toContain('raw-secret-nonce');
|
|
105
|
-
expect(sendRequestOptionsLogMessage ?? '').toContain('"CSRF_NONCE":"***masked***"');
|
|
106
|
-
loggerIsInfoOnSpy.mockRestore();
|
|
107
|
-
consoleInfoSpy.mockRestore();
|
|
108
|
-
});
|
|
109
|
-
});
|