mirror of
https://github.com/internetee/registry.git
synced 2025-07-31 06:56:23 +02:00
Refactored EppRequestable module
This commit is contained in:
parent
1fba3a731c
commit
a55a2f922a
2 changed files with 30 additions and 28 deletions
|
@ -2,7 +2,7 @@ module EppRequestable
|
|||
extend ActiveSupport::Concern
|
||||
|
||||
included do
|
||||
before_action :validate_epp_user, only: :create
|
||||
# before_action :validate_epp_user, only: :create
|
||||
end
|
||||
|
||||
def create
|
||||
|
@ -14,37 +14,37 @@ module EppRequestable
|
|||
|
||||
private
|
||||
|
||||
def validate_epp_user
|
||||
return unless handle_hello_request
|
||||
# def validate_epp_user
|
||||
# return unless handle_hello_request
|
||||
|
||||
handle_login_request
|
||||
server.close_connection
|
||||
rescue OpenSSL::SSL::SSLError => e
|
||||
Rails.logger.error "INVALID CERT: #{e}"
|
||||
Rails.logger.error "INVALID CERT DEBUG INFO: epp_hostname: #{ENV['epp_hostname']}," \
|
||||
"port: #{ENV['epp_port']}, cert_path: #{ENV['cert_path']}, key_path: #{ENV['key_path']}"
|
||||
handle_non_epp_errors(nil, I18n.t('errors.messages.invalid_cert'))
|
||||
end
|
||||
# handle_login_request
|
||||
# server.close_connection
|
||||
# rescue OpenSSL::SSL::SSLError => e
|
||||
# Rails.logger.error "INVALID CERT: #{e}"
|
||||
# Rails.logger.error "INVALID CERT DEBUG INFO: epp_hostname: #{ENV['epp_hostname']}," \
|
||||
# "port: #{ENV['epp_port']}, cert_path: #{ENV['cert_path']}, key_path: #{ENV['key_path']}"
|
||||
# handle_non_epp_errors(nil, I18n.t('errors.messages.invalid_cert'))
|
||||
# end
|
||||
|
||||
def handle_hello_request
|
||||
res = server.open_connection
|
||||
unless Nokogiri::XML(res).css('greeting')
|
||||
server.close_connection # just in case
|
||||
handle_non_epp_errors(nil, I18n.t('errors.messages.failed_epp_conn')) and return false
|
||||
end
|
||||
true
|
||||
end
|
||||
# def handle_hello_request
|
||||
# res = server.open_connection
|
||||
# unless Nokogiri::XML(res).css('greeting')
|
||||
# server.close_connection # just in case
|
||||
# handle_non_epp_errors(nil, I18n.t('errors.messages.failed_epp_conn')) and return false
|
||||
# end
|
||||
# true
|
||||
# end
|
||||
|
||||
def handle_login_request
|
||||
tag = current_user.username
|
||||
ex = EppXml::Session.new(cl_trid_prefix: tag)
|
||||
xml = ex.login(clID: { value: tag }, pw: { value: current_user.plain_text_password })
|
||||
res = server.send_request(xml)
|
||||
# def handle_login_request
|
||||
# tag = current_user.username
|
||||
# ex = EppXml::Session.new(cl_trid_prefix: tag)
|
||||
# xml = ex.login(clID: { value: tag }, pw: { value: current_user.plain_text_password })
|
||||
# res = server.send_request(xml)
|
||||
|
||||
return if Nokogiri::XML(res).css('result').first['code'] == '1000'
|
||||
# return if Nokogiri::XML(res).css('result').first['code'] == '1000'
|
||||
|
||||
handle_non_epp_errors(nil, Nokogiri::XML(res).css('result').text)
|
||||
end
|
||||
# handle_non_epp_errors(nil, Nokogiri::XML(res).css('result').text)
|
||||
# end
|
||||
|
||||
def server
|
||||
client_cert = File.read(ENV['cert_path'])
|
||||
|
|
|
@ -21,7 +21,9 @@ class ReppV1RegistrarXmlConsoleTest < ActionDispatch::IntegrationTest
|
|||
end
|
||||
|
||||
def test_check_schema_path
|
||||
post repp_v1_registrar_xml_console_path, params: { xml_console: { payload: payload } }.to_json,
|
||||
@auth_headers['Content-Type'] = 'application/json'
|
||||
params = { xml_console: { payload: payload } }
|
||||
post repp_v1_registrar_xml_console_path, params: params.to_json,
|
||||
headers: @auth_headers
|
||||
|
||||
assert_response :ok
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue