summaryrefslogtreecommitdiffstats
path: root/api
diff options
context:
space:
mode:
authorJoram Wilander <jwawilander@gmail.com>2017-09-14 11:48:48 -0400
committerGitHub <noreply@github.com>2017-09-14 11:48:48 -0400
commited1363e1bf0d4a99ab6f990595b60cd891825561 (patch)
treefbdb81e73945ea8611323cbb929a9be0eb731e3f /api
parent23e64ec9aa2fd245a7e3b2faf5973433d8080c03 (diff)
downloadchat-ed1363e1bf0d4a99ab6f990595b60cd891825561.tar.gz
chat-ed1363e1bf0d4a99ab6f990595b60cd891825561.tar.bz2
chat-ed1363e1bf0d4a99ab6f990595b60cd891825561.zip
Fix update SQL query to include refresh token (#7425)
Diffstat (limited to 'api')
-rw-r--r--api/oauth_test.go29
1 files changed, 29 insertions, 0 deletions
diff --git a/api/oauth_test.go b/api/oauth_test.go
index 2e0288061..317478b0a 100644
--- a/api/oauth_test.go
+++ b/api/oauth_test.go
@@ -703,6 +703,35 @@ func TestOAuthAccessToken(t *testing.T) {
if rsp.TokenType != model.ACCESS_TOKEN_TYPE {
t.Fatal("access token type incorrect")
}
+ Client.SetOAuthToken(rsp.AccessToken)
+ _, err = Client.GetMe("")
+ if err != nil {
+ t.Fatal(err)
+ }
+
+ data.Set("refresh_token", rsp.RefreshToken)
+ }
+
+ if result, err := Client.GetAccessToken(data); err != nil {
+ t.Fatal(err)
+ } else {
+ rsp := result.Data.(*model.AccessResponse)
+ if len(rsp.AccessToken) == 0 {
+ t.Fatal("access token not returned")
+ } else if len(rsp.RefreshToken) == 0 {
+ t.Fatal("refresh token not returned")
+ } else if rsp.RefreshToken == refreshToken {
+ t.Fatal("refresh token did not update")
+ }
+
+ if rsp.TokenType != model.ACCESS_TOKEN_TYPE {
+ t.Fatal("access token type incorrect")
+ }
+ Client.SetOAuthToken(rsp.AccessToken)
+ _, err = Client.GetMe("")
+ if err != nil {
+ t.Fatal(err)
+ }
}
authData := &model.AuthData{ClientId: oauthApp.Id, RedirectUri: oauthApp.CallbackUrls[0], UserId: th.BasicUser.Id, Code: model.NewId(), ExpiresIn: -1}