diff options
Diffstat (limited to 'web')
-rw-r--r-- | web/web.go | 6 | ||||
-rw-r--r-- | web/web_test.go | 10 |
2 files changed, 14 insertions, 2 deletions
diff --git a/web/web.go b/web/web.go index ff5040a4b..8e96edd69 100644 --- a/web/web.go +++ b/web/web.go @@ -62,5 +62,11 @@ func root(c *api.Context, w http.ResponseWriter, r *http.Request) { if !CheckBrowserCompatability(c, r) { return } + + if api.IsApiCall(r) { + api.Handle404(w, r) + return + } + http.ServeFile(w, r, utils.FindDir(CLIENT_DIR)+"root.html") } diff --git a/web/web_test.go b/web/web_test.go index 8dde5d747..9d7a84c5c 100644 --- a/web/web_test.go +++ b/web/web_test.go @@ -30,6 +30,8 @@ func Setup() { ApiClient = model.NewClient(URL) api.Srv.Store.MarkSystemRanUnitTests() + + *utils.Cfg.TeamSettings.EnableOpenServer = true } } @@ -62,8 +64,9 @@ func TestGetAccessToken(t *testing.T) { team := model.Team{DisplayName: "Name", Name: "z-z-" + model.NewId() + "a", Email: "test@nowhere.com", Type: model.TEAM_OPEN} rteam, _ := ApiClient.CreateTeam(&team) - user := model.User{TeamId: rteam.Data.(*model.Team).Id, Email: strings.ToLower(model.NewId()) + "success+test@simulator.amazonses.com", Password: "pwd"} + user := model.User{Email: strings.ToLower(model.NewId()) + "success+test@simulator.amazonses.com", Password: "pwd"} ruser := ApiClient.Must(ApiClient.CreateUser(&user, "")).Data.(*model.User) + api.JoinUserToTeam(rteam.Data.(*model.Team), ruser) store.Must(api.Srv.Store.User().VerifyEmail(ruser.Id)) app := &model.OAuthApp{Name: "TestApp" + model.NewId(), Homepage: "https://nowhere.com", Description: "test", CallbackUrls: []string{"https://nowhere.com"}} @@ -77,6 +80,7 @@ func TestGetAccessToken(t *testing.T) { } else { ApiClient.Must(ApiClient.LoginById(ruser.Id, "pwd")) + ApiClient.SetTeamId(rteam.Data.(*model.Team).Id) app = ApiClient.Must(ApiClient.RegisterApp(app)).Data.(*model.OAuthApp) redirect := ApiClient.Must(ApiClient.AllowOAuth(model.AUTHCODE_RESPONSE_TYPE, app.Id, app.CallbackUrls[0], "all", "123")).Data.(map[string]string)["redirect"] @@ -191,15 +195,17 @@ func TestIncomingWebhook(t *testing.T) { team := &model.Team{DisplayName: "Name", Name: "z-z-" + model.NewId() + "a", Email: "test@nowhere.com", Type: model.TEAM_OPEN} team = ApiClient.Must(ApiClient.CreateTeam(team)).Data.(*model.Team) - user := &model.User{TeamId: team.Id, Email: model.NewId() + "success+test@simulator.amazonses.com", Nickname: "Corey Hulen", Password: "pwd"} + user := &model.User{Email: model.NewId() + "success+test@simulator.amazonses.com", Nickname: "Corey Hulen", Password: "pwd"} user = ApiClient.Must(ApiClient.CreateUser(user, "")).Data.(*model.User) store.Must(api.Srv.Store.User().VerifyEmail(user.Id)) + api.JoinUserToTeam(team, user) c := &api.Context{} c.RequestId = model.NewId() c.IpAddress = "cmd_line" api.UpdateRoles(c, user, model.ROLE_SYSTEM_ADMIN) ApiClient.LoginByEmail(team.Name, user.Email, "pwd") + ApiClient.SetTeamId(team.Id) channel1 := &model.Channel{DisplayName: "Test API Name", Name: "a" + model.NewId() + "a", Type: model.CHANNEL_OPEN, TeamId: team.Id} channel1 = ApiClient.Must(ApiClient.CreateChannel(channel1)).Data.(*model.Channel) |