diff options
author | Corey Hulen <corey@hulen.com> | 2015-07-21 10:47:46 -0800 |
---|---|---|
committer | Corey Hulen <corey@hulen.com> | 2015-07-21 10:47:46 -0800 |
commit | bee26e3f2654ce7acce647818847480569236343 (patch) | |
tree | ad9032009e18b78c3ffca6e9e48fc4467ddd282b /api/team_test.go | |
parent | dc250d77310e8b38b445bcaa4ae8f2d5df97cc1e (diff) | |
parent | c6fb95912bb481791c1ca370a46a4da9c05d05ad (diff) | |
download | chat-bee26e3f2654ce7acce647818847480569236343.tar.gz chat-bee26e3f2654ce7acce647818847480569236343.tar.bz2 chat-bee26e3f2654ce7acce647818847480569236343.zip |
Merge pull request #200 from mattermost/mm-1356
MM-1356 Changing team URLs from team.domain.com to domain.com/team
Diffstat (limited to 'api/team_test.go')
-rw-r--r-- | api/team_test.go | 70 |
1 files changed, 35 insertions, 35 deletions
diff --git a/api/team_test.go b/api/team_test.go index f61babe8e..2723eff57 100644 --- a/api/team_test.go +++ b/api/team_test.go @@ -32,7 +32,7 @@ func TestCreateFromSignupTeam(t *testing.T) { data := model.MapToJson(props) hash := model.HashPassword(fmt.Sprintf("%v:%v", data, utils.Cfg.ServiceSettings.InviteSalt)) - team := model.Team{Name: "Name", Domain: "z-z-" + model.NewId() + "a", Email: "test@nowhere.com", Type: model.TEAM_OPEN} + team := model.Team{DisplayName: "Name", Name: "z-z-" + model.NewId() + "a", Email: "test@nowhere.com", Type: model.TEAM_OPEN} user := model.User{Email: props["email"], Nickname: "Corey Hulen", Password: "hello"} ts := model.TeamSignup{Team: team, User: user, Invites: []string{"corey@test.com"}, Data: data, Hash: hash} @@ -42,7 +42,7 @@ func TestCreateFromSignupTeam(t *testing.T) { t.Fatal(err) } - if rts.Data.(*model.TeamSignup).Team.Name != team.Name { + if rts.Data.(*model.TeamSignup).Team.DisplayName != team.DisplayName { t.Fatal("full name didn't match") } @@ -71,7 +71,7 @@ func TestCreateFromSignupTeam(t *testing.T) { func TestCreateTeam(t *testing.T) { Setup() - team := model.Team{Name: "Name", Domain: "z-z-" + model.NewId() + "a", Email: "test@nowhere.com", Type: model.TEAM_OPEN} + team := model.Team{DisplayName: "Name", Name: "z-z-" + model.NewId() + "a", Email: "test@nowhere.com", Type: model.TEAM_OPEN} rteam, err := Client.CreateTeam(&team) if err != nil { t.Fatal(err) @@ -81,14 +81,14 @@ func TestCreateTeam(t *testing.T) { user = Client.Must(Client.CreateUser(user, "")).Data.(*model.User) store.Must(Srv.Store.User().VerifyEmail(user.Id)) - Client.LoginByEmail(team.Domain, user.Email, "pwd") + Client.LoginByEmail(team.Name, user.Email, "pwd") c1 := Client.Must(Client.GetChannels("")).Data.(*model.ChannelList) if len(c1.Channels) != 2 { t.Fatal("default channels not created") } - if rteam.Data.(*model.Team).Name != team.Name { + if rteam.Data.(*model.Team).DisplayName != team.DisplayName { t.Fatal("full name didn't match") } @@ -111,7 +111,7 @@ func TestCreateTeam(t *testing.T) { func TestFindTeamByEmail(t *testing.T) { Setup() - team := &model.Team{Name: "Name", Domain: "z-z-" + model.NewId() + "a", Email: "test@nowhere.com", Type: model.TEAM_OPEN} + 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"} @@ -122,7 +122,7 @@ func TestFindTeamByEmail(t *testing.T) { t.Fatal(err) } else { domains := r1.Data.([]string) - if domains[0] != team.Domain { + if domains[0] != team.Name { t.Fatal(domains) } } @@ -139,14 +139,14 @@ XXXXXX investigate and fix failing test func TestFindTeamByDomain(t *testing.T) { Setup() - team := &model.Team{Name: "Name", Domain: "z-z-" + model.NewId() + "a", Email: "test@nowhere.com", Type: model.TEAM_OPEN} + 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)) - if r1, err := Client.FindTeamByDomain(team.Domain, false); err != nil { + if r1, err := Client.FindTeamByDomain(team.Name, false); err != nil { t.Fatal(err) } else { val := r1.Data.(bool) @@ -155,7 +155,7 @@ func TestFindTeamByDomain(t *testing.T) { } } - if r1, err := Client.FindTeamByDomain(team.Domain, true); err != nil { + if r1, err := Client.FindTeamByDomain(team.Name, true); err != nil { t.Fatal(err) } else { val := r1.Data.(bool) @@ -179,7 +179,7 @@ func TestFindTeamByDomain(t *testing.T) { func TestFindTeamByEmailSend(t *testing.T) { Setup() - team := &model.Team{Name: "Name", Domain: "z-z-" + model.NewId() + "a", Email: "test@nowhere.com", Type: model.TEAM_OPEN} + 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"} @@ -203,14 +203,14 @@ func TestFindTeamByEmailSend(t *testing.T) { func TestInviteMembers(t *testing.T) { Setup() - team := &model.Team{Name: "Name", Domain: "z-z-" + model.NewId() + "a", Email: "test@nowhere.com", Type: model.TEAM_OPEN} + 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.Domain, user.Email, "pwd") + Client.LoginByEmail(team.Name, user.Email, "pwd") invite := make(map[string]string) invite["email"] = model.NewId() + "corey@test.com" @@ -229,10 +229,10 @@ func TestInviteMembers(t *testing.T) { } } -func TestUpdateTeamName(t *testing.T) { +func TestUpdateTeamDisplayName(t *testing.T) { Setup() - team := &model.Team{Name: "Name", Domain: "z-z-" + model.NewId() + "a", Email: "test@nowhere.com", Type: model.TEAM_OPEN} + 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: "test@nowhere.com", Nickname: "Corey Hulen", Password: "pwd"} @@ -243,40 +243,40 @@ func TestUpdateTeamName(t *testing.T) { user2 = Client.Must(Client.CreateUser(user2, "")).Data.(*model.User) store.Must(Srv.Store.User().VerifyEmail(user2.Id)) - Client.LoginByEmail(team.Domain, user2.Email, "pwd") + Client.LoginByEmail(team.Name, user2.Email, "pwd") data := make(map[string]string) data["new_name"] = "NewName" - if _, err := Client.UpdateTeamName(data); err == nil { + if _, err := Client.UpdateTeamDisplayName(data); err == nil { t.Fatal("Should have errored, not admin") } - Client.LoginByEmail(team.Domain, user.Email, "pwd") + Client.LoginByEmail(team.Name, user.Email, "pwd") data["new_name"] = "" - if _, err := Client.UpdateTeamName(data); err == nil { + if _, err := Client.UpdateTeamDisplayName(data); err == nil { t.Fatal("Should have errored, empty name") } data["new_name"] = "NewName" - if _, err := Client.UpdateTeamName(data); err != nil { + if _, err := Client.UpdateTeamDisplayName(data); err != nil { t.Fatal(err) } // No GET team web service, so hard to confirm here that team name updated data["team_id"] = "junk" - if _, err := Client.UpdateTeamName(data); err == nil { + if _, err := Client.UpdateTeamDisplayName(data); err == nil { t.Fatal("Should have errored, junk team id") } data["team_id"] = "12345678901234567890123456" - if _, err := Client.UpdateTeamName(data); err == nil { + if _, err := Client.UpdateTeamDisplayName(data); err == nil { t.Fatal("Should have errored, bad team id") } data["team_id"] = team.Id data["new_name"] = "NewNameAgain" - if _, err := Client.UpdateTeamName(data); err != nil { + if _, err := Client.UpdateTeamDisplayName(data); err != nil { t.Fatal(err) } // No GET team web service, so hard to confirm here that team name updated @@ -285,17 +285,17 @@ func TestUpdateTeamName(t *testing.T) { func TestFuzzyTeamCreate(t *testing.T) { for i := 0; i < len(utils.FUZZY_STRINGS_NAMES) || i < len(utils.FUZZY_STRINGS_EMAILS); i++ { - testName := "Name" + testDisplayName := "Name" testEmail := "test@nowhere.com" if i < len(utils.FUZZY_STRINGS_NAMES) { - testName = utils.FUZZY_STRINGS_NAMES[i] + testDisplayName = utils.FUZZY_STRINGS_NAMES[i] } if i < len(utils.FUZZY_STRINGS_EMAILS) { testEmail = utils.FUZZY_STRINGS_EMAILS[i] } - team := model.Team{Name: testName, Domain: "z-z-" + model.NewId() + "a", Email: testEmail, Type: model.TEAM_OPEN} + team := model.Team{DisplayName: testDisplayName, Name: "z-z-" + model.NewId() + "a", Email: testEmail, Type: model.TEAM_OPEN} _, err := Client.CreateTeam(&team) if err != nil { @@ -307,22 +307,22 @@ func TestFuzzyTeamCreate(t *testing.T) { func TestGetMyTeam(t *testing.T) { Setup() - team := model.Team{Name: "Name", Domain: "z-z-" + model.NewId() + "a", Email: "test@nowhere.com", Type: model.TEAM_OPEN} + team := model.Team{DisplayName: "Name", Name: "z-z-" + model.NewId() + "a", Email: "test@nowhere.com", Type: model.TEAM_OPEN} rteam, _ := Client.CreateTeam(&team) user := model.User{TeamId: rteam.Data.(*model.Team).Id, Email: strings.ToLower(model.NewId()) + "corey@test.com", Nickname: "Corey Hulen", Password: "pwd"} ruser, _ := Client.CreateUser(&user, "") store.Must(Srv.Store.User().VerifyEmail(ruser.Data.(*model.User).Id)) - Client.LoginByEmail(team.Domain, user.Email, user.Password) + Client.LoginByEmail(team.Name, user.Email, user.Password) if result, err := Client.GetMyTeam(""); err != nil { t.Fatal("Failed to get user") } else { - if result.Data.(*model.Team).Name != team.Name { + if result.Data.(*model.Team).DisplayName != team.DisplayName { t.Fatal("team names did not match") } - if result.Data.(*model.Team).Domain != team.Domain { + if result.Data.(*model.Team).Name != team.Name { t.Fatal("team domains did not match") } if result.Data.(*model.Team).Type != team.Type { @@ -334,7 +334,7 @@ func TestGetMyTeam(t *testing.T) { func TestUpdateValetFeature(t *testing.T) { Setup() - team := &model.Team{Name: "Name", Domain: "z-z-" + model.NewId() + "a", Email: "test@nowhere.com", Type: model.TEAM_OPEN} + 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: "test@nowhere.com", Nickname: "Corey Hulen", Password: "pwd"} @@ -345,14 +345,14 @@ func TestUpdateValetFeature(t *testing.T) { user2 = Client.Must(Client.CreateUser(user2, "")).Data.(*model.User) store.Must(Srv.Store.User().VerifyEmail(user2.Id)) - team2 := &model.Team{Name: "Name", Domain: "z-z-" + model.NewId() + "a", Email: "test@nowhere.com", Type: model.TEAM_OPEN} + team2 := &model.Team{DisplayName: "Name", Name: "z-z-" + model.NewId() + "a", Email: "test@nowhere.com", Type: model.TEAM_OPEN} team2 = Client.Must(Client.CreateTeam(team2)).Data.(*model.Team) user3 := &model.User{TeamId: team2.Id, Email: model.NewId() + "corey@test.com", Nickname: "Corey Hulen", Password: "pwd"} user3 = Client.Must(Client.CreateUser(user3, "")).Data.(*model.User) store.Must(Srv.Store.User().VerifyEmail(user3.Id)) - Client.LoginByEmail(team.Domain, user2.Email, "pwd") + Client.LoginByEmail(team.Name, user2.Email, "pwd") data := make(map[string]string) data["allow_valet"] = "true" @@ -360,7 +360,7 @@ func TestUpdateValetFeature(t *testing.T) { t.Fatal("Should have errored, not admin") } - Client.LoginByEmail(team.Domain, user.Email, "pwd") + Client.LoginByEmail(team.Name, user.Email, "pwd") data["allow_valet"] = "" if _, err := Client.UpdateValetFeature(data); err == nil { @@ -398,7 +398,7 @@ func TestUpdateValetFeature(t *testing.T) { t.Fatal("Should have errored - allow valet property not updated") } - Client.LoginByEmail(team2.Domain, user3.Email, "pwd") + Client.LoginByEmail(team2.Name, user3.Email, "pwd") data["team_id"] = team.Id data["allow_valet"] = "true" |