diff --git a/acceptance/acceptance_test.go b/acceptance/acceptance_test.go index f205217ff..7126ccb83 100644 --- a/acceptance/acceptance_test.go +++ b/acceptance/acceptance_test.go @@ -35,7 +35,7 @@ var ( // In order to debug CLI running under acceptance test, set this to full subtest name, e.g. "bundle/variables/empty" // Then install your breakpoints and click "debug test" near TestAccept in VSCODE. // example: var SingleTest = "bundle/variables/empty" -var SingleTest = "" +var SingleTest = "auth/basic" // If enabled, instead of compiling and running CLI externally, we'll start in-process server that accepts and runs // CLI commands. The $CLI in test scripts is a helper that just forwards command-line arguments to this server (see bin/callserver.py). diff --git a/acceptance/auth/basic/out.requests.txt b/acceptance/auth/basic/out.requests.txt index 03ebfd5a2..0d005d5e6 100644 --- a/acceptance/auth/basic/out.requests.txt +++ b/acceptance/auth/basic/out.requests.txt @@ -1 +1 @@ -{"method":"GET","path":"/api/2.0/preview/scim/v2/Me","headers":{"Authorization":"Basic dXNlcm5hbWU6cGFzc3dvcmQ=","User-Agent":"cli/[DEV_VERSION] databricks-sdk-go/[SDK_VERSION] go/[GO_VERSION] os/[OS] cmd/current-user_me cmd-exec-id/[UUID] auth/basic"},"body":""} +{"headers":{"Authorization":"Basic dXNlcm5hbWU6cGFzc3dvcmQ=","User-Agent":"cli/[DEV_VERSION] databricks-sdk-go/[SDK_VERSION] go/[GO_VERSION] os/[OS] cmd/current-user_me cmd-exec-id/[UUID] auth/basic"},"method":"GET","path":"/api/2.0/preview/scim/v2/Me","body":""} diff --git a/acceptance/auth/basic/test.toml b/acceptance/auth/basic/test.toml index 9dae1dca7..89438f43a 100644 --- a/acceptance/auth/basic/test.toml +++ b/acceptance/auth/basic/test.toml @@ -1,4 +1,20 @@ LocalOnly = true RecordRequests = true -IncludeReqHeaders = ["Authorization", "User-Agent"] +IncludeRequestHeaders = ["Authorization", "User-Agent"] + +[[Repls]] +Old = '(linux|darwin|windows)' +New = '[OS]' + +[[Repls]] +Old = " upstream/[A-Za-z0-9.-]+" +New = "" + +[[Repls]] +Old = " upstream-version/[A-Za-z0-9.-]+" +New = "" + +[[Repls]] +Old = " cicd/[A-Za-z0-9.-]+" +New = "" diff --git a/acceptance/auth/oauth/test.toml b/acceptance/auth/oauth/test.toml index 9dae1dca7..89438f43a 100644 --- a/acceptance/auth/oauth/test.toml +++ b/acceptance/auth/oauth/test.toml @@ -1,4 +1,20 @@ LocalOnly = true RecordRequests = true -IncludeReqHeaders = ["Authorization", "User-Agent"] +IncludeRequestHeaders = ["Authorization", "User-Agent"] + +[[Repls]] +Old = '(linux|darwin|windows)' +New = '[OS]' + +[[Repls]] +Old = " upstream/[A-Za-z0-9.-]+" +New = "" + +[[Repls]] +Old = " upstream-version/[A-Za-z0-9.-]+" +New = "" + +[[Repls]] +Old = " cicd/[A-Za-z0-9.-]+" +New = "" diff --git a/acceptance/auth/pat/test.toml b/acceptance/auth/pat/test.toml index 9dae1dca7..89438f43a 100644 --- a/acceptance/auth/pat/test.toml +++ b/acceptance/auth/pat/test.toml @@ -1,4 +1,20 @@ LocalOnly = true RecordRequests = true -IncludeReqHeaders = ["Authorization", "User-Agent"] +IncludeRequestHeaders = ["Authorization", "User-Agent"] + +[[Repls]] +Old = '(linux|darwin|windows)' +New = '[OS]' + +[[Repls]] +Old = " upstream/[A-Za-z0-9.-]+" +New = "" + +[[Repls]] +Old = " upstream-version/[A-Za-z0-9.-]+" +New = "" + +[[Repls]] +Old = " cicd/[A-Za-z0-9.-]+" +New = "" diff --git a/libs/testserver/server.go b/libs/testserver/server.go index 5e3efe1c5..03db53aa3 100644 --- a/libs/testserver/server.go +++ b/libs/testserver/server.go @@ -61,11 +61,21 @@ func (s *Server) Handle(pattern string, handler HandlerFunc) { headers[k] = v[0] } + var reqBody any + if json.Valid(body) { + // If the request body is a valid JSON, typecast it to json.RawMessage. + // This way json.Marshal will ignore the body and serialize it + // as is, which is what we want because the body is already a JSON. + reqBody = json.RawMessage(body) + } else { + reqBody = body + } + s.Requests = append(s.Requests, Request{ Headers: headers, Method: r.Method, Path: r.URL.Path, - Body: json.RawMessage(body), + Body: reqBody, }) }