diff options
author | Pawel Chojnacki <pawel@chojnacki.ws> | 2017-02-17 13:24:32 +0100 |
---|---|---|
committer | Pawel Chojnacki <pawel@chojnacki.ws> | 2017-03-06 15:41:25 +0100 |
commit | b1da4f7de3019059051e35c806bb03bdacb41fcf (patch) | |
tree | e8c222f99ddee8dda54035d6d62b86f74272a814 /spec/controllers/sessions_controller_spec.rb | |
parent | 8993801f0cefdc64b46b8fe30622cc78eaa03173 (diff) | |
download | gitlab-ce-b1da4f7de3019059051e35c806bb03bdacb41fcf.tar.gz |
Cleanup RSpec tests
Diffstat (limited to 'spec/controllers/sessions_controller_spec.rb')
-rw-r--r-- | spec/controllers/sessions_controller_spec.rb | 23 |
1 files changed, 2 insertions, 21 deletions
diff --git a/spec/controllers/sessions_controller_spec.rb b/spec/controllers/sessions_controller_spec.rb index f1157d159ab..56ed11737ad 100644 --- a/spec/controllers/sessions_controller_spec.rb +++ b/spec/controllers/sessions_controller_spec.rb @@ -30,30 +30,11 @@ describe SessionsController do expect(SecurityEvent.last.details[:with]).to eq('standard') end - context 'unique ip limit is enabled and set to 1', :redis do - before do - allow(Gitlab::Auth::UniqueIpsLimiter).to receive_message_chain(:config, :unique_ips_limit_enabled).and_return(true) - allow(Gitlab::Auth::UniqueIpsLimiter).to receive_message_chain(:config, :unique_ips_limit_time_window).and_return(10) - allow(Gitlab::Auth::UniqueIpsLimiter).to receive_message_chain(:config, :unique_ips_limit_per_user).and_return(1) - end - - it 'allows user authenticating from the same ip' do - allow(Gitlab::RequestContext).to receive(:client_ip).and_return('ip') - post(:create, user: { login: user.username, password: user.password }) - expect(subject.current_user).to eq user - + include_examples 'user login operation with unique ip limit' do + def operation post(:create, user: { login: user.username, password: user.password }) expect(subject.current_user).to eq user end - - it 'blocks user authenticating from two distinct ips' do - allow(Gitlab::RequestContext).to receive(:client_ip).and_return('ip') - post(:create, user: { login: user.username, password: user.password }) - expect(subject.current_user).to eq user - - allow(Gitlab::RequestContext).to receive(:client_ip).and_return('ip2') - expect { post(:create, user: { login: user.username, password: user.password }) }.to raise_error(Gitlab::Auth::TooManyIps) - end end end end |