Implement GET /audits endpoint for APIv4 (#5779)

* Implement GET /audits endpoint for APIv4

* Fix log unit test
This commit is contained in:
Joram Wilander
2017-03-21 09:06:08 -04:00
committed by GitHub
parent 4968ef0759
commit fd6e2f3f73
6 changed files with 78 additions and 12 deletions

View File

@@ -127,7 +127,43 @@ func TestUpdateConfig(t *testing.T) {
t.Fatal()
}
}
}
func TestGetAudits(t *testing.T) {
th := Setup().InitBasic().InitSystemAdmin()
defer TearDown()
Client := th.Client
audits, resp := th.SystemAdminClient.GetAudits(0, 100, "")
CheckNoError(t, resp)
if len(audits) == 0 {
t.Fatal("should not be empty")
}
audits, resp = th.SystemAdminClient.GetAudits(0, 1, "")
CheckNoError(t, resp)
if len(audits) != 1 {
t.Fatal("should only be 1")
}
audits, resp = th.SystemAdminClient.GetAudits(1, 1, "")
CheckNoError(t, resp)
if len(audits) != 1 {
t.Fatal("should only be 1")
}
_, resp = th.SystemAdminClient.GetAudits(-1, -1, "")
CheckNoError(t, resp)
_, resp = Client.GetAudits(0, 100, "")
CheckForbiddenStatus(t, resp)
Client.Logout()
_, resp = Client.GetAudits(0, 100, "")
CheckUnauthorizedStatus(t, resp)
}
func TestEmailTest(t *testing.T) {
@@ -217,7 +253,7 @@ func TestGetLogs(t *testing.T) {
logs, resp = th.SystemAdminClient.GetLogs(-1, -1)
CheckNoError(t, resp)
if len(logs) != 0 {
if len(logs) == 0 {
t.Fatal("should not be empty")
}