diff --git a/internal/federationdomain/endpoints/login/login_handler_test.go b/internal/federationdomain/endpoints/login/login_handler_test.go index 3e761d442..64506ccb7 100644 --- a/internal/federationdomain/endpoints/login/login_handler_test.go +++ b/internal/federationdomain/endpoints/login/login_handler_test.go @@ -388,7 +388,7 @@ func TestLoginEndpoint(t *testing.T) { ) error { require.Equal(t, req, r) require.Equal(t, rsp, w) - require.Equal(t, stateparam.Encoded(tt.wantEncodedState), encodedState) + require.Equal(t, tt.wantEncodedState, encodedState) require.Equal(t, tt.wantDecodedState, decodedState) if tt.getHandlerErr == nil { _, err := w.Write([]byte(happyGetResult)) @@ -405,7 +405,7 @@ func TestLoginEndpoint(t *testing.T) { ) error { require.Equal(t, req, r) require.Equal(t, rsp, w) - require.Equal(t, stateparam.Encoded(tt.wantEncodedState), encodedState) + require.Equal(t, tt.wantEncodedState, encodedState) require.Equal(t, tt.wantDecodedState, decodedState) if tt.postHandlerErr == nil { _, err := w.Write([]byte(happyPostResult)) diff --git a/internal/testutil/log_lines.go b/internal/testutil/log_lines.go index 7f1cd7600..7ada0a320 100644 --- a/internal/testutil/log_lines.go +++ b/internal/testutil/log_lines.go @@ -41,8 +41,8 @@ func WantAuditLog(message string, params map[string]any, auditID string) WantedA func CompareAuditLogs(t *testing.T, wantAuditLogs []WantedAuditLog, actualAuditLogsOneLiner string) { t.Helper() - var wantJsonAuditLogs []map[string]any - var wantMessages []string + wantJsonAuditLogs := make([]map[string]any, 0) + wantMessages := make([]string, 0) for _, wantAuditLog := range wantAuditLogs { wantJsonAuditLog := make(map[string]any) wantJsonAuditLog["level"] = "info" @@ -56,8 +56,8 @@ func CompareAuditLogs(t *testing.T, wantAuditLogs []WantedAuditLog, actualAuditL wantJsonAuditLogs = append(wantJsonAuditLogs, wantJsonAuditLog) } - var actualJsonAuditLogs []map[string]any - var actualMessages []string + actualJsonAuditLogs := make([]map[string]any, 0) + actualMessages := make([]string, 0) actualAuditLogs := strings.Split(actualAuditLogsOneLiner, "\n") require.GreaterOrEqual(t, len(actualAuditLogs), 2) actualAuditLogs = actualAuditLogs[:len(actualAuditLogs)-1] // trim off the last "" @@ -78,15 +78,12 @@ func CompareAuditLogs(t *testing.T, wantAuditLogs []WantedAuditLog, actualAuditL actualMessages = append(actualMessages, actualMessage) } - // TODO: remove this - t.Logf("LAST AUDIT EVENT: %s", actualAuditLogs[len(actualAuditLogs)-1]) - // We should check array indices first so that we don't exceed any boundaries. // But we also want to be sure to indicate to the caller what went wrong, so compare the messages. require.Equal(t, wantMessages, actualMessages) // We can expect the audit logs to be ordered deterministically. - for i := range len(wantJsonAuditLogs) { + for i := range wantJsonAuditLogs { // compare each item individually so we know which message it is require.Equal(t, wantJsonAuditLogs[i], actualJsonAuditLogs[i], "audit event for message %q does not match", wantJsonAuditLogs[i]["message"])