diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2019-12-05 00:07:31 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2019-12-05 00:07:31 +0300 |
commit | 71221554dd9ddf30f73035c89f78164e001aa96d (patch) | |
tree | c56e0b2fc3dd16602183b78cb3f68aed211c5e77 /spec/models/active_session_spec.rb | |
parent | b41cd8cb92d53454b2b160ba922d33801933a9cf (diff) |
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 | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/spec/models/active_session_spec.rb b/spec/models/active_session_spec.rb index c26675e75bf..072d0fa86e5 100644 --- a/spec/models/active_session_spec.rb +++ b/spec/models/active_session_spec.rb @@ -329,6 +329,35 @@ RSpec.describe ActiveSession, :clean_gitlab_redis_shared_state do ) end end + + context 'when the number of active sessions is lower than the limit' do + before do + Gitlab::Redis::SharedState.with do |redis| + ((max_number_of_sessions_plus_two - 4)..max_number_of_sessions_plus_two).each do |number| + redis.del("session:user:gitlab:#{user.id}:#{number}") + end + end + end + + it 'does not remove active session entries, but removes lookup entries' do + lookup_entries_before_cleanup = Gitlab::Redis::SharedState.with do |redis| + redis.smembers("session:lookup:user:gitlab:#{user.id}") + end + + sessions_before_cleanup = Gitlab::Redis::SharedState.with do |redis| + redis.scan_each(match: "session:user:gitlab:#{user.id}:*").to_a + end + + ActiveSession.cleanup(user) + + Gitlab::Redis::SharedState.with do |redis| + lookup_entries = redis.smembers("session:lookup:user:gitlab:#{user.id}") + sessions = redis.scan_each(match: "session:user:gitlab:#{user.id}:*").to_a + expect(sessions.count).to eq(sessions_before_cleanup.count) + expect(lookup_entries.count).to be < lookup_entries_before_cleanup.count + end + end + end end end end |