From ba9a485542156af2d40612b9fce1163086d2856b Mon Sep 17 00:00:00 2001 From: Alex Sherman Date: Mon, 26 Apr 2021 17:17:13 +0500 Subject: [PATCH 1/3] Add test to check response on /error/ epp endpoint --- test/integration/epp/base_test.rb | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/test/integration/epp/base_test.rb b/test/integration/epp/base_test.rb index 2d19a6fa8..3e40ac525 100644 --- a/test/integration/epp/base_test.rb +++ b/test/integration/epp/base_test.rb @@ -34,6 +34,13 @@ 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_validates_request_xml invalid_xml = <<-XML From c0917d4978f99871d38d9f50badd7847f1cf4e6c Mon Sep 17 00:00:00 2001 From: Oleg Hasjanov Date: Mon, 26 Apr 2021 16:05:52 +0300 Subject: [PATCH 2/3] changed error code --- app/controllers/epp/base_controller.rb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/app/controllers/epp/base_controller.rb b/app/controllers/epp/base_controller.rb index f12bd1bd2..3943d741b 100644 --- a/app/controllers/epp/base_controller.rb +++ b/app/controllers/epp/base_controller.rb @@ -8,7 +8,7 @@ module Epp before_action :ensure_session_id_passed before_action :generate_svtrid before_action :latin_only - before_action :validate_against_schema + # before_action :validate_against_schema before_action :validate_request before_action :enforce_epp_session_timeout, if: :signed_in? before_action :iptables_counter_update, if: :signed_in? @@ -113,7 +113,6 @@ module Epp end end end - @errors.uniq! render_epp_response '/epp/error' From e76f8da61819eaf066651a4735eed9b80c1794ba Mon Sep 17 00:00:00 2001 From: Oleg Hasjanov Date: Tue, 27 Apr 2021 15:25:56 +0300 Subject: [PATCH 3/3] refactoring test --- app/controllers/epp/base_controller.rb | 4 +++- test/integration/epp/base_test.rb | 15 ++++++++++++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/app/controllers/epp/base_controller.rb b/app/controllers/epp/base_controller.rb index 3943d741b..820fe9098 100644 --- a/app/controllers/epp/base_controller.rb +++ b/app/controllers/epp/base_controller.rb @@ -8,7 +8,7 @@ module Epp before_action :ensure_session_id_passed before_action :generate_svtrid before_action :latin_only - # before_action :validate_against_schema + before_action :validate_against_schema before_action :validate_request before_action :enforce_epp_session_timeout, if: :signed_in? before_action :iptables_counter_update, if: :signed_in? @@ -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) diff --git a/test/integration/epp/base_test.rb b/test/integration/epp/base_test.rb index 3e40ac525..41fb186fe 100644 --- a/test/integration/epp/base_test.rb +++ b/test/integration/epp/base_test.rb @@ -41,6 +41,19 @@ class EppBaseTest < EppTestCase 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 @@ -50,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