diff options
author | Harrison Healey <harrisonmhealey@gmail.com> | 2015-09-18 18:11:01 -0400 |
---|---|---|
committer | Harrison Healey <harrisonmhealey@gmail.com> | 2015-09-18 18:11:01 -0400 |
commit | 679e20aa4b74b468c7e372c77219142599f2385d (patch) | |
tree | 544b2a5f932dc2a2cbd27a800fddcb4ce07b057e /api/admin_test.go | |
parent | 676f2a63999e51a03f2f57209ce4c9f106683da4 (diff) | |
parent | cdf813f07b207c14bb9fa03f38d734b45e40823e (diff) | |
download | chat-679e20aa4b74b468c7e372c77219142599f2385d.tar.gz chat-679e20aa4b74b468c7e372c77219142599f2385d.tar.bz2 chat-679e20aa4b74b468c7e372c77219142599f2385d.zip |
Merge pull request #709 from mattermost/PLT-11
PLT-11 adding config for logs to UI
Diffstat (limited to 'api/admin_test.go')
-rw-r--r-- | api/admin_test.go | 82 |
1 files changed, 81 insertions, 1 deletions
diff --git a/api/admin_test.go b/api/admin_test.go index e67077c55..e1778b5ac 100644 --- a/api/admin_test.go +++ b/api/admin_test.go @@ -8,6 +8,7 @@ import ( "github.com/mattermost/platform/model" "github.com/mattermost/platform/store" + "github.com/mattermost/platform/utils" ) func TestGetLogs(t *testing.T) { @@ -20,6 +21,12 @@ func TestGetLogs(t *testing.T) { user = Client.Must(Client.CreateUser(user, "")).Data.(*model.User) store.Must(Srv.Store.User().VerifyEmail(user.Id)) + Client.LoginByEmail(team.Name, user.Email, "pwd") + + if _, err := Client.GetLogs(); err == nil { + t.Fatal("Shouldn't have permissions") + } + c := &Context{} c.RequestId = model.NewId() c.IpAddress = "cmd_line" @@ -37,8 +44,81 @@ func TestGetLogs(t *testing.T) { func TestGetClientProperties(t *testing.T) { Setup() - if _, err := Client.GetClientProperties(); err != nil { + if result, err := Client.GetClientProperties(); err != nil { + t.Fatal(err) + } else { + props := result.Data.(map[string]string) + + if len(props["Version"]) == 0 { + t.Fatal() + } + } +} + +func TestGetConfig(t *testing.T) { + Setup() + + team := &model.Team{DisplayName: "Name", Name: "z-z-" + model.NewId() + "a", Email: "test@nowhere.com", Type: model.TEAM_OPEN} + team = Client.Must(Client.CreateTeam(team)).Data.(*model.Team) + + user := &model.User{TeamId: team.Id, Email: model.NewId() + "corey@test.com", Nickname: "Corey Hulen", Password: "pwd"} + user = Client.Must(Client.CreateUser(user, "")).Data.(*model.User) + store.Must(Srv.Store.User().VerifyEmail(user.Id)) + + Client.LoginByEmail(team.Name, user.Email, "pwd") + + if _, err := Client.GetConfig(); err == nil { + t.Fatal("Shouldn't have permissions") + } + + c := &Context{} + c.RequestId = model.NewId() + c.IpAddress = "cmd_line" + UpdateRoles(c, user, model.ROLE_SYSTEM_ADMIN) + + Client.LoginByEmail(team.Name, user.Email, "pwd") + + if result, err := Client.GetConfig(); err != nil { + t.Fatal(err) + } else { + cfg := result.Data.(*model.Config) + + if len(cfg.ServiceSettings.SiteName) == 0 { + t.Fatal() + } + } +} + +func TestSaveConfig(t *testing.T) { + Setup() + + team := &model.Team{DisplayName: "Name", Name: "z-z-" + model.NewId() + "a", Email: "test@nowhere.com", Type: model.TEAM_OPEN} + team = Client.Must(Client.CreateTeam(team)).Data.(*model.Team) + user := &model.User{TeamId: team.Id, Email: model.NewId() + "corey@test.com", Nickname: "Corey Hulen", Password: "pwd"} + user = Client.Must(Client.CreateUser(user, "")).Data.(*model.User) + store.Must(Srv.Store.User().VerifyEmail(user.Id)) + + Client.LoginByEmail(team.Name, user.Email, "pwd") + + if _, err := Client.SaveConfig(utils.Cfg); err == nil { + t.Fatal("Shouldn't have permissions") + } + + c := &Context{} + c.RequestId = model.NewId() + c.IpAddress = "cmd_line" + UpdateRoles(c, user, model.ROLE_SYSTEM_ADMIN) + + Client.LoginByEmail(team.Name, user.Email, "pwd") + + if result, err := Client.SaveConfig(utils.Cfg); err != nil { t.Fatal(err) + } else { + cfg := result.Data.(*model.Config) + + if len(cfg.ServiceSettings.SiteName) == 0 { + t.Fatal() + } } } |