summaryrefslogtreecommitdiffstats
path: root/app/oauth_test.go
diff options
context:
space:
mode:
authorChris <ccbrown112@gmail.com>2017-09-12 09:19:52 -0500
committerGitHub <noreply@github.com>2017-09-12 09:19:52 -0500
commitb066b6df138e88e75cb40f1ec3e58fbd13e61909 (patch)
tree7ee0e8c935cd3bbafd15d0d07d8900af8b82a4e0 /app/oauth_test.go
parent674a606bd00b276d0a05b3b29a3d5f5e5e7f8206 (diff)
downloadchat-b066b6df138e88e75cb40f1ec3e58fbd13e61909.tar.gz
chat-b066b6df138e88e75cb40f1ec3e58fbd13e61909.tar.bz2
chat-b066b6df138e88e75cb40f1ec3e58fbd13e61909.zip
Remove global app references (#7433)
* remove global app references * test fix * fix api4 test compilation
Diffstat (limited to 'app/oauth_test.go')
-rw-r--r--app/oauth_test.go26
1 files changed, 12 insertions, 14 deletions
diff --git a/app/oauth_test.go b/app/oauth_test.go
index 6a8ea7123..d756c0abe 100644
--- a/app/oauth_test.go
+++ b/app/oauth_test.go
@@ -11,9 +11,8 @@ import (
)
func TestOAuthRevokeAccessToken(t *testing.T) {
- a := Global()
- a.Setup()
- if err := a.RevokeAccessToken(model.NewRandomString(16)); err == nil {
+ th := Setup()
+ if err := th.App.RevokeAccessToken(model.NewRandomString(16)); err == nil {
t.Fatal("Should have failed bad token")
}
@@ -24,8 +23,8 @@ func TestOAuthRevokeAccessToken(t *testing.T) {
session.Roles = model.ROLE_SYSTEM_USER.Id
session.SetExpireInDays(1)
- session, _ = a.CreateSession(session)
- if err := a.RevokeAccessToken(session.Token); err == nil {
+ session, _ = th.App.CreateSession(session)
+ if err := th.App.RevokeAccessToken(session.Token); err == nil {
t.Fatal("Should have failed does not have an access token")
}
@@ -36,18 +35,17 @@ func TestOAuthRevokeAccessToken(t *testing.T) {
accessData.ClientId = model.NewId()
accessData.ExpiresAt = session.ExpiresAt
- if result := <-a.Srv.Store.OAuth().SaveAccessData(accessData); result.Err != nil {
+ if result := <-th.App.Srv.Store.OAuth().SaveAccessData(accessData); result.Err != nil {
t.Fatal(result.Err)
}
- if err := a.RevokeAccessToken(accessData.Token); err != nil {
+ if err := th.App.RevokeAccessToken(accessData.Token); err != nil {
t.Fatal(err)
}
}
func TestOAuthDeleteApp(t *testing.T) {
- a := Global()
- a.Setup()
+ th := Setup()
oldSetting := utils.Cfg.ServiceSettings.EnableOAuthServiceProvider
defer func() {
@@ -62,7 +60,7 @@ func TestOAuthDeleteApp(t *testing.T) {
a1.Homepage = "https://nowhere.com"
var err *model.AppError
- a1, err = a.CreateOAuthApp(a1)
+ a1, err = th.App.CreateOAuthApp(a1)
if err != nil {
t.Fatal(err)
}
@@ -75,7 +73,7 @@ func TestOAuthDeleteApp(t *testing.T) {
session.IsOAuth = true
session.SetExpireInDays(1)
- session, _ = a.CreateSession(session)
+ session, _ = th.App.CreateSession(session)
accessData := &model.AccessData{}
accessData.Token = session.Token
@@ -84,15 +82,15 @@ func TestOAuthDeleteApp(t *testing.T) {
accessData.ClientId = a1.Id
accessData.ExpiresAt = session.ExpiresAt
- if result := <-a.Srv.Store.OAuth().SaveAccessData(accessData); result.Err != nil {
+ if result := <-th.App.Srv.Store.OAuth().SaveAccessData(accessData); result.Err != nil {
t.Fatal(result.Err)
}
- if err := a.DeleteOAuthApp(a1.Id); err != nil {
+ if err := th.App.DeleteOAuthApp(a1.Id); err != nil {
t.Fatal(err)
}
- if _, err := a.GetSession(session.Token); err == nil {
+ if _, err := th.App.GetSession(session.Token); err == nil {
t.Fatal("should not get session from cache or db")
}
}