diff options
Diffstat (limited to 'spec/support/helpers')
| -rw-r--r-- | spec/support/helpers/rack_attack_spec_helpers.rb | 4 | ||||
| -rw-r--r-- | spec/support/helpers/session_helpers.rb | 16 |
2 files changed, 2 insertions, 18 deletions
diff --git a/spec/support/helpers/rack_attack_spec_helpers.rb b/spec/support/helpers/rack_attack_spec_helpers.rb index c82a87dc58e..d50a6382a40 100644 --- a/spec/support/helpers/rack_attack_spec_helpers.rb +++ b/spec/support/helpers/rack_attack_spec_helpers.rb @@ -26,14 +26,14 @@ module RackAttackSpecHelpers { 'AUTHORIZATION' => "Basic #{encoded_login}" } end - def expect_rejection(name = nil, &block) + def expect_rejection(&block) yield expect(response).to have_gitlab_http_status(:too_many_requests) expect(response.headers.to_h).to include( 'RateLimit-Limit' => a_string_matching(/^\d+$/), - 'RateLimit-Name' => name || a_string_matching(/^throttle_.*$/), + 'RateLimit-Name' => a_string_matching(/^throttle_.*$/), 'RateLimit-Observed' => a_string_matching(/^\d+$/), 'RateLimit-Remaining' => a_string_matching(/^\d+$/), 'Retry-After' => a_string_matching(/^\d+$/) diff --git a/spec/support/helpers/session_helpers.rb b/spec/support/helpers/session_helpers.rb index 394a401afca..236585296e5 100644 --- a/spec/support/helpers/session_helpers.rb +++ b/spec/support/helpers/session_helpers.rb @@ -1,22 +1,6 @@ # frozen_string_literal: true module SessionHelpers - # Stub a session in Redis, for use in request specs where we can't mock the session directly. - # This also needs the :clean_gitlab_redis_sessions tag on the spec. - def stub_session(session_hash) - unless RSpec.current_example.metadata[:clean_gitlab_redis_sessions] - raise 'Add :clean_gitlab_redis_sessions to your spec!' - end - - session_id = Rack::Session::SessionId.new(SecureRandom.hex) - - Gitlab::Redis::Sessions.with do |redis| - redis.set("session:gitlab:#{session_id.private_id}", Marshal.dump(session_hash)) - end - - cookies[Gitlab::Application.config.session_options[:key]] = session_id.public_id - end - def expect_single_session_with_authenticated_ttl expect_single_session_with_expiration(Settings.gitlab['session_expire_delay'] * 60) end |
