MCPcopy Index your code
hub / github.com/coder/coder / TestParseUUID_Invalid

Function TestParseUUID_Invalid

coderd/httpmw/httpmw_internal_test.go:37–55  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

35}
36
37func TestParseUUID_Invalid(t *testing.T) {
38 t.Parallel()
39
40 rw := httptest.NewRecorder()
41 r := httptest.NewRequest("GET", "/{workspaceagent}", nil)
42
43 ctx := chi.NewRouteContext()
44 ctx.URLParams.Add(testParam, "wrong-id")
45 r = r.WithContext(context.WithValue(r.Context(), chi.RouteCtxKey, ctx))
46
47 _, ok := ParseUUIDParam(rw, r, "workspaceagent")
48 assert.False(t, ok, "UUID should not be parsed")
49 assert.Equal(t, http.StatusBadRequest, rw.Code)
50
51 var response codersdk.Response
52 err := json.Unmarshal(rw.Body.Bytes(), &response)
53 require.NoError(t, err)
54 assert.Contains(t, response.Message, `Invalid UUID "wrong-id"`)
55}
56
57// TestNormalizeAudienceURI tests URI normalization for OAuth2 audience validation
58func TestNormalizeAudienceURI(t *testing.T) {

Callers

nothing calls this directly

Calls 8

ParseUUIDParamFunction · 0.85
WithContextMethod · 0.80
AddMethod · 0.65
ContextMethod · 0.65
EqualMethod · 0.45
UnmarshalMethod · 0.45
BytesMethod · 0.45
ContainsMethod · 0.45

Tested by

no test coverage detected