From fd6e2f3f73c1fbdda49e4f32d0e40e8d7230518b Mon Sep 17 00:00:00 2001 From: Joram Wilander Date: Tue, 21 Mar 2017 09:06:08 -0400 Subject: Implement GET /audits endpoint for APIv4 (#5779) * Implement GET /audits endpoint for APIv4 * Fix log unit test --- api4/system_test.go | 38 +++++++++++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) (limited to 'api4/system_test.go') diff --git a/api4/system_test.go b/api4/system_test.go index 658bb5881..289a41907 100644 --- a/api4/system_test.go +++ b/api4/system_test.go @@ -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") } -- cgit v1.2.3-1-g7c22