Commit eb871d3a authored by Quang-Minh Nguyen's avatar Quang-Minh Nguyen

Refine expect_rejection assertions

parent b1c223d5
......@@ -26,18 +26,35 @@ module RackAttackSpecHelpers
{ 'AUTHORIZATION' => "Basic #{encoded_login}" }
end
# rubocop:disable Metrics/AbcSize
def expect_rejection(&block)
yield
expect(response).to have_gitlab_http_status(:too_many_requests)
expect(response).to have_header('Retry-After')
expect(response.headers['Retry-After']).to match(/^\d+$/)
expect(response).to have_header('RateLimit-Limit')
expect(response.headers['RateLimit-Limit']).to match(/^\d+$/)
expect(response).to have_header('RateLimit-Observed')
expect(response.headers['RateLimit-Observed']).to match(/^\d+$/)
expect(response).to have_header('RateLimit-Remaining')
expect(response.headers['RateLimit-Remaining']).to match(/^\d+$/)
expect(response).to have_header('RateLimit-Reset')
expect(response.headers['RateLimit-Reset']).to match(/^\d+$/)
expect(response).to have_header('RateLimit-ResetTime')
expect do
Time.httpdate(response.headers['RateLimit-ResetTime'])
end.not_to raise_error
expect(response).to have_header('Retry-After')
expect(response.headers['Retry-After']).to match(/^\d+$/)
end
# rubocop:enable Metrics/AbcSize
def expect_ok(&block)
yield
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment