Remove more global refs / state (#7723)

* remove more global refs / state

* fix job enterprise initialization

* fix api4 test compilation

* saml api endpoints fix
Этот коммит содержится в:
Chris
2017-10-26 14:21:22 -05:00
коммит произвёл Joram Wilander
родитель a0bfd2885d
Коммит 7ed011745a
23 изменённых файлов: 129 добавлений и 150 удалений

Просмотреть файл

@@ -8,7 +8,6 @@ import (
"net/http"
l4g "github.com/alecthomas/log4go"
"github.com/mattermost/mattermost-server/app"
"github.com/mattermost/mattermost-server/model"
"github.com/mattermost/mattermost-server/utils"
)
@@ -73,7 +72,7 @@ func addSamlPublicCertificate(c *Context, w http.ResponseWriter, r *http.Request
return
}
if err := app.AddSamlPublicCertificate(fileData); err != nil {
if err := c.App.AddSamlPublicCertificate(fileData); err != nil {
c.Err = err
return
}
@@ -92,7 +91,7 @@ func addSamlPrivateCertificate(c *Context, w http.ResponseWriter, r *http.Reques
return
}
if err := app.AddSamlPrivateCertificate(fileData); err != nil {
if err := c.App.AddSamlPrivateCertificate(fileData); err != nil {
c.Err = err
return
}
@@ -111,7 +110,7 @@ func addSamlIdpCertificate(c *Context, w http.ResponseWriter, r *http.Request) {
return
}
if err := app.AddSamlIdpCertificate(fileData); err != nil {
if err := c.App.AddSamlIdpCertificate(fileData); err != nil {
c.Err = err
return
}
@@ -124,7 +123,7 @@ func removeSamlPublicCertificate(c *Context, w http.ResponseWriter, r *http.Requ
return
}
if err := app.RemoveSamlPublicCertificate(); err != nil {
if err := c.App.RemoveSamlPublicCertificate(); err != nil {
c.Err = err
return
}
@@ -138,7 +137,7 @@ func removeSamlPrivateCertificate(c *Context, w http.ResponseWriter, r *http.Req
return
}
if err := app.RemoveSamlPrivateCertificate(); err != nil {
if err := c.App.RemoveSamlPrivateCertificate(); err != nil {
c.Err = err
return
}
@@ -152,7 +151,7 @@ func removeSamlIdpCertificate(c *Context, w http.ResponseWriter, r *http.Request
return
}
if err := app.RemoveSamlIdpCertificate(); err != nil {
if err := c.App.RemoveSamlIdpCertificate(); err != nil {
c.Err = err
return
}
@@ -166,6 +165,6 @@ func getSamlCertificateStatus(c *Context, w http.ResponseWriter, r *http.Request
return
}
status := app.GetSamlCertificateStatus()
status := c.App.GetSamlCertificateStatus()
w.Write([]byte(status.ToJson()))
}

Просмотреть файл

@@ -10,7 +10,6 @@ import (
"testing"
"time"
"github.com/mattermost/mattermost-server/app"
"github.com/mattermost/mattermost-server/model"
"github.com/mattermost/mattermost-server/utils"
"github.com/stretchr/testify/assert"
@@ -961,7 +960,7 @@ func TestUpdateUser(t *testing.T) {
session, _ := th.App.GetSession(Client.AuthToken)
session.IsOAuth = true
app.AddSessionToCache(session)
th.App.AddSessionToCache(session)
ruser.Id = user.Id
ruser.Email = GenerateTestEmail()
@@ -1045,7 +1044,7 @@ func TestPatchUser(t *testing.T) {
session, _ := th.App.GetSession(Client.AuthToken)
session.IsOAuth = true
app.AddSessionToCache(session)
th.App.AddSessionToCache(session)
patch.Email = model.NewString(GenerateTestEmail())
_, resp = Client.PatchUser(user.Id, patch)
@@ -1513,7 +1512,7 @@ func TestUpdateUserMfa(t *testing.T) {
session, _ := th.App.GetSession(Client.AuthToken)
session.IsOAuth = true
app.AddSessionToCache(session)
th.App.AddSessionToCache(session)
_, resp := Client.UpdateUserMfa(th.BasicUser.Id, "12345", false)
CheckForbiddenStatus(t, resp)
@@ -1609,7 +1608,7 @@ func TestGenerateMfaSecret(t *testing.T) {
session, _ := th.App.GetSession(Client.AuthToken)
session.IsOAuth = true
app.AddSessionToCache(session)
th.App.AddSessionToCache(session)
_, resp = Client.GenerateMfaSecret(th.BasicUser.Id)
CheckForbiddenStatus(t, resp)
@@ -2257,7 +2256,7 @@ func TestCreateUserAccessToken(t *testing.T) {
session, _ := th.App.GetSession(Client.AuthToken)
session.IsOAuth = true
app.AddSessionToCache(session)
th.App.AddSessionToCache(session)
_, resp = Client.CreateUserAccessToken(th.BasicUser.Id, testDescription)
CheckForbiddenStatus(t, resp)