mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Chore: Move ReqContext to contexthandler service (#62102)
* Chore: Move ReqContext to contexthandler service * Rename package to contextmodel * Generate ngalert files * Remove unused imports
This commit is contained in:
@@ -21,6 +21,7 @@ import (
|
||||
"github.com/grafana/grafana/pkg/login/social"
|
||||
"github.com/grafana/grafana/pkg/models"
|
||||
"github.com/grafana/grafana/pkg/services/auth/authtest"
|
||||
contextmodel "github.com/grafana/grafana/pkg/services/contexthandler/model"
|
||||
"github.com/grafana/grafana/pkg/services/featuremgmt"
|
||||
"github.com/grafana/grafana/pkg/services/hooks"
|
||||
"github.com/grafana/grafana/pkg/services/licensing"
|
||||
@@ -40,7 +41,7 @@ func fakeSetIndexViewData(t *testing.T) {
|
||||
t.Cleanup(func() {
|
||||
setIndexViewData = origSetIndexViewData
|
||||
})
|
||||
setIndexViewData = func(*HTTPServer, *models.ReqContext) (*dtos.IndexViewData, error) {
|
||||
setIndexViewData = func(*HTTPServer, *contextmodel.ReqContext) (*dtos.IndexViewData, error) {
|
||||
data := &dtos.IndexViewData{
|
||||
User: &dtos.CurrentUser{},
|
||||
Settings: map[string]interface{}{},
|
||||
@@ -104,7 +105,7 @@ func TestLoginErrorCookieAPIEndpoint(t *testing.T) {
|
||||
SecretsService: secretsService,
|
||||
}
|
||||
|
||||
sc.defaultHandler = routing.Wrap(func(c *models.ReqContext) response.Response {
|
||||
sc.defaultHandler = routing.Wrap(func(c *contextmodel.ReqContext) response.Response {
|
||||
hs.LoginView(c)
|
||||
return response.Empty(http.StatusOK)
|
||||
})
|
||||
@@ -152,7 +153,7 @@ func TestLoginViewRedirect(t *testing.T) {
|
||||
}
|
||||
hs.Cfg.CookieSecure = true
|
||||
|
||||
sc.defaultHandler = routing.Wrap(func(c *models.ReqContext) response.Response {
|
||||
sc.defaultHandler = routing.Wrap(func(c *contextmodel.ReqContext) response.Response {
|
||||
c.IsSignedIn = true
|
||||
c.SignedInUser = &user.SignedInUser{
|
||||
UserID: 10,
|
||||
@@ -328,7 +329,7 @@ func TestLoginPostRedirect(t *testing.T) {
|
||||
}
|
||||
hs.Cfg.CookieSecure = true
|
||||
|
||||
sc.defaultHandler = routing.Wrap(func(c *models.ReqContext) response.Response {
|
||||
sc.defaultHandler = routing.Wrap(func(c *contextmodel.ReqContext) response.Response {
|
||||
c.Req.Header.Set("Content-Type", "application/json")
|
||||
c.Req.Body = io.NopCloser(bytes.NewBufferString(`{"user":"admin","password":"admin"}`))
|
||||
return hs.LoginPost(c)
|
||||
@@ -492,7 +493,7 @@ func TestLoginOAuthRedirect(t *testing.T) {
|
||||
SocialService: mock,
|
||||
}
|
||||
|
||||
sc.defaultHandler = routing.Wrap(func(c *models.ReqContext) response.Response {
|
||||
sc.defaultHandler = routing.Wrap(func(c *contextmodel.ReqContext) response.Response {
|
||||
hs.LoginView(c)
|
||||
return response.Empty(http.StatusOK)
|
||||
})
|
||||
@@ -518,7 +519,7 @@ func TestLoginInternal(t *testing.T) {
|
||||
log: log.New("test"),
|
||||
}
|
||||
|
||||
sc.defaultHandler = routing.Wrap(func(c *models.ReqContext) response.Response {
|
||||
sc.defaultHandler = routing.Wrap(func(c *contextmodel.ReqContext) response.Response {
|
||||
c.Req.URL.RawQuery = "disableAutoLogin=true"
|
||||
hs.LoginView(c)
|
||||
return response.Empty(http.StatusOK)
|
||||
@@ -570,7 +571,7 @@ func setupAuthProxyLoginTest(t *testing.T, enableLoginToken bool) *scenarioConte
|
||||
SocialService: &mockSocialService{},
|
||||
}
|
||||
|
||||
sc.defaultHandler = routing.Wrap(func(c *models.ReqContext) response.Response {
|
||||
sc.defaultHandler = routing.Wrap(func(c *contextmodel.ReqContext) response.Response {
|
||||
c.IsSignedIn = true
|
||||
c.SignedInUser = &user.SignedInUser{
|
||||
UserID: 10,
|
||||
@@ -592,7 +593,7 @@ type loginHookTest struct {
|
||||
info *models.LoginInfo
|
||||
}
|
||||
|
||||
func (r *loginHookTest) LoginHook(loginInfo *models.LoginInfo, req *models.ReqContext) {
|
||||
func (r *loginHookTest) LoginHook(loginInfo *models.LoginInfo, req *contextmodel.ReqContext) {
|
||||
r.info = loginInfo
|
||||
}
|
||||
|
||||
@@ -608,7 +609,7 @@ func TestLoginPostRunLokingHook(t *testing.T) {
|
||||
HooksService: hookService,
|
||||
}
|
||||
|
||||
sc.defaultHandler = routing.Wrap(func(c *models.ReqContext) response.Response {
|
||||
sc.defaultHandler = routing.Wrap(func(c *contextmodel.ReqContext) response.Response {
|
||||
c.Req.Header.Set("Content-Type", "application/json")
|
||||
c.Req.Body = io.NopCloser(bytes.NewBufferString(`{"user":"admin","password":"admin"}`))
|
||||
x := hs.LoginPost(c)
|
||||
|
||||
Reference in New Issue
Block a user