summaryrefslogtreecommitdiffstats
path: root/api
diff options
context:
space:
mode:
author=Corey Hulen <corey@hulen.com>2016-03-16 18:13:16 -0700
committer=Corey Hulen <corey@hulen.com>2016-03-16 18:13:16 -0700
commitb9d5b4e5dcc1585397f1e1d2e53c5f040ee76220 (patch)
tree85d2c293aa3456182a754fefe6646162b516eb6c /api
parente101b2cf7c172d1c4ff20e0df63917b5b8f923ed (diff)
parentcba59d4eb6ef0f65304bc72339c676ebfd653e2b (diff)
downloadchat-b9d5b4e5dcc1585397f1e1d2e53c5f040ee76220.tar.gz
chat-b9d5b4e5dcc1585397f1e1d2e53c5f040ee76220.tar.bz2
chat-b9d5b4e5dcc1585397f1e1d2e53c5f040ee76220.zip
merging files
Diffstat (limited to 'api')
-rw-r--r--api/command_loadtest_test.go32
-rw-r--r--api/file_test.go6
-rw-r--r--api/user.go14
-rw-r--r--api/user_test.go2
4 files changed, 31 insertions, 23 deletions
diff --git a/api/command_loadtest_test.go b/api/command_loadtest_test.go
index 1debc766a..ef370cf19 100644
--- a/api/command_loadtest_test.go
+++ b/api/command_loadtest_test.go
@@ -201,21 +201,23 @@ func TestLoadTestUrlCommands(t *testing.T) {
t.Fatal("/loadtest url for README.md should've executed")
}
- command = "/loadtest url test-emoticons1.md"
- if r := Client.Must(Client.Command(channel.Id, command, false)).Data.(*model.CommandResponse); r.Text != "Loading data..." {
- t.Fatal("/loadtest url for test-emoticons.md should've executed")
- }
-
- command = "/loadtest url test-emoticons1"
- if r := Client.Must(Client.Command(channel.Id, command, false)).Data.(*model.CommandResponse); r.Text != "Loading data..." {
- t.Fatal("/loadtest url for test-emoticons should've executed")
- }
-
- posts := Client.Must(Client.GetPosts(channel.Id, 0, 5, "")).Data.(*model.PostList)
- // note that this may make more than 3 posts if files are too long to fit in an individual post
- if len(posts.Order) < 3 {
- t.Fatal("/loadtest url made too few posts, perhaps there needs to be a delay before GetPosts in the test?")
- }
+ // Removing these tests since they break compatibilty with previous release branches because the url pulls from github master
+
+ // command = "/loadtest url test-emoticons1.md"
+ // if r := Client.Must(Client.Command(channel.Id, command, false)).Data.(*model.CommandResponse); r.Text != "Loading data..." {
+ // t.Fatal("/loadtest url for test-emoticons.md should've executed")
+ // }
+
+ // command = "/loadtest url test-emoticons1"
+ // if r := Client.Must(Client.Command(channel.Id, command, false)).Data.(*model.CommandResponse); r.Text != "Loading data..." {
+ // t.Fatal("/loadtest url for test-emoticons should've executed")
+ // }
+
+ // posts := Client.Must(Client.GetPosts(channel.Id, 0, 5, "")).Data.(*model.PostList)
+ // // note that this may make more than 3 posts if files are too long to fit in an individual post
+ // if len(posts.Order) < 3 {
+ // t.Fatal("/loadtest url made too few posts, perhaps there needs to be a delay before GetPosts in the test?")
+ // }
time.Sleep(2 * time.Second)
}
diff --git a/api/file_test.go b/api/file_test.go
index c3ece7199..4a3eaebfb 100644
--- a/api/file_test.go
+++ b/api/file_test.go
@@ -43,7 +43,7 @@ func TestUploadFile(t *testing.T) {
t.Fatal(err)
}
- path := utils.FindDir("web/static/images")
+ path := utils.FindDir("tests")
file, err := os.Open(path + "/test.png")
defer file.Close()
@@ -159,7 +159,7 @@ func TestGetFile(t *testing.T) {
t.Fatal(err)
}
- path := utils.FindDir("web/static/images")
+ path := utils.FindDir("tests")
file, err := os.Open(path + "/test.png")
if err != nil {
t.Fatal(err)
@@ -342,7 +342,7 @@ func TestGetPublicLink(t *testing.T) {
t.Fatal(err)
}
- path := utils.FindDir("web/static/images")
+ path := utils.FindDir("tests")
file, err := os.Open(path + "/test.png")
if err != nil {
t.Fatal(err)
diff --git a/api/user.go b/api/user.go
index 0841c38aa..aadf735d0 100644
--- a/api/user.go
+++ b/api/user.go
@@ -249,7 +249,7 @@ func CreateUser(team *model.Team, user *model.User) (*model.User, *model.AppErro
}
}
-func CreateOAuthUser(c *Context, w http.ResponseWriter, r *http.Request, service string, userData io.ReadCloser, team *model.Team) *model.User {
+func CreateOAuthUser(c *Context, w http.ResponseWriter, r *http.Request, service string, userData io.Reader, team *model.Team) *model.User {
var user *model.User
provider := einterfaces.GetOauthProvider(service)
if provider == nil {
@@ -481,7 +481,10 @@ func LoginByUsername(c *Context, w http.ResponseWriter, r *http.Request, usernam
return nil
}
-func LoginByOAuth(c *Context, w http.ResponseWriter, r *http.Request, service string, userData io.ReadCloser, team *model.Team) *model.User {
+func LoginByOAuth(c *Context, w http.ResponseWriter, r *http.Request, service string, userData io.Reader, team *model.Team) *model.User {
+ buf := bytes.Buffer{}
+ buf.ReadFrom(userData)
+
authData := ""
provider := einterfaces.GetOauthProvider(service)
if provider == nil {
@@ -489,7 +492,7 @@ func LoginByOAuth(c *Context, w http.ResponseWriter, r *http.Request, service st
map[string]interface{}{"Service": service}, "")
return nil
} else {
- authData = provider.GetAuthDataFromJson(userData)
+ authData = provider.GetAuthDataFromJson(bytes.NewReader(buf.Bytes()))
}
if len(authData) == 0 {
@@ -500,6 +503,9 @@ func LoginByOAuth(c *Context, w http.ResponseWriter, r *http.Request, service st
var user *model.User
if result := <-Srv.Store.User().GetByAuth(team.Id, authData, service); result.Err != nil {
+ if result.Err.Id == store.MISSING_AUTH_ACCOUNT_ERROR && team.AllowOpenInvite {
+ return CreateOAuthUser(c, w, r, service, bytes.NewReader(buf.Bytes()), team)
+ }
c.Err = result.Err
return nil
} else {
@@ -1049,7 +1055,7 @@ func createProfileImage(username string, userId string) ([]byte, *model.AppError
initial := string(strings.ToUpper(username)[0])
- fontBytes, err := ioutil.ReadFile(utils.FindDir("web/static/fonts") + utils.Cfg.FileSettings.InitialFont)
+ fontBytes, err := ioutil.ReadFile(utils.FindDir("fonts") + utils.Cfg.FileSettings.InitialFont)
if err != nil {
return nil, model.NewLocAppError("createProfileImage", "api.user.create_profile_image.default_font.app_error", nil, err.Error())
}
diff --git a/api/user_test.go b/api/user_test.go
index 27f00829f..a175adb1b 100644
--- a/api/user_test.go
+++ b/api/user_test.go
@@ -470,7 +470,7 @@ func TestUserUploadProfileImage(t *testing.T) {
t.Fatal(err)
}
- path := utils.FindDir("web/static/images")
+ path := utils.FindDir("tests")
file, err := os.Open(path + "/test.png")
if err != nil {
t.Fatal(err)