Browse Source

add datasource proxy test to verify trailing slashes are forwarded

Marcus Efraimsson 7 năm trước cách đây
mục cha
commit
8bf4d68035
1 tập tin đã thay đổi với 17 bổ sung0 xóa
  1. 17 0
      pkg/api/pluginproxy/ds_proxy_test.go

+ 17 - 0
pkg/api/pluginproxy/ds_proxy_test.go

@@ -374,6 +374,23 @@ func TestDSRouteRule(t *testing.T) {
 			})
 		})
 
+		Convey("When proxying a custom datasource", func() {
+			plugin := &plugins.DataSourcePlugin{}
+			ds := &m.DataSource{
+				Type: "custom-datasource",
+				Url:  "http://host/root/",
+			}
+			ctx := &m.ReqContext{}
+			proxy := NewDataSourceProxy(ds, plugin, ctx, "/path/to/folder/")
+			req, err := http.NewRequest(http.MethodGet, "http://grafana.com/sub", nil)
+			So(err, ShouldBeNil)
+
+			proxy.getDirector()(req)
+
+			Convey("Shoudl keep user request (including trailing slash)", func() {
+				So(req.URL.String(), ShouldEqual, "http://host/root/path/to/folder/")
+			})
+		})
 	})
 }