Improved session tests.
This commit is contained in:
parent
fa454abf3a
commit
90047729d4
5 changed files with 31 additions and 8 deletions
|
@ -448,11 +448,21 @@ returns
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
=begin
|
||||||
|
|
||||||
|
remove all session and spool messages
|
||||||
|
|
||||||
|
Sessions.cleanup
|
||||||
|
|
||||||
|
=end
|
||||||
|
|
||||||
def self.cleanup
|
def self.cleanup
|
||||||
path = "#{@path}/spool/"
|
Dir.foreach(@path) do |entry|
|
||||||
FileUtils.rm_rf path
|
next if entry == '.'
|
||||||
path = "#{@path}/tmp/"
|
next if entry == '..'
|
||||||
FileUtils.rm_rf path
|
FileUtils.rm_rf entry
|
||||||
|
end
|
||||||
|
true
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.spool_create(data)
|
def self.spool_create(data)
|
||||||
|
|
|
@ -42,6 +42,9 @@ class ActiveSupport::TestCase
|
||||||
# clear cache
|
# clear cache
|
||||||
Cache.clear
|
Cache.clear
|
||||||
|
|
||||||
|
# remove all session messages
|
||||||
|
Sessions.cleanup
|
||||||
|
|
||||||
# remove background jobs
|
# remove background jobs
|
||||||
Delayed::Job.destroy_all
|
Delayed::Job.destroy_all
|
||||||
Trigger.destroy_all
|
Trigger.destroy_all
|
||||||
|
|
|
@ -70,8 +70,11 @@ class SessionBasicTicketTest < ActiveSupport::TestCase
|
||||||
Sessions::Backend::TicketOverviewList.reset(user.id)
|
Sessions::Backend::TicketOverviewList.reset(user.id)
|
||||||
result1 = client1.push
|
result1 = client1.push
|
||||||
assert(result1, 'check ticket_overview_index - recall 7')
|
assert(result1, 'check ticket_overview_index - recall 7')
|
||||||
travel_back
|
|
||||||
|
|
||||||
|
travel 10.seconds
|
||||||
|
Sessions.destroy_idle_sessions(3)
|
||||||
|
|
||||||
|
travel_back
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -130,6 +130,10 @@ class SessionCollectionsTest < ActiveSupport::TestCase
|
||||||
assert(result2.empty?, 'check collections - recall')
|
assert(result2.empty?, 'check collections - recall')
|
||||||
result3 = collection_client3.push
|
result3 = collection_client3.push
|
||||||
assert(result3.empty?, 'check collections - recall')
|
assert(result3.empty?, 'check collections - recall')
|
||||||
|
|
||||||
|
travel 10.seconds
|
||||||
|
Sessions.destroy_idle_sessions(3)
|
||||||
|
|
||||||
travel_back
|
travel_back
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -175,9 +179,9 @@ class SessionCollectionsTest < ActiveSupport::TestCase
|
||||||
|
|
||||||
UserInfo.current_user_id = 2
|
UserInfo.current_user_id = 2
|
||||||
agent1 = User.create_or_update(
|
agent1 = User.create_or_update(
|
||||||
login: 'sessions-assets-1',
|
login: "sessions-assets-1-#{rand(99_999)}",
|
||||||
firstname: 'Session',
|
firstname: 'Session',
|
||||||
lastname: "activity stream #{rand(99_999)}",
|
lastname: "sessions assets #{rand(99_999)}",
|
||||||
email: 'sessions-assets1@example.com',
|
email: 'sessions-assets1@example.com',
|
||||||
password: 'agentpw',
|
password: 'agentpw',
|
||||||
active: true,
|
active: true,
|
||||||
|
@ -204,6 +208,9 @@ class SessionCollectionsTest < ActiveSupport::TestCase
|
||||||
assert(data[:collection][:Group][groups.first.id])
|
assert(data[:collection][:Group][groups.first.id])
|
||||||
assert_nil(data[:assets][:Group])
|
assert_nil(data[:assets][:Group])
|
||||||
|
|
||||||
|
travel 10.seconds
|
||||||
|
Sessions.destroy_idle_sessions(3)
|
||||||
|
|
||||||
travel_back
|
travel_back
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -155,7 +155,7 @@ class SessionEnhancedTest < ActiveSupport::TestCase
|
||||||
|
|
||||||
# check if session still exists after idle cleanup
|
# check if session still exists after idle cleanup
|
||||||
sleep 4
|
sleep 4
|
||||||
client_ids = Sessions.destroy_idle_sessions(3)
|
client_ids = Sessions.destroy_idle_sessions(2)
|
||||||
|
|
||||||
# check client sessions
|
# check client sessions
|
||||||
assert(!Sessions.session_exists?(client_id1), 'check if session is removed')
|
assert(!Sessions.session_exists?(client_id1), 'check if session is removed')
|
||||||
|
|
Loading…
Reference in a new issue