MCPcopy Index your code
hub / github.com/OverloadBlitz/cloudcent-cli / TestGetCanSkipAuthHeaders

Function TestGetCanSkipAuthHeaders

internal/api/client_test.go:234–263  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

232}
233
234func TestGetCanSkipAuthHeaders(t *testing.T) {
235 client := newTestClient(t, false, func(req *http.Request) (*http.Response, error) {
236 if req.Method != http.MethodGet {
237 t.Fatalf("expected GET request, got %s", req.Method)
238 }
239 if got := req.Header.Get("Authorization"); got != "" {
240 t.Fatalf("expected no auth header, got %q", got)
241 }
242 if got := req.Header.Get("X-Cli-Id"); got != "" {
243 t.Fatalf("expected no cli id header, got %q", got)
244 }
245
246 return response(http.StatusOK, "ok"), nil
247 })
248
249 status, data, err := client.get((&url.URL{
250 Scheme: "https",
251 Host: "example.com",
252 Path: "/health",
253 }).String(), false)
254 if err != nil {
255 t.Fatalf("get returned error: %v", err)
256 }
257 if status != http.StatusOK {
258 t.Fatalf("expected status 200, got %d", status)
259 }
260 if string(data) != "ok" {
261 t.Fatalf("unexpected response body: %s", string(data))
262 }
263}

Callers

nothing calls this directly

Calls 4

newTestClientFunction · 0.85
responseFunction · 0.85
getMethod · 0.80
StringMethod · 0.80

Tested by

no test coverage detected