Remove unnecessary tests. Fix indentation. Remove conversion of _id field.
MODIFY
src/storage/mongodb/LoggingStorage.ts
src/storage/mongodb/LoggingStorage.ts
@@ -80,7 +80,7 @@ export default class LoggingStorage {
// Insert
if (global.database) {
await global.database.getCollection<Log>(tenantID, 'logs').insertOne(logMDB);
- return logMDB._id.toHexString();
+ return logMDB._id;
}
}

MODIFY
test/api/SecurityTest.ts
test/api/SecurityTest.ts
@@ -170,54 +170,6 @@ describe('Security tests', function() {
const read = await testData.centralService.logsApi.readById(logId);
expect(read.status).to.equal(200);
- checkSensitiveDataIsObfuscated(JSON.parse(read.data.detailedMessages));
- });
- it('Check that everything goes well if detailed message is boolean', async () => { // Will fail
- const logId:string = await Logging.logDebug({
- source: 'test',
- tenantID: testData.credentials.tenantId,
- action: ServerAction.HTTP_REQUEST,
- message: 'Just a test',
- module: 'test',
- method: 'test',
- detailedMessages: true // Is this a valid usecase?
- });
-
- const read = await testData.centralService.logsApi.readById(logId);
- expect(read.status).to.equal(200);
-
- checkSensitiveDataIsObfuscated(JSON.parse(read.data.detailedMessages));
- });
- it('Check that everything goes well if detailed message is number', async () => { // Will fail
- const logId:string = await Logging.logDebug({
- source: 'test',
- tenantID: testData.credentials.tenantId,
- action: ServerAction.HTTP_REQUEST,
- message: 'Just a test',
- module: 'test',
- method: 'test',
- detailedMessages: 123 // Is this a valid usecase?
- });
-
- const read = await testData.centralService.logsApi.readById(logId);
- expect(read.status).to.equal(200);
-
- checkSensitiveDataIsObfuscated(JSON.parse(read.data.detailedMessages));
- });
- it('Check that everything goes well if detailed message is object with sensitive data field number', async () => { // Should fail, but doesn't
- const logId:string = await Logging.logDebug({
- source: 'test',
- tenantID: testData.credentials.tenantId,
- action: ServerAction.HTTP_REQUEST,
- message: 'Just a test',
- module: 'test',
- method: 'test',
- detailedMessages: { password: 123 } // Is this a valid usecase?
- });
-
- const read = await testData.centralService.logsApi.readById(logId);
- expect(read.status).to.equal(200);
-
checkSensitiveDataIsObfuscated(JSON.parse(read.data.detailedMessages));
});
});

Remove unnecessary tests. Fix indentation. Remove conversion of _id field.