diff --git a/app/controllers/epp/domains_controller.rb b/app/controllers/epp/domains_controller.rb index 6f8d10ced..d017fbcce 100644 --- a/app/controllers/epp/domains_controller.rb +++ b/app/controllers/epp/domains_controller.rb @@ -4,6 +4,7 @@ module Epp before_action :find_domain, only: %i[info renew update transfer delete] before_action :find_password, only: %i[info update transfer delete] before_action :set_paper_trail_whodunnit + before_action :parse_schemas_prefix_and_version def info authorize! :info, @domain @@ -243,5 +244,14 @@ module Epp end true end + + def parse_schemas_prefix_and_version + return unless params[:frame] + + xml = params[:frame].gsub!(/(?<=>)(.*?)(?=<)/, &:strip).to_s + res = xml.match(/xmlns:domain=\"https:\/\/epp.tld.ee\/schema\/(?\w+-\w+)-(?\w.\w).xsd/) + @schema_version = res[:version] + @schema_prefix = res[:prefix] + end end end diff --git a/app/views/epp/domains/check.xml.builder b/app/views/epp/domains/check.xml.builder index 7816ac909..6a37d8382 100644 --- a/app/views/epp/domains/check.xml.builder +++ b/app/views/epp/domains/check.xml.builder @@ -5,7 +5,8 @@ xml.epp_head do end xml.resData do - xml.tag!('domain:chkData', 'xmlns:domain' => Xsd::Schema.filename(for_prefix: 'domain-ee')) do + xml.tag!('domain:chkData', + 'xmlns:domain' => Xsd::Schema.filename(for_prefix: @schema_prefix)) do @domains.each do |x| xml.tag!('domain:cd') do xml.tag!('domain:name', x[:name], 'avail' => x[:avail]) diff --git a/app/views/epp/domains/create.xml.builder b/app/views/epp/domains/create.xml.builder index 7a907c4b7..e1338780a 100644 --- a/app/views/epp/domains/create.xml.builder +++ b/app/views/epp/domains/create.xml.builder @@ -5,7 +5,8 @@ xml.epp_head do end xml.resData do - xml.tag!('domain:creData', 'xmlns:domain' => Xsd::Schema.filename(for_prefix: 'domain-ee')) do + xml.tag!('domain:creData', + 'xmlns:domain' => Xsd::Schema.filename(for_prefix: @schema_prefix)) do xml.tag!('domain:name', @domain.name) xml.tag!('domain:crDate', @domain.created_at.try(:iso8601)) xml.tag!('domain:exDate', @domain.valid_to.iso8601) diff --git a/app/views/epp/domains/info.xml.builder b/app/views/epp/domains/info.xml.builder index d1695f20c..e836265d7 100644 --- a/app/views/epp/domains/info.xml.builder +++ b/app/views/epp/domains/info.xml.builder @@ -5,7 +5,8 @@ xml.epp_head do end xml.resData do - xml.tag! 'domain:infData', 'xmlns:domain' => Xsd::Schema.filename(for_prefix: 'domain-ee') do + xml.tag! 'domain:infData', + 'xmlns:domain' => Xsd::Schema.filename(for_prefix: @schema_prefix) do xml.tag!('domain:name', @domain.name) xml.tag!('domain:roid', @domain.roid) @domain.statuses.each do |s| diff --git a/app/views/epp/domains/renew.xml.builder b/app/views/epp/domains/renew.xml.builder index 91fdbf1c9..4b7b64cdd 100644 --- a/app/views/epp/domains/renew.xml.builder +++ b/app/views/epp/domains/renew.xml.builder @@ -5,7 +5,8 @@ xml.epp_head do end xml.resData do - xml.tag!('domain:renData', 'xmlns:domain' => Xsd::Schema.filename(for_prefix: 'domain-ee')) do + xml.tag!('domain:renData', + 'xmlns:domain' => Xsd::Schema.filename(for_prefix: @schema_prefix)) do xml.tag!('domain:name', @domain[:name]) xml.tag!('domain:exDate', @domain.valid_to.iso8601) end diff --git a/test/integration/epp/domain/info/base_test.rb b/test/integration/epp/domain/info/base_test.rb index dd54e651e..5462f8f86 100644 --- a/test/integration/epp/domain/info/base_test.rb +++ b/test/integration/epp/domain/info/base_test.rb @@ -77,12 +77,12 @@ class EppDomainInfoBaseTest < EppTestCase post epp_info_path, params: { frame: request_xml }, headers: { 'HTTP_COOKIE' => 'session=api_bestnames' } - response_xml = Nokogiri::XML(response.body) assert_epp_response :completed_successfully - schema = EPP_ALL_SCHEMA - schema_validation_errors = schema.validate(response_xml) - assert_equal 0, schema_validation_errors.size + res = parsing_schemas_prefix_and_version(response.body) + + assert_equal res[:prefix], 'domain-eis' + assert_equal res[:version], '1.0' end def test_returns_valid_response_if_disputed diff --git a/test/test_helper.rb b/test/test_helper.rb index 16eda7fc3..efdd982ce 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -95,4 +95,10 @@ class EppTestCase < ActionDispatch::IntegrationTest raise Exception.new('Wrong prefix') end end + + # The prefix and version of the response are returned are these variants - res[:prefix] res[:version] + def parsing_schemas_prefix_and_version(response) + xml = response.gsub!(/(?<=>)(.*?)(?=<)/, &:strip) + xml.to_s.match(/xmlns:domain=\"https:\/\/epp.tld.ee\/schema\/(?\w+-\w+)-(?\w.\w).xsd/) + end end