diff options
Diffstat (limited to 'spec/support/helpers/rack_attack_spec_helpers.rb')
-rw-r--r-- | spec/support/helpers/rack_attack_spec_helpers.rb | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/spec/support/helpers/rack_attack_spec_helpers.rb b/spec/support/helpers/rack_attack_spec_helpers.rb new file mode 100644 index 00000000000..234271ba1c0 --- /dev/null +++ b/spec/support/helpers/rack_attack_spec_helpers.rb @@ -0,0 +1,33 @@ +# frozen_string_literal: true + +module RackAttackSpecHelpers + def post_args_with_token_headers(url, token_headers) + [url, params: nil, headers: token_headers] + end + + def api_get_args_with_token_headers(partial_url, token_headers) + ["/api/#{API::API.version}#{partial_url}", params: nil, headers: token_headers] + end + + def rss_url(user) + "/dashboard/projects.atom?feed_token=#{user.feed_token}" + end + + def private_token_headers(user) + { 'HTTP_PRIVATE_TOKEN' => user.private_token } + end + + def personal_access_token_headers(personal_access_token) + { 'HTTP_PRIVATE_TOKEN' => personal_access_token.token } + end + + def oauth_token_headers(oauth_access_token) + { 'AUTHORIZATION' => "Bearer #{oauth_access_token.token}" } + end + + def expect_rejection(&block) + yield + + expect(response).to have_http_status(429) + end +end |