Add current limits to the error message

This commit is contained in:
Alex Sherman 2021-12-05 14:06:13 +05:00 committed by olegphenomenon
parent 16d4e4b4e6
commit dbe1678430
6 changed files with 11 additions and 3 deletions

View file

@ -32,7 +32,7 @@ module Epp
def respond_with_session_limit_exceeded_error(exception)
epp_errors.add(:epp_errors,
code: '2502',
message: 'Session limit exceeded, try again later')
msg: Shunter.default_error_message)
handle_errors
log_exception(exception)
end

View file

@ -9,6 +9,10 @@ module Shunter
BASE_CONNECTION = ENV['shunter_redis_connection'] || { host: 'redis', port: 6379 }
def default_error_message
"Session limit exceeded. Current limit is #{default_threshold} in #{default_timespan} seconds"
end
def default_timespan
ENV['shunter_default_timespan'] || ONE_MINUTE
end

View file

@ -105,6 +105,9 @@ class Epp::Domain < Domain
max: Setting.ns_max_count
}
],
'2502' => [ # Rate limit exceeded
%i[base session_limit_exceeded],
],
]
}
end

View file

@ -62,7 +62,7 @@ module Epp
2308 => 'Data management policy violation',
2400 => 'Command failed',
2501 => 'Authentication error; server closing connection',
2502 => 'Session limit exceeded; server closing connection',
2502 => Shunter.default_error_message,
}.freeze
private_constant :DEFAULT_DESCRIPTIONS

View file

@ -236,6 +236,7 @@ class EppDomainInfoBaseTest < EppTestCase
response_xml = Nokogiri::XML(response.body)
assert_epp_response :session_limit_exceeded_server_closing_connection
assert_correct_against_schema response_xml
assert response.body.include?(Shunter.default_error_message)
ENV["shunter_default_threshold"] = '10000'
ENV["shunter_enabled"] = 'false'
end

View file

@ -85,7 +85,7 @@ class EppResponseResultCodeTest < ActiveSupport::TestCase
2308 => 'Data management policy violation',
2400 => 'Command failed',
2501 => 'Authentication error; server closing connection',
2502 => 'Session limit exceeded; server closing connection'
2502 => Shunter.default_error_message
}
assert_equal descriptions, Epp::Response::Result::Code.default_descriptions
end