MCPcopy
hub / github.com/harness/harness / TestWriteUnauthorized

Function TestWriteUnauthorized

app/api/render/render_test.go:87–104  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

85}
86
87func TestWriteUnauthorized(t *testing.T) {
88 ctx := context.TODO()
89 w := httptest.NewRecorder()
90
91 Unauthorized(ctx, w)
92
93 if got, want := w.Code, 401; want != got {
94 t.Errorf("Want response code %d, got %d", want, got)
95 }
96
97 errjson := &usererror.Error{}
98 if err := json.NewDecoder(w.Body).Decode(errjson); err != nil {
99 t.Error(err)
100 }
101 if got, want := errjson.Message, usererror.ErrUnauthorized.Message; got != want {
102 t.Errorf("Want error message %s, got %s", want, got)
103 }
104}
105
106func TestWriteForbidden(t *testing.T) {
107 ctx := context.TODO()

Callers

nothing calls this directly

Calls 4

UnauthorizedFunction · 0.70
DecodeMethod · 0.65
ErrorMethod · 0.65
ErrorfMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…