Skip to content

Commit 22ea58c

Browse files
committed
update tests
1 parent 0f162b1 commit 22ea58c

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

coderd/workspaceapps/db_test.go

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -454,7 +454,8 @@ func Test_ResolveRequest(t *testing.T) {
454454
require.NotZero(t, rw.Code)
455455
require.NotEqual(t, http.StatusOK, rw.Code)
456456

457-
require.Len(t, auditor.AuditLogs(), 0, "no audit logs for unauthenticated requests")
457+
assertAuditApp(t, rw, r, auditor, appsBySlug[app], uuid.Nil, nil)
458+
require.Len(t, auditor.AuditLogs(), 1, "audit log for unauthenticated requests")
458459
} else {
459460
if !assert.True(t, ok) {
460461
dump, err := httputil.DumpResponse(w, true)
@@ -971,7 +972,10 @@ func Test_ResolveRequest(t *testing.T) {
971972
w := rw.Result()
972973
defer w.Body.Close()
973974
require.Equal(t, http.StatusSeeOther, w.StatusCode)
974-
require.Len(t, auditor.AuditLogs(), 0, "no audit logs for redirect requests")
975+
// Note that we don't capture the owner UUID here because the apiKey
976+
// check/authorization exits early.
977+
assertAuditApp(t, rw, r, auditor, appsBySlug[appNameOwner], uuid.Nil, nil)
978+
require.Len(t, auditor.AuditLogs(), 1, "autit log entry for redirect")
975979

976980
loc, err := w.Location()
977981
require.NoError(t, err)
@@ -1254,7 +1258,9 @@ func workspaceappsResolveRequest(t testing.TB, auditor audit.Auditor, w http.Res
12541258
}
12551259

12561260
tracing.StatusWriterMiddleware(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
1257-
token, ok = workspaceapps.ResolveRequest(w, r, opts)
1261+
httpmw.AttachRequestID(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
1262+
token, ok = workspaceapps.ResolveRequest(w, r, opts)
1263+
})).ServeHTTP(w, r)
12581264
})).ServeHTTP(w, r)
12591265

12601266
return token, ok

0 commit comments

Comments
 (0)