Skip to content

Commit

Permalink
Clear expired EPP sessions
Browse files Browse the repository at this point in the history
Fixes #711
  • Loading branch information
Artur Beljajev authored and yulgolem committed Aug 31, 2020
1 parent 44e9b1b commit 4c884cc
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
7 changes: 7 additions & 0 deletions lib/tasks/epp/clear_expired_sessions.rake
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace :epp do
desc 'Clear expired EPP sessions'

task clear_expired_sessions: :environment do
Epp::ExpiredSessions.new(EppSession.expired).clear
end
end
20 changes: 20 additions & 0 deletions test/tasks/epp/clear_expired_sessions_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
require 'test_helper'

class EppClearExpiredSessionsTaskTest < ActiveSupport::TestCase
def test_clears_expired_epp_sessions
idle_timeout = 0.second
EppSession.idle_timeout = idle_timeout
session = epp_sessions(:api_bestnames)
session.update!(updated_at: Time.zone.now - idle_timeout - 1.second)

run_task

assert_nil EppSession.find_by(session_id: session.session_id)
end

private

def run_task
Rake::Task['epp:clear_expired_sessions'].execute
end
end

0 comments on commit 4c884cc

Please sign in to comment.