summaryrefslogtreecommitdiffstats
path: root/app/oauth_test.go
diff options
context:
space:
mode:
authorJoramWilander <jwawilander@gmail.com>2017-07-12 16:58:51 -0400
committerJoramWilander <jwawilander@gmail.com>2017-07-12 16:58:51 -0400
commit259ad46f30d0fac2f7c5c14f3b76b2170f7e90c7 (patch)
tree627c5a1d3c40f1391edea4be2881e189ba4ef934 /app/oauth_test.go
parent96d7783d36986a8300d173eef44976f2425f1a7d (diff)
downloadchat-259ad46f30d0fac2f7c5c14f3b76b2170f7e90c7.tar.gz
chat-259ad46f30d0fac2f7c5c14f3b76b2170f7e90c7.tar.bz2
chat-259ad46f30d0fac2f7c5c14f3b76b2170f7e90c7.zip
Minor fix
Diffstat (limited to 'app/oauth_test.go')
-rw-r--r--app/oauth_test.go52
1 files changed, 52 insertions, 0 deletions
diff --git a/app/oauth_test.go b/app/oauth_test.go
index 9e8fdfc7d..185f5d73f 100644
--- a/app/oauth_test.go
+++ b/app/oauth_test.go
@@ -7,6 +7,7 @@ import (
"testing"
"github.com/mattermost/platform/model"
+ "github.com/mattermost/platform/utils"
)
func TestOAuthRevokeAccessToken(t *testing.T) {
@@ -42,3 +43,54 @@ func TestOAuthRevokeAccessToken(t *testing.T) {
t.Fatal(err)
}
}
+
+func TestOAuthDeleteApp(t *testing.T) {
+ Setup()
+
+ oldSetting := utils.Cfg.ServiceSettings.EnableOAuthServiceProvider
+ defer func() {
+ utils.Cfg.ServiceSettings.EnableOAuthServiceProvider = oldSetting
+ }()
+ utils.Cfg.ServiceSettings.EnableOAuthServiceProvider = true
+
+ a1 := &model.OAuthApp{}
+ a1.CreatorId = model.NewId()
+ a1.Name = "TestApp" + model.NewId()
+ a1.CallbackUrls = []string{"https://nowhere.com"}
+ a1.Homepage = "https://nowhere.com"
+
+ var err *model.AppError
+ a1, err = CreateOAuthApp(a1)
+ if err != nil {
+ t.Fatal(err)
+ }
+
+ session := &model.Session{}
+ session.CreateAt = model.GetMillis()
+ session.UserId = model.NewId()
+ session.Token = model.NewId()
+ session.Roles = model.ROLE_SYSTEM_USER.Id
+ session.IsOAuth = true
+ session.SetExpireInDays(1)
+
+ session, _ = CreateSession(session)
+
+ accessData := &model.AccessData{}
+ accessData.Token = session.Token
+ accessData.UserId = session.UserId
+ accessData.RedirectUri = "http://example.com"
+ accessData.ClientId = a1.Id
+ accessData.ExpiresAt = session.ExpiresAt
+
+ if result := <-Srv.Store.OAuth().SaveAccessData(accessData); result.Err != nil {
+ t.Fatal(result.Err)
+ }
+
+ if err := DeleteOAuthApp(a1.Id); err != nil {
+ t.Fatal(err)
+ }
+
+ if _, err := GetSession(session.Token); err == nil {
+ t.Fatal("should not get session from cache or db")
+ }
+}