Skip to content

Commit

Permalink
block request logic is working as expected now, test fixed :)
Browse files Browse the repository at this point in the history
  • Loading branch information
fabriziosalmi committed Jan 29, 2025
1 parent abb5a17 commit 859a9f1
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions response_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,12 @@ func TestBlockRequest(t *testing.T) {
ResponseWritten: true,
StatusCode: http.StatusOK,
}
recorder := NewResponseRecorder(w)

m.blockRequest(w, r, state, http.StatusForbidden, "test reason", "rule1", "match1")
m.blockRequest(recorder, r, state, http.StatusForbidden, "test reason", "rule1", "match1")

assert.Equal(t, http.StatusOK, state.StatusCode)
assert.Equal(t, http.StatusForbidden, recorder.StatusCode()) // Check the Recorder status code instead
assert.True(t, state.ResponseWritten) // Check that the ResponseWritten flag is set
assert.True(t, state.Blocked) // Verify block is set to true
})
}

0 comments on commit 859a9f1

Please sign in to comment.