diff --git a/server/routes/blaiseApi.ts b/server/routes/blaiseApi.ts index 41c0e8c..2b38c37 100644 --- a/server/routes/blaiseApi.ts +++ b/server/routes/blaiseApi.ts @@ -110,10 +110,10 @@ export default function blaiseApi(config: CustomConfig, auth: Auth, blaiseApiCli auditLogger.error(req.log, "No user provided for deletion"); return res.status(400).json(); } - auditLogger.info(req.log, `${currentUser.name || "Unknown"} has successfully deleted user: ${user}`); + auditLogger.info(req.log, `${currentUser.name || "Unknown"} has successfully deleted user, ${user}`); return res.status(204).json(await blaiseApiClient.deleteUser(user)); } catch (error) { - auditLogger.error(req.log, `Error whilst trying to delete user: ${error}`); + auditLogger.error(req.log, `Error whilst trying to delete user, ${req.headers.user}, with error message: ${error}`); return res.status(500).json(error); } }); diff --git a/server/tests/routes/blaiseApi.test.ts b/server/tests/routes/blaiseApi.test.ts index 9f1b3b6..6d3a03c 100644 --- a/server/tests/routes/blaiseApi.test.ts +++ b/server/tests/routes/blaiseApi.test.ts @@ -172,7 +172,7 @@ describe("DELETE /api/users endpoint", () => { .set("user", username); const log = logInfo.mock.calls[0][0]; - expect(log).toEqual(`AUDIT_LOG: ${mockUser.name} has successfully deleted user: ${username}`); + expect(log).toEqual(`AUDIT_LOG: ${mockUser.name} has successfully deleted user, ${username}`); expect(response.statusCode).toEqual(204); blaiseApiMock.verify(a => a.deleteUser(It.isValue(username)), Times.once()); }); @@ -188,7 +188,7 @@ describe("DELETE /api/users endpoint", () => { .set("user", username); const log = logError.mock.calls[0][0]; - expect(log).toEqual(`AUDIT_LOG: Error whilst trying to delete user: ${errorMessage}`); + expect(log).toEqual(`AUDIT_LOG: Error whilst trying to delete user, ${username}, with error message: ${errorMessage}`); expect(response.statusCode).toEqual(500); blaiseApiMock.verify(a => a.deleteUser(It.isValue(username)), Times.once()); expect(response.body).toStrictEqual(errorMessage);