mirror of
https://github.com/internetee/registry.git
synced 2025-07-22 18:56:05 +02:00
Improve readability
This commit is contained in:
parent
9eb7d3527b
commit
cbb3c0d5ef
3 changed files with 8 additions and 8 deletions
|
@ -6,14 +6,14 @@ class EppSession < ApplicationRecord
|
||||||
class_attribute :timeout
|
class_attribute :timeout
|
||||||
self.timeout = (ENV['epp_session_timeout_seconds'] || 300).to_i.seconds
|
self.timeout = (ENV['epp_session_timeout_seconds'] || 300).to_i.seconds
|
||||||
|
|
||||||
class_attribute :limit_per_registrar
|
class_attribute :sessions_per_registrar
|
||||||
self.limit_per_registrar = (ENV['epp_session_limit_per_registrar'] || 4).to_i
|
self.sessions_per_registrar = (ENV['epp_session_limit_per_registrar'] || 4).to_i
|
||||||
|
|
||||||
alias_attribute :last_access, :updated_at
|
alias_attribute :last_access, :updated_at
|
||||||
|
|
||||||
def self.limit_reached?(registrar)
|
def self.limit_reached?(registrar)
|
||||||
count = where(user_id: registrar.api_users.ids).count
|
count = where(user_id: registrar.api_users.ids).count
|
||||||
count >= limit_per_registrar
|
count >= sessions_per_registrar
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.expired
|
def self.expired
|
||||||
|
|
|
@ -170,7 +170,7 @@ tara_rant_redirect_uri: 'redirect_uri'
|
||||||
default_email_validation_type: 'regex'
|
default_email_validation_type: 'regex'
|
||||||
|
|
||||||
|
|
||||||
epp_session_limit_per_registrar: '4'
|
epp_sessions_per_registrar: '4'
|
||||||
|
|
||||||
# Since the keys for staging are absent from the repo, we need to supply them separate for testing.
|
# Since the keys for staging are absent from the repo, we need to supply them separate for testing.
|
||||||
test:
|
test:
|
||||||
|
|
|
@ -2,11 +2,11 @@ require 'test_helper'
|
||||||
|
|
||||||
class EppLoginTest < EppTestCase
|
class EppLoginTest < EppTestCase
|
||||||
setup do
|
setup do
|
||||||
@original_session_limit_per_registrar = EppSession.limit_per_registrar
|
@original_sessions_per_registrar_setting = EppSession.sessions_per_registrar
|
||||||
end
|
end
|
||||||
|
|
||||||
teardown do
|
teardown do
|
||||||
EppSession.limit_per_registrar = @original_session_limit_per_registrar
|
EppSession.sessions_per_registrar = @original_sessions_per_registrar_setting
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_logging_in_with_correct_credentials_creates_new_session
|
def test_logging_in_with_correct_credentials_creates_new_session
|
||||||
|
@ -142,10 +142,10 @@ class EppLoginTest < EppTestCase
|
||||||
assert_equal new_password, user.plain_text_password
|
assert_equal new_password, user.plain_text_password
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_user_cannot_login_when_session_limit_is_exceeded
|
def test_user_cannot_login_when_max_allowed_sessions_per_registrar_is_exceeded
|
||||||
user = users(:api_bestnames)
|
user = users(:api_bestnames)
|
||||||
eliminate_effect_of_existing_epp_sessions
|
eliminate_effect_of_existing_epp_sessions
|
||||||
EppSession.limit_per_registrar = 1
|
EppSession.sessions_per_registrar = 1
|
||||||
EppSession.create!(session_id: 'any', user: user)
|
EppSession.create!(session_id: 'any', user: user)
|
||||||
|
|
||||||
request_xml = <<-XML
|
request_xml = <<-XML
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue