summaryrefslogtreecommitdiffstats
path: root/api4/system_test.go
diff options
context:
space:
mode:
authorJoram Wilander <jwawilander@gmail.com>2017-03-21 09:06:08 -0400
committerGitHub <noreply@github.com>2017-03-21 09:06:08 -0400
commitfd6e2f3f73c1fbdda49e4f32d0e40e8d7230518b (patch)
tree708faaa67a39648dcd9deab953d836771f531d8f /api4/system_test.go
parent4968ef0759087f34c1674a385707f6befef810b7 (diff)
downloadchat-fd6e2f3f73c1fbdda49e4f32d0e40e8d7230518b.tar.gz
chat-fd6e2f3f73c1fbdda49e4f32d0e40e8d7230518b.tar.bz2
chat-fd6e2f3f73c1fbdda49e4f32d0e40e8d7230518b.zip
Implement GET /audits endpoint for APIv4 (#5779)
* Implement GET /audits endpoint for APIv4 * Fix log unit test
Diffstat (limited to 'api4/system_test.go')
-rw-r--r--api4/system_test.go38
1 files changed, 37 insertions, 1 deletions
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")
}