diff --git a/server/routes/blaiseApi.ts b/server/routes/blaiseApi.ts index 7e17f72..3b55657 100644 --- a/server/routes/blaiseApi.ts +++ b/server/routes/blaiseApi.ts @@ -42,14 +42,14 @@ export default function blaiseApi(config: CustomConfig, auth: Auth, blaiseApiCli const successMessage = `${currentUser.name || "Unknown user"} has successfully updated user role and permissions to ${role} for ${user}`; auditLogger.info(req.log, successMessage); return res.status(200).json({ - message: successMessage + message: "Successfully updated user role and permissions to " + role + " for " + user }); } catch (error) { const errorMessage = `Error whilst trying to update user role and permissions to ${role} for ${req.params.user}, with error message: ${error}`; auditLogger.info(req.log, `${currentUser.name || "Unknown user"} has failed to update user role and permissions to ${role} for ${user}`); auditLogger.error(req.log, errorMessage); return res.status(500).json({ - message: errorMessage + message: "Failed to update user role and permissions to " + role + " for " + user }); } }); diff --git a/server/tests/routes/blaiseApi.test.ts b/server/tests/routes/blaiseApi.test.ts index df0cc4a..97b16af 100644 --- a/server/tests/routes/blaiseApi.test.ts +++ b/server/tests/routes/blaiseApi.test.ts @@ -347,7 +347,7 @@ describe("PATCH /api/users/:user/rolesAndPermissions endpoint", () => { const log = logInfo.mock.calls[0][0]; expect(log).toEqual("AUDIT_LOG: testUser has successfully updated user role and permissions to IPS Manager for testUser"); expect(response.statusCode).toEqual(200); - expect(response.body.message).toContain(`${mockUser.name} has successfully updated user role and permissions to ${role} for ${user}`); + expect(response.body.message).toContain(`Successfully updated user role and permissions to ${role} for ${user}`); blaiseApiMock.verify(api => api.changeUserRole(It.isValue(user), It.isValue(role)), Times.once()); blaiseApiMock.verify(api => api.changeUserServerParks(It.isValue(user), It.isValue(serverParks), It.isValue(defaultServerPark)), Times.once()); }); @@ -380,6 +380,6 @@ describe("PATCH /api/users/:user/rolesAndPermissions endpoint", () => { expect(infoLog).toEqual(`AUDIT_LOG: ${mockUser.name} has failed to update user role and permissions to ${role} for ${user}`); expect(errorLog).toEqual(`AUDIT_LOG: Error whilst trying to update user role and permissions to admin for ${mockUser.name}, with error message: Error: ${errorMessage}`); expect(response.statusCode).toEqual(500); - expect(response.body.message).toContain(errorMessage); + expect(response.body.message).toContain("Failed to update user role and permissions to admin for testUser"); }); }); \ No newline at end of file