From 5a0ce3110ce559fa438a48ec48c3ec0c4daffce1 Mon Sep 17 00:00:00 2001 From: alonadam <96700455+alonadam@users.noreply.github.com> Date: Wed, 25 Dec 2024 12:50:23 +0200 Subject: [PATCH] Auth metadata endpoint is always rooted. (#275) --- azkustodata/cloudinfo.go | 10 +++++----- azkustodata/cloudinfo_test.go | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/azkustodata/cloudinfo.go b/azkustodata/cloudinfo.go index 44492ee4..b58b3b3b 100644 --- a/azkustodata/cloudinfo.go +++ b/azkustodata/cloudinfo.go @@ -9,7 +9,6 @@ import ( "net/http" "net/url" "os" - "strings" "sync" ) @@ -65,10 +64,11 @@ func GetMetadata(kustoUri string, httpClient *http.Client) (CloudInfo, error) { if err != nil { return CloudInfo{}, err } - if !strings.HasPrefix(u.Path, "/") { - u.Path = "/" + u.Path - } - u = u.JoinPath(metadataPath) + + // Auth metadata is always at the root of the cluster + u.Path = metadataPath + u.RawQuery = "" + // TODO should we make this timeout configurable. req, err := http.NewRequest("GET", u.String(), nil) diff --git a/azkustodata/cloudinfo_test.go b/azkustodata/cloudinfo_test.go index 5508f457..c8d5d8d7 100644 --- a/azkustodata/cloudinfo_test.go +++ b/azkustodata/cloudinfo_test.go @@ -25,7 +25,7 @@ func newTestServ() *server { func (s *server) ServeHTTP(w http.ResponseWriter, r *http.Request) { defer log.Println("server exited") w.WriteHeader(s.code) - if s.code == 200 { + if s.code == 200 && r.RequestURI == metadataPath { _, _ = w.Write(s.payload) } } @@ -95,7 +95,7 @@ func TestGetMetadata(t *testing.T) { desc: "Internal server error", payload: "", want: CloudInfo{}, - errwant: fmt.Sprintf("Op(Op(6)): Kind(KHTTPError): error 500 Internal Server Error when querying endpoint %s/test_cloud_info_internal_error%s", s.urlStr(), metadataPath), + errwant: fmt.Sprintf("Op(Op(6)): Kind(KHTTPError): error 500 Internal Server Error when querying endpoint %s%s", s.urlStr(), metadataPath), }, { name: "test_cloud_info_missing_key",