diff --git a/app/models/epp_session.rb b/app/models/epp_session.rb index f1b641aa0..1336be39e 100644 --- a/app/models/epp_session.rb +++ b/app/models/epp_session.rb @@ -6,11 +6,10 @@ class EppSession < ApplicationRecord class_attribute :timeout self.timeout = (ENV['epp_session_timeout_seconds'] || 300).to_i.seconds - alias_attribute :last_access, :updated_at + class_attribute :limit_per_registrar + self.limit_per_registrar = (ENV['epp_session_limit_per_registrar'] || 4).to_i - def self.limit_per_registrar - 4 - end + alias_attribute :last_access, :updated_at def self.limit_reached?(registrar) count = where(user_id: registrar.api_users.ids).where('updated_at >= ?', Time.zone.now - 1.second).count diff --git a/config/application.yml.sample b/config/application.yml.sample index ab64ed35e..65e83b603 100644 --- a/config/application.yml.sample +++ b/config/application.yml.sample @@ -170,6 +170,8 @@ tara_rant_redirect_uri: 'redirect_uri' default_email_validation_type: 'regex' +epp_session_limit_per_registrar: '4' + # Since the keys for staging are absent from the repo, we need to supply them separate for testing. test: payments_seb_bank_certificate: 'test/fixtures/files/seb_bank_cert.pem' diff --git a/test/models/epp_session_test.rb b/test/models/epp_session_test.rb index 8ed63f6ab..398753bd1 100644 --- a/test/models/epp_session_test.rb +++ b/test/models/epp_session_test.rb @@ -49,10 +49,6 @@ class EppSessionTest < ActiveSupport::TestCase end end - def test_limit_per_registrar - assert_equal 4, EppSession.limit_per_registrar - end - def test_limit_is_per_registrar travel_to Time.zone.parse('2010-07-05') EppSession.delete_all