diff options
author | Jack <jackdeng@gmail.com> | 2015-09-22 08:16:51 -0700 |
---|---|---|
committer | Jack <jackdeng@gmail.com> | 2015-09-22 08:16:51 -0700 |
commit | 602bed85f2b32733f73e2edddb542fa36baac462 (patch) | |
tree | 06a6ee9b609a9122bc2f0e6f6e6300f9ba79a3aa /api/admin_test.go | |
parent | a31868336f97a91bfd5a7e91e99a9b294d131f90 (diff) | |
parent | f439c82d7c885b4c530ba9da0a41b17910743b55 (diff) | |
download | chat-602bed85f2b32733f73e2edddb542fa36baac462.tar.gz chat-602bed85f2b32733f73e2edddb542fa36baac462.tar.bz2 chat-602bed85f2b32733f73e2edddb542fa36baac462.zip |
fix conflict
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() + } } } |