Skip to content

Commit

Permalink
✅ test: Fix failing CSRF tests (#2720)
Browse files Browse the repository at this point in the history
✅ test: fix failing csrf test

A test validating that expired tokens fail was hitting a race condition
with garbage collection. Sometimes, an assertion that expects memory
storage GC to have triggered happens too quickly, causing the assertion
to fail. Give the GC a little bit more time to process before asserting.
  • Loading branch information
nickajacks1 authored Nov 22, 2023
1 parent 12e0e48 commit eeced20
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion middleware/csrf/csrf_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ func Test_CSRF_ExpiredToken(t *testing.T) {
utils.AssertEqual(t, 200, ctx.Response.StatusCode())

// Wait for the token to expire
time.Sleep(1 * time.Second)
time.Sleep(1250 * time.Millisecond)

// Expired CSRF token
ctx.Request.Reset()
Expand Down

1 comment on commit eeced20

@ReneWerner87
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Performance Alert ⚠️

Possible performance regression was detected for benchmark.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold 2.

Benchmark suite Current: eeced20 Previous: 12e0e48 Ratio
Benchmark_AcquireCtx 1020 ns/op 1568 B/op 5 allocs/op 498.5 ns/op 1568 B/op 5 allocs/op 2.05

This comment was automatically generated by workflow using github-action-benchmark.

Please sign in to comment.