bug fix getUnsignedReports

This commit is contained in:
al8763be 2024-03-29 13:02:31 +01:00
parent c466a98b15
commit bcb661dc22
2 changed files with 9 additions and 2 deletions

View file

@ -137,6 +137,11 @@ func (gs *GState) GetUnsignedReports(c *fiber.Ctx) error {
log.Info("Failed to get project manager ID")
return c.Status(500).SendString("Failed to get project manager ID")
}
if !isProjectManager {
log.Info("User is not a project manager")
return c.Status(401).SendString("User is not a project manager")
}
log.Info("User is Project Manager: ", isProjectManager)
// Call the database function to get the unsigned weekly reports

View file

@ -505,18 +505,20 @@ def test_remove_project():
def test_get_unsigned_reports():
# Log in as the user
token = login("user2", "123").json()["token"]
token = login("admin", "123").json()["token"]
# Make a request to get all unsigned reports
response = requests.get(
getUnsignedReportsPath + "/" + projectName,
getUnsignedReportsPath + "/" "projecttest",
headers={"Authorization": "Bearer " + token},
)
dprint(response.text)
assert response.status_code == 200, "Get unsigned reports failed"
gprint("test_get_unsigned_reports successful")
if __name__ == "__main__":
test_get_unsigned_reports()
test_remove_project()
test_get_user_projects()
test_create_user()