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:
@@ -8,10 +8,10 @@ import (
|
||||
"github.com/stretchr/testify/assert"
|
||||
|
||||
"github.com/grafana/grafana/pkg/infra/log"
|
||||
"github.com/grafana/grafana/pkg/models"
|
||||
"github.com/grafana/grafana/pkg/services/accesscontrol"
|
||||
"github.com/grafana/grafana/pkg/services/accesscontrol/mock"
|
||||
"github.com/grafana/grafana/pkg/services/contexthandler/ctxkey"
|
||||
contextmodel "github.com/grafana/grafana/pkg/services/contexthandler/model"
|
||||
"github.com/grafana/grafana/pkg/services/user"
|
||||
"github.com/grafana/grafana/pkg/web"
|
||||
)
|
||||
@@ -55,7 +55,7 @@ func TestMiddleware(t *testing.T) {
|
||||
for _, test := range tests {
|
||||
t.Run(test.desc, func(t *testing.T) {
|
||||
fallbackCalled := false
|
||||
fallback := func(c *models.ReqContext) {
|
||||
fallback := func(c *contextmodel.ReqContext) {
|
||||
fallbackCalled = true
|
||||
}
|
||||
|
||||
@@ -66,7 +66,7 @@ func TestMiddleware(t *testing.T) {
|
||||
server.Use(accesscontrol.Middleware(test.ac)(fallback, test.evaluator))
|
||||
|
||||
endpointCalled := false
|
||||
server.Get("/", func(c *models.ReqContext) {
|
||||
server.Get("/", func(c *contextmodel.ReqContext) {
|
||||
endpointCalled = true
|
||||
c.Resp.WriteHeader(http.StatusOK)
|
||||
})
|
||||
@@ -99,13 +99,13 @@ func TestMiddleware_forceLogin(t *testing.T) {
|
||||
server := web.New()
|
||||
server.UseMiddleware(web.Renderer("../../public/views", "[[", "]]"))
|
||||
|
||||
server.Get("/endpoint", func(c *models.ReqContext) {
|
||||
server.Get("/endpoint", func(c *contextmodel.ReqContext) {
|
||||
endpointCalled = true
|
||||
c.Resp.WriteHeader(http.StatusOK)
|
||||
})
|
||||
|
||||
ac := mock.New().WithPermissions([]accesscontrol.Permission{{Action: "endpoint:read", Scope: "endpoint:1"}})
|
||||
server.Use(contextProvider(func(c *models.ReqContext) {
|
||||
server.Use(contextProvider(func(c *contextmodel.ReqContext) {
|
||||
c.AllowAnonymous = true
|
||||
c.SignedInUser.IsAnonymous = true
|
||||
c.IsSignedIn = false
|
||||
@@ -129,9 +129,9 @@ func TestMiddleware_forceLogin(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func contextProvider(modifiers ...func(c *models.ReqContext)) web.Handler {
|
||||
func contextProvider(modifiers ...func(c *contextmodel.ReqContext)) web.Handler {
|
||||
return func(c *web.Context) {
|
||||
reqCtx := &models.ReqContext{
|
||||
reqCtx := &contextmodel.ReqContext{
|
||||
Context: c,
|
||||
Logger: log.New(""),
|
||||
SignedInUser: &user.SignedInUser{},
|
||||
|
||||
Reference in New Issue
Block a user