diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2019-12-02 21:06:51 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2019-12-02 21:06:51 +0000 |
commit | a19a376bf35b2009566e86b8190662c21ed7e2ba (patch) | |
tree | 46d3ea7f44a0a732b96fcbae0cf09d3cfd8ec9dc /spec/models/active_session_spec.rb | |
parent | 556c79d6cc3d7b24ecbba3a79f8432eb3fcf5c7e (diff) | |
download | gitlab-ce-a19a376bf35b2009566e86b8190662c21ed7e2ba.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/models/active_session_spec.rb')
-rw-r--r-- | spec/models/active_session_spec.rb | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/spec/models/active_session_spec.rb b/spec/models/active_session_spec.rb index 07f716c4f38..c26675e75bf 100644 --- a/spec/models/active_session_spec.rb +++ b/spec/models/active_session_spec.rb @@ -307,6 +307,28 @@ RSpec.describe ActiveSession, :clean_gitlab_redis_shared_state do expect(lookup_entries).not_to include(max_number_of_sessions_plus_one.to_s, max_number_of_sessions_plus_two.to_s) end end + + it 'removes obsolete lookup entries even without active session' do + Gitlab::Redis::SharedState.with do |redis| + redis.sadd( + "session:lookup:user:gitlab:#{user.id}", + "#{max_number_of_sessions_plus_two + 1}" + ) + end + + ActiveSession.cleanup(user) + + Gitlab::Redis::SharedState.with do |redis| + lookup_entries = redis.smembers("session:lookup:user:gitlab:#{user.id}") + + expect(lookup_entries.count).to eq(ActiveSession::ALLOWED_NUMBER_OF_ACTIVE_SESSIONS) + expect(lookup_entries).not_to include( + max_number_of_sessions_plus_one.to_s, + max_number_of_sessions_plus_two.to_s, + (max_number_of_sessions_plus_two + 1).to_s + ) + end + end end end end |