DataProxy: Ignore empty URL's in plugin routes (#27653)
This adds a check to see if plugin route URL is empty, and in such case does not modify request schema and host of the request to be proxied. This behavior is now the same as in the plugin proxy.
This commit is contained in:
@@ -67,6 +67,10 @@ func TestDSRouteRule(t *testing.T) {
|
||||
{Name: "x-header", Content: "my secret {{.SecureJsonData.key}}"},
|
||||
},
|
||||
},
|
||||
{
|
||||
Path: "api/restricted",
|
||||
ReqRole: models.ROLE_ADMIN,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
@@ -116,6 +120,17 @@ func TestDSRouteRule(t *testing.T) {
|
||||
})
|
||||
})
|
||||
|
||||
Convey("When matching route path with no url", func() {
|
||||
proxy, err := NewDataSourceProxy(ds, plugin, ctx, "", &setting.Cfg{})
|
||||
So(err, ShouldBeNil)
|
||||
proxy.route = plugin.Routes[4]
|
||||
ApplyRoute(proxy.ctx.Req.Context(), req, proxy.proxyPath, proxy.route, proxy.ds)
|
||||
|
||||
Convey("Should not replace request url", func() {
|
||||
So(req.URL.String(), ShouldEqual, "http://localhost/asd")
|
||||
})
|
||||
})
|
||||
|
||||
Convey("Validating request", func() {
|
||||
Convey("plugin route with valid role", func() {
|
||||
proxy, err := NewDataSourceProxy(ds, plugin, ctx, "api/v4/some/method", &setting.Cfg{})
|
||||
|
||||
Reference in New Issue
Block a user