diff --git a/app/controllers/epp/base_controller.rb b/app/controllers/epp/base_controller.rb index 99c0ead35..820fe9098 100644 --- a/app/controllers/epp/base_controller.rb +++ b/app/controllers/epp/base_controller.rb @@ -23,6 +23,8 @@ module Epp rescue_from ActiveRecord::RecordNotFound, with: :respond_with_object_does_not_exist_error before_action :set_paper_trail_whodunnit + skip_before_action :validate_against_schema + protected def respond_with_command_failed_error(exception) @@ -103,7 +105,7 @@ module Epp @errors += obj.errors[:epp_errors] end - if params[:parsed_frame].at_css('update') + if params[:parsed_frame]&.at_css('update') @errors.each_with_index do |errors, index| if errors[:code] == '2304' && errors[:value].present? && @@ -113,7 +115,6 @@ module Epp end end end - @errors.uniq! render_epp_response '/epp/error' diff --git a/app/controllers/epp/errors_controller.rb b/app/controllers/epp/errors_controller.rb index e4b179464..6cb689166 100644 --- a/app/controllers/epp/errors_controller.rb +++ b/app/controllers/epp/errors_controller.rb @@ -6,5 +6,10 @@ module Epp epp_errors << { code: params[:code], msg: params[:msg] } render_epp_response '/epp/error' end + + def command_handler + epp_errors << { code: '2000', msg: 'Unknown command' } + render_epp_response '/epp/error' + end end end diff --git a/config/routes.rb b/config/routes.rb index a6a9f5ab3..be4c3cd7e 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -36,6 +36,7 @@ Rails.application.routes.draw do post 'command/poll', to: 'polls#poll', as: 'poll', constraints: EppConstraint.new(:poll) get 'error/:command', to: 'errors#error' + get 'error', to: 'errors#command_handler' end namespace :repp do diff --git a/test/integration/epp/base_test.rb b/test/integration/epp/base_test.rb index 2d19a6fa8..41fb186fe 100644 --- a/test/integration/epp/base_test.rb +++ b/test/integration/epp/base_test.rb @@ -34,6 +34,26 @@ class EppBaseTest < EppTestCase end end + def test_additional_error + get '/epp/error', params: { frame: valid_request_xml }, + headers: { 'HTTP_COOKIE' => 'session=api_bestnames' } + + assert_epp_response :unknown_command + end + + def test_error_with_unknown_command + invalid_xml = <<-XML + + + + XML + + get '/epp/error', params: { frame: invalid_xml }, + headers: { 'HTTP_COOKIE' => 'session=api_bestnames' } + + assert_epp_response :unknown_command + end + def test_validates_request_xml invalid_xml = <<-XML @@ -43,7 +63,7 @@ class EppBaseTest < EppTestCase post valid_command_path, params: { frame: invalid_xml }, headers: { 'HTTP_COOKIE' => 'session=api_bestnames' } - assert_epp_response :syntax_error + assert_epp_response :required_parameter_missing end def test_anonymous_user