Skip to content

Commit

Permalink
refactoring test
Browse files Browse the repository at this point in the history
  • Loading branch information
Oleg Hasjanov committed Apr 27, 2021
1 parent c0917d4 commit e76f8da
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
4 changes: 3 additions & 1 deletion app/controllers/epp/base_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class AuthorizationError < StandardError; end
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?
Expand All @@ -23,6 +23,8 @@ class AuthorizationError < StandardError; end
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)
Expand Down
15 changes: 14 additions & 1 deletion test/integration/epp/base_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,19 @@ def test_additional_error
assert_epp_response :unknown_command
end

def test_error_with_unknown_command
invalid_xml = <<-XML
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<epsdp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
</epp>
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
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
Expand All @@ -50,7 +63,7 @@ def test_validates_request_xml
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
Expand Down

0 comments on commit e76f8da

Please sign in to comment.