Skip to content

Commit

Permalink
Auth metadata endpoint is always rooted. (#275)
Browse files Browse the repository at this point in the history
  • Loading branch information
alonadam authored Dec 25, 2024
1 parent bc36d62 commit 5a0ce31
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
10 changes: 5 additions & 5 deletions azkustodata/cloudinfo.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
"net/http"
"net/url"
"os"
"strings"
"sync"
)

Expand Down Expand Up @@ -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)

Expand Down
4 changes: 2 additions & 2 deletions azkustodata/cloudinfo_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
Expand Down Expand Up @@ -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",
Expand Down

0 comments on commit 5a0ce31

Please sign in to comment.