diff options
author | Joram Wilander <jwawilander@gmail.com> | 2017-03-27 09:19:53 -0400 |
---|---|---|
committer | Christopher Speller <crspeller@gmail.com> | 2017-03-27 09:19:53 -0400 |
commit | a0d5c01dfd97b45478353ccff777de677f088d0f (patch) | |
tree | d4206ef53c44e5ec65fb5b5a01e68d3102e1adf6 /api4/system_test.go | |
parent | d145c3583835766c1f200a413131e7d6bad82229 (diff) | |
download | chat-a0d5c01dfd97b45478353ccff777de677f088d0f.tar.gz chat-a0d5c01dfd97b45478353ccff777de677f088d0f.tar.bz2 chat-a0d5c01dfd97b45478353ccff777de677f088d0f.zip |
Implement client config/license endpoints for APIv4 (#5867)
Diffstat (limited to 'api4/system_test.go')
-rw-r--r-- | api4/system_test.go | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/api4/system_test.go b/api4/system_test.go index 289a41907..b2b5d3f43 100644 --- a/api4/system_test.go +++ b/api4/system_test.go @@ -1,6 +1,7 @@ package api4 import ( + "net/http" "strings" "testing" @@ -129,6 +130,58 @@ func TestUpdateConfig(t *testing.T) { } } +func TestGetOldClientConfig(t *testing.T) { + th := Setup().InitBasic().InitSystemAdmin() + defer TearDown() + Client := th.Client + + config, resp := Client.GetOldClientConfig("") + CheckNoError(t, resp) + + if len(config["Version"]) == 0 { + t.Fatal("config not returned correctly") + } + + Client.Logout() + + _, resp = Client.GetOldClientConfig("") + CheckNoError(t, resp) + + if _, err := Client.DoApiGet("/config/client", ""); err == nil || err.StatusCode != http.StatusNotImplemented { + t.Fatal("should have errored with 501") + } + + if _, err := Client.DoApiGet("/config/client?format=junk", ""); err == nil || err.StatusCode != http.StatusBadRequest { + t.Fatal("should have errored with 400") + } +} + +func TestGetOldClientLicense(t *testing.T) { + th := Setup().InitBasic().InitSystemAdmin() + defer TearDown() + Client := th.Client + + license, resp := Client.GetOldClientLicense("") + CheckNoError(t, resp) + + if len(license["IsLicensed"]) == 0 { + t.Fatal("license not returned correctly") + } + + Client.Logout() + + _, resp = Client.GetOldClientLicense("") + CheckNoError(t, resp) + + if _, err := Client.DoApiGet("/license/client", ""); err == nil || err.StatusCode != http.StatusNotImplemented { + t.Fatal("should have errored with 501") + } + + if _, err := Client.DoApiGet("/license/client?format=junk", ""); err == nil || err.StatusCode != http.StatusBadRequest { + t.Fatal("should have errored with 400") + } +} + func TestGetAudits(t *testing.T) { th := Setup().InitBasic().InitSystemAdmin() defer TearDown() |