diff --git a/Gemfile b/Gemfile index 5bcbd2bec..bd4bef176 100644 --- a/Gemfile +++ b/Gemfile @@ -62,7 +62,7 @@ gem 'omniauth-tara', github: 'internetee/omniauth-tara' gem 'epp', github: 'internetee/epp', branch: :master -gem 'epp-xml', '1.1.0', github: 'internetee/epp-xml' +gem 'epp-xml', '1.2.0', github: 'internetee/epp-xml', branch: :master gem 'que' gem 'daemons-rails', '1.2.1' gem 'que-web' diff --git a/Gemfile.lock b/Gemfile.lock index ecdb4605e..e24bae2f2 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -28,9 +28,10 @@ GIT GIT remote: https://github.com/internetee/epp-xml.git - revision: 27959f8cb244ea5eabaeeee747984988b454e840 + revision: cab8ba4d07b16e664b8ae6d3c6a6821e89a48b78 + branch: master specs: - epp-xml (1.1.0) + epp-xml (1.2.0) activesupport (>= 4.1) builder (~> 3.2) @@ -532,7 +533,7 @@ DEPENDENCIES domain_name e_invoice! epp! - epp-xml (= 1.1.0)! + epp-xml (= 1.2.0)! figaro (~> 1.2) haml (~> 5.0) isikukood @@ -575,4 +576,4 @@ DEPENDENCIES wkhtmltopdf-binary (~> 0.12.5.1) BUNDLED WITH - 2.2.17 + 2.2.20 diff --git a/app/controllers/epp/base_controller.rb b/app/controllers/epp/base_controller.rb index 3230d3e70..4e9c7e9cf 100644 --- a/app/controllers/epp/base_controller.rb +++ b/app/controllers/epp/base_controller.rb @@ -127,6 +127,7 @@ module Epp # VALIDATION def validate_request validation_method = "validate_#{params[:action]}" + return unless respond_to?(validation_method, true) send(validation_method) diff --git a/app/controllers/epp/errors_controller.rb b/app/controllers/epp/errors_controller.rb index ab2e00b75..da1e27a9e 100644 --- a/app/controllers/epp/errors_controller.rb +++ b/app/controllers/epp/errors_controller.rb @@ -11,5 +11,10 @@ module Epp epp_errors.add(:epp_errors, code: '2000', msg: 'Unknown command') render_epp_response '/epp/error' end + + def wrong_schema + epp_errors.add(:epp_errors, code: '2100', msg: 'Wrong path') + render_epp_response '/epp/error' + end end end diff --git a/app/controllers/registrar/xml_consoles_controller.rb b/app/controllers/registrar/xml_consoles_controller.rb index b07b9cbee..fef6b33ad 100644 --- a/app/controllers/registrar/xml_consoles_controller.rb +++ b/app/controllers/registrar/xml_consoles_controller.rb @@ -1,14 +1,20 @@ class Registrar class XmlConsolesController < DeppController + PREFS = %w[ + domain-ee + contact-ee + eis + epp-ee + ].freeze + authorize_resource class: false - def show - end + def show; end def create begin @result = depp_current_user.server.request(params[:payload]) - rescue + rescue StandardError @result = 'CONNECTION ERROR - Is the EPP server running?' end render :show @@ -18,8 +24,21 @@ class Registrar cl_trid = "#{depp_current_user.tag}-#{Time.zone.now.to_i}" xml_dir_path = Rails.root + 'app/views/registrar/xml_consoles/epp_requests' xml = File.read("#{xml_dir_path}/#{params[:obj]}/#{params[:epp_action]}.xml") - xml.gsub!('ABC-12345', "#{cl_trid}") + xml = prepare_payload(xml, cl_trid) + render plain: xml end + + protected + + def prepare_payload(xml, cl_trid) + PREFS.map do |pref| + xml.gsub!('"' + pref.to_s + '"', + "\"#{Xsd::Schema.filename(for_prefix: pref.to_s)}\"") + end + + xml.gsub!('ABC-12345', "#{cl_trid}") + xml + end end end diff --git a/app/models/depp/domain.rb b/app/models/depp/domain.rb index 3bb3b7473..f9e065241 100644 --- a/app/models/depp/domain.rb +++ b/app/models/depp/domain.rb @@ -6,13 +6,13 @@ module Depp attr_accessor :name, :current_user, :epp_xml - STATUSES = %w( + STATUSES = %w[ clientDeleteProhibited clientHold clientRenewProhibited clientTransferProhibited clientUpdateProhibited - ) + ].freeze PERIODS = [ ['3 months', '3m'], @@ -28,11 +28,15 @@ module Depp ['8 years', '8y'], ['9 years', '9y'], ['10 years', '10y'], - ] + ].freeze def initialize(args = {}) self.current_user = args[:current_user] - self.epp_xml = EppXml::Domain.new(cl_trid_prefix: current_user.tag) + self.epp_xml = EppXml::Domain.new( + cl_trid_prefix: current_user.tag, + schema_prefix: 'domain-ee', + schema_version: '1.1' + ) end def info(domain_name) @@ -49,6 +53,11 @@ module Depp current_user.request(xml) end + def hostname_present + domain_params[:nameservers_attributes] + .select { |_key, value| value['hostname'].present? }.any? + end + def create(domain_params) dns_hash = {} keys = Domain.create_dnskeys_hash(domain_params) @@ -57,22 +66,22 @@ module Depp period = domain_params[:period].to_i.to_s period_unit = domain_params[:period][-1].to_s - if domain_params[:nameservers_attributes].select { |key, value| value['hostname'].present? }.any? - xml = epp_xml.create({ - name: { value: domain_params[:name] }, - period: { value: period, attrs: { unit: period_unit } }, - ns: Domain.create_nameservers_hash(domain_params), - registrant: { value: domain_params[:registrant] }, - _anonymus: Domain.create_contacts_hash(domain_params) - }, dns_hash, Domain.construct_custom_params_hash(domain_params)) - else - xml = epp_xml.create({ - name: { value: domain_params[:name] }, - period: { value: period, attrs: { unit: period_unit } }, - registrant: { value: domain_params[:registrant] }, - _anonymus: Domain.create_contacts_hash(domain_params) - }, dns_hash, Domain.construct_custom_params_hash(domain_params)) - end + xml = if hostname_present + epp_xml.create({ + name: { value: domain_params[:name] }, + period: { value: period, attrs: { unit: period_unit } }, + ns: Domain.create_nameservers_hash(domain_params), + registrant: { value: domain_params[:registrant] }, + _anonymus: Domain.create_contacts_hash(domain_params) + }, dns_hash, Domain.construct_custom_params_hash(domain_params)) + else + epp_xml.create({ + name: { value: domain_params[:name] }, + period: { value: period, attrs: { unit: period_unit } }, + registrant: { value: domain_params[:registrant] }, + _anonymus: Domain.create_contacts_hash(domain_params) + }, dns_hash, Domain.construct_custom_params_hash(domain_params)) + end current_user.request(xml) end @@ -92,9 +101,10 @@ module Depp def delete(domain_params) xml = epp_xml.delete({ - name: { value: domain_params[:name] }}, - Depp::Domain.construct_custom_params_hash(domain_params), - (domain_params[:verified].present? && 'yes')) + name: { value: domain_params[:name] }, + }, + Depp::Domain.construct_custom_params_hash(domain_params), + (domain_params[:verified].present? && 'yes')) current_user.request(xml) end @@ -104,10 +114,10 @@ module Depp period_unit = params[:period][-1].to_s current_user.request(epp_xml.renew( - name: { value: params[:domain_name] }, - curExpDate: { value: params[:cur_exp_date] }, - period: { value: period, attrs: { unit: period_unit } } - )) + name: { value: params[:domain_name] }, + curExpDate: { value: params[:cur_exp_date] }, + period: { value: period, attrs: { unit: period_unit } } + )) end def transfer(params) @@ -117,9 +127,9 @@ module Depp op = params[:reject] ? 'reject' : op current_user.request(epp_xml.transfer({ - name: { value: params[:domain_name] }, - authInfo: { pw: { value: params[:transfer_code] } } - }, op, Domain.construct_custom_params_hash(params))) + name: { value: params[:domain_name] }, + authInfo: { pw: { value: params[:transfer_code] } } + }, op, Domain.construct_custom_params_hash(params))) end def confirm_transfer(domain_params) @@ -127,9 +137,9 @@ module Depp pw = data.css('pw').text xml = epp_xml.transfer({ - name: { value: domain_params[:name] }, - authInfo: { pw: { value: pw } } - }, 'approve') + name: { value: domain_params[:name] }, + authInfo: { pw: { value: pw } } + }, 'approve') current_user.request(xml) end @@ -171,24 +181,25 @@ module Depp hostname: x.css('hostName').text, ipv4: Array(x.css('hostAddr[ip="v4"]')).map(&:text).join(','), ipv6: Array(x.css('hostAddr[ip="v6"]')).map(&:text).join(',') - } + } end data.css('keyData').each_with_index do |x, i| ret[:dnskeys_attributes][i] = { - flags: x.css('flags').text, - protocol: x.css('protocol').text, - alg: x.css('alg').text, - public_key: x.css('pubKey').text, - ds_key_tag: x.css('keyTag').first.try(:text), - ds_alg: x.css('alg').first.try(:text), - ds_digest_type: x.css('digestType').first.try(:text), - ds_digest: x.css('digest').first.try(:text) + flags: x.css('flags').text, + protocol: x.css('protocol').text, + alg: x.css('alg').text, + public_key: x.css('pubKey').text, + ds_key_tag: x.css('keyTag').first.try(:text), + ds_alg: x.css('alg').first.try(:text), + ds_digest_type: x.css('digestType').first.try(:text), + ds_digest: x.css('digest').first.try(:text) } end data.css('status').each_with_index do |x, i| next unless STATUSES.include?(x['s']) + ret[:statuses_attributes][i] = { code: x['s'], description: x.text @@ -203,7 +214,7 @@ module Depp if domain_params[:legal_document].present? type = domain_params[:legal_document].original_filename.split('.').last.downcase custom_params[:_anonymus] << { - legalDocument: { value: Base64.encode64(domain_params[:legal_document].read), attrs: { type: type } } + legalDocument: { value: Base64.encode64(domain_params[:legal_document].read), attrs: { type: type } } } end @@ -231,9 +242,12 @@ module Depp rem_arr << { ns: rem_ns } if rem_ns.any? rem_arr << { _anonymus: rem_anon } if rem_anon.any? - if domain_params[:registrant] != old_domain_params[:registrant] - chg = [{ registrant: { value: domain_params[:registrant] } }] if !domain_params[:verified].present? - chg = [{ registrant: { value: domain_params[:registrant], attrs: { verified: 'yes' } } }] if domain_params[:verified] + return if domain_params[:registrant] == old_domain_params[:registrant] + + chg = [{ registrant: { value: domain_params[:registrant] } }] + if domain_params[:verified].blank? && (domain_params[:verified]) + chg = [{ registrant: { value: domain_params[:registrant], + attrs: { verified: 'yes' } } }] end add_arr = nil if add_arr.none? @@ -263,13 +277,17 @@ module Depp host_attr = [] host_attr << { hostName: { value: v['hostname'] } } - v['ipv4'].to_s.split(",").each do |ip| - host_attr << { hostAddr: { value: ip, attrs: { ip: 'v4' } } } - end if v['ipv4'].present? + if v['ipv4'].present? + v['ipv4'].to_s.split(',').each do |ip| + host_attr << { hostAddr: { value: ip, attrs: { ip: 'v4' } } } + end + end - v['ipv6'].to_s.split(",").each do |ip| - host_attr << { hostAddr: { value: ip, attrs: { ip: 'v6' } } } - end if v['ipv6'].present? + if v['ipv6'].present? + v['ipv6'].to_s.split(',').each do |ip| + host_attr << { hostAddr: { value: ip, attrs: { ip: 'v6' } } } + end + end ret << { hostAttr: host_attr } end @@ -281,6 +299,7 @@ module Depp ret = [] domain_params[:contacts_attributes].each do |_k, v| next if v['code'].blank? + ret << { contact: { value: v['code'], attrs: { type: v['type'] } } } @@ -294,9 +313,11 @@ module Depp domain_params[:dnskeys_attributes].each do |_k, v| if v['ds_key_tag'].blank? kd = create_key_data_hash(v) - ret << { - keyData: kd - } if kd + if kd + ret << { + keyData: kd + } + end else ret << { dsData: [ @@ -315,6 +336,7 @@ module Depp def create_key_data_hash(key_data_params) return nil if key_data_params['public_key'].blank? + { flags: { value: key_data_params['flags'] }, protocol: { value: key_data_params['protocol'] }, @@ -331,6 +353,6 @@ module Depp end ret end - end + end end end diff --git a/app/models/epp/response/result/code.rb b/app/models/epp/response/result/code.rb index 10edf0a35..f2b1ccd3b 100644 --- a/app/models/epp/response/result/code.rb +++ b/app/models/epp/response/result/code.rb @@ -17,6 +17,7 @@ module Epp required_parameter_missing: 2003, parameter_value_range_error: 2004, parameter_value_syntax_error: 2005, + wrong_schema: 2100, unimplemented: 2101, billing_failure: 2104, object_is_not_eligible_for_renewal: 2105, @@ -47,6 +48,7 @@ module Epp 2003 => 'Required parameter missing', 2004 => 'Parameter value range error', 2005 => 'Parameter value syntax error', + 2100 => 'Wrong schema', 2101 => 'Unimplemented command', 2104 => 'Billing failure', 2105 => 'Object is not eligible for renewal', @@ -79,6 +81,7 @@ module Epp def initialize(value) value = value.to_i raise ArgumentError, "Invalid value: #{value}" unless KEY_TO_VALUE.value?(value) + @value = value end diff --git a/app/views/epp/domains/check.xml.builder b/app/views/epp/domains/check.xml.builder index f6f2fe831..7816ac909 100644 --- a/app/views/epp/domains/check.xml.builder +++ b/app/views/epp/domains/check.xml.builder @@ -5,7 +5,7 @@ xml.epp_head do end xml.resData do - xml.tag!('domain:chkData', 'xmlns:domain' => Xsd::Schema.filename(for_prefix: 'domain-eis')) do + xml.tag!('domain:chkData', 'xmlns:domain' => Xsd::Schema.filename(for_prefix: 'domain-ee')) 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 e4f4d969b..7a907c4b7 100644 --- a/app/views/epp/domains/create.xml.builder +++ b/app/views/epp/domains/create.xml.builder @@ -5,7 +5,7 @@ xml.epp_head do end xml.resData do - xml.tag!('domain:creData', 'xmlns:domain' => Xsd::Schema.filename(for_prefix: 'domain-eis')) do + xml.tag!('domain:creData', 'xmlns:domain' => Xsd::Schema.filename(for_prefix: 'domain-ee')) 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 a2079dbce..492248958 100644 --- a/app/views/epp/domains/info.xml.builder +++ b/app/views/epp/domains/info.xml.builder @@ -5,7 +5,7 @@ xml.epp_head do end xml.resData do - xml.tag! 'domain:infData', 'xmlns:domain' => Xsd::Schema.filename(for_prefix: 'domain-eis') do + xml.tag! 'domain:infData', 'xmlns:domain' => Xsd::Schema.filename(for_prefix: 'domain-ee') 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/partials/_transfer.xml.builder b/app/views/epp/domains/partials/_transfer.xml.builder index 4e1569908..e9de73ce3 100644 --- a/app/views/epp/domains/partials/_transfer.xml.builder +++ b/app/views/epp/domains/partials/_transfer.xml.builder @@ -1,4 +1,4 @@ -builder.tag!('domain:trnData', 'xmlns:domain' => Xsd::Schema.filename(for_prefix: 'domain-eis')) do +builder.tag!('domain:trnData', 'xmlns:domain' => Xsd::Schema.filename(for_prefix: 'domain-ee')) do builder.tag!('domain:name', dt.domain_name) builder.tag!('domain:trStatus', dt.status) builder.tag!('domain:reID', dt.new_registrar.code) diff --git a/app/views/epp/domains/renew.xml.builder b/app/views/epp/domains/renew.xml.builder index 89a939af5..91fdbf1c9 100644 --- a/app/views/epp/domains/renew.xml.builder +++ b/app/views/epp/domains/renew.xml.builder @@ -5,7 +5,7 @@ xml.epp_head do end xml.resData do - xml.tag!('domain:renData', 'xmlns:domain' => Xsd::Schema.filename(for_prefix: 'domain-eis')) do + xml.tag!('domain:renData', 'xmlns:domain' => Xsd::Schema.filename(for_prefix: 'domain-ee')) do xml.tag!('domain:name', @domain[:name]) xml.tag!('domain:exDate', @domain.valid_to.iso8601) end diff --git a/app/views/epp/error.xml.builder b/app/views/epp/error.xml.builder index f906a7e04..609c323ff 100644 --- a/app/views/epp/error.xml.builder +++ b/app/views/epp/error.xml.builder @@ -7,7 +7,7 @@ xml.epp_head do xml.result('code' => x[:code]) do xml.msg(x[:msg], 'lang' => 'en') model_name = resource ? resource.model_name.singular.sub('epp_','') : controller.controller_name.singularize - prefix = model_name == 'poll' ? 'changePoll' : model_name + '-eis' + prefix = model_name == 'poll' ? 'changePoll' : model_name + '-ee' xml.value("xmlns:#{model_name}" => Xsd::Schema.filename(for_prefix: prefix)) do value = x[:value][:val] diff --git a/app/views/epp/sessions/greeting.xml.builder b/app/views/epp/sessions/greeting.xml.builder index c1461f2e2..054307652 100644 --- a/app/views/epp/sessions/greeting.xml.builder +++ b/app/views/epp/sessions/greeting.xml.builder @@ -5,7 +5,7 @@ xml.epp_head do xml.svcMenu do xml.version '1.0' xml.lang 'en' - xml.objURI Xsd::Schema.filename(for_prefix: 'domain-eis') + xml.objURI Xsd::Schema.filename(for_prefix: 'domain-ee') xml.objURI Xsd::Schema.filename(for_prefix: 'contact-ee') xml.objURI 'urn:ietf:params:xml:ns:host-1.0' xml.svcExtension do diff --git a/app/views/registrar/xml_consoles/epp_requests/contact/check.xml b/app/views/registrar/xml_consoles/epp_requests/contact/check.xml index f8d6e05ce..f4c10d8bd 100644 --- a/app/views/registrar/xml_consoles/epp_requests/contact/check.xml +++ b/app/views/registrar/xml_consoles/epp_requests/contact/check.xml @@ -1,9 +1,9 @@ - + + xmlns:contact="contact-ee"> sh8013 diff --git a/app/views/registrar/xml_consoles/epp_requests/contact/check_multiple.xml b/app/views/registrar/xml_consoles/epp_requests/contact/check_multiple.xml index b71871ed1..bdcff03dd 100644 --- a/app/views/registrar/xml_consoles/epp_requests/contact/check_multiple.xml +++ b/app/views/registrar/xml_consoles/epp_requests/contact/check_multiple.xml @@ -1,9 +1,9 @@ - + + xmlns:contact="contact-ee"> sh8013 sh13 vsdfvq diff --git a/app/views/registrar/xml_consoles/epp_requests/contact/create.xml b/app/views/registrar/xml_consoles/epp_requests/contact/create.xml index 2607a7582..fc60b8311 100644 --- a/app/views/registrar/xml_consoles/epp_requests/contact/create.xml +++ b/app/views/registrar/xml_consoles/epp_requests/contact/create.xml @@ -1,8 +1,8 @@ - + - + Sillius Soddus @@ -20,7 +20,7 @@ - + 123 dGVzdCBmYWlsCg== diff --git a/app/views/registrar/xml_consoles/epp_requests/contact/delete.xml b/app/views/registrar/xml_consoles/epp_requests/contact/delete.xml index 2d2e483a2..28b50af64 100644 --- a/app/views/registrar/xml_consoles/epp_requests/contact/delete.xml +++ b/app/views/registrar/xml_consoles/epp_requests/contact/delete.xml @@ -1,9 +1,9 @@ - + + xmlns:contact="contact-ee"> sh8013 wrong-one @@ -11,7 +11,7 @@ - + dGVzdCBmYWlsCg== diff --git a/app/views/registrar/xml_consoles/epp_requests/contact/info.xml b/app/views/registrar/xml_consoles/epp_requests/contact/info.xml index 01685a3a1..44e5d5a1e 100644 --- a/app/views/registrar/xml_consoles/epp_requests/contact/info.xml +++ b/app/views/registrar/xml_consoles/epp_requests/contact/info.xml @@ -1,8 +1,8 @@ - + - + sh8013 Aas34fq diff --git a/app/views/registrar/xml_consoles/epp_requests/contact/update_chg.xml b/app/views/registrar/xml_consoles/epp_requests/contact/update_chg.xml index e7fa45dde..61ea43202 100644 --- a/app/views/registrar/xml_consoles/epp_requests/contact/update_chg.xml +++ b/app/views/registrar/xml_consoles/epp_requests/contact/update_chg.xml @@ -1,8 +1,8 @@ - + - + sh8013 @@ -25,7 +25,7 @@ - + dGVzdCBmYWlsCg== diff --git a/app/views/registrar/xml_consoles/epp_requests/domain/check.xml b/app/views/registrar/xml_consoles/epp_requests/domain/check.xml index 4c03654cd..06492bcfe 100644 --- a/app/views/registrar/xml_consoles/epp_requests/domain/check.xml +++ b/app/views/registrar/xml_consoles/epp_requests/domain/check.xml @@ -1,9 +1,9 @@ - + + xmlns:domain="domain-ee"> example.ee diff --git a/app/views/registrar/xml_consoles/epp_requests/domain/client_hold.xml b/app/views/registrar/xml_consoles/epp_requests/domain/client_hold.xml index 31c9c21af..68f0b778e 100644 --- a/app/views/registrar/xml_consoles/epp_requests/domain/client_hold.xml +++ b/app/views/registrar/xml_consoles/epp_requests/domain/client_hold.xml @@ -1,9 +1,9 @@ - + + xmlns:domain="domain-ee"> example.ee diff --git a/app/views/registrar/xml_consoles/epp_requests/domain/create.xml b/app/views/registrar/xml_consoles/epp_requests/domain/create.xml index d962ef259..f57fcfe30 100644 --- a/app/views/registrar/xml_consoles/epp_requests/domain/create.xml +++ b/app/views/registrar/xml_consoles/epp_requests/domain/create.xml @@ -1,9 +1,9 @@ - + + xmlns:domain="domain-ee"> example.ee 1 @@ -31,7 +31,7 @@ AwEAAddt2AkLfYGKgiEZB5SmIF8EvrjxNMH6HtxWEA4RJ9Ao6LCWheg8 - + dGVzdCBmYWlsCg== diff --git a/app/views/registrar/xml_consoles/epp_requests/domain/delete.xml b/app/views/registrar/xml_consoles/epp_requests/domain/delete.xml index f7a004982..f47bb79eb 100644 --- a/app/views/registrar/xml_consoles/epp_requests/domain/delete.xml +++ b/app/views/registrar/xml_consoles/epp_requests/domain/delete.xml @@ -1,14 +1,14 @@ - + + xmlns:domain="domain-ee"> example.ee - + dGVzdCBmYWlsCg== diff --git a/app/views/registrar/xml_consoles/epp_requests/domain/info.xml b/app/views/registrar/xml_consoles/epp_requests/domain/info.xml index c79100824..210396c3b 100644 --- a/app/views/registrar/xml_consoles/epp_requests/domain/info.xml +++ b/app/views/registrar/xml_consoles/epp_requests/domain/info.xml @@ -1,9 +1,9 @@ - + + xmlns:domain="domain-ee"> example.ee 2fooBAR diff --git a/app/views/registrar/xml_consoles/epp_requests/domain/renew.xml b/app/views/registrar/xml_consoles/epp_requests/domain/renew.xml index 9993bc1e0..6ef479468 100644 --- a/app/views/registrar/xml_consoles/epp_requests/domain/renew.xml +++ b/app/views/registrar/xml_consoles/epp_requests/domain/renew.xml @@ -1,9 +1,9 @@ - + + xmlns:domain="domain-ee"> example.ee 2014-08-07 1 diff --git a/app/views/registrar/xml_consoles/epp_requests/domain/transfer.xml b/app/views/registrar/xml_consoles/epp_requests/domain/transfer.xml index 7f94ca60e..f6ee87b79 100644 --- a/app/views/registrar/xml_consoles/epp_requests/domain/transfer.xml +++ b/app/views/registrar/xml_consoles/epp_requests/domain/transfer.xml @@ -1,9 +1,9 @@ - + + xmlns:domain="domain-ee"> example.ee 2BARfoo @@ -11,7 +11,7 @@ - + dGVzdCBmYWlsCg== diff --git a/app/views/registrar/xml_consoles/epp_requests/domain/update.xml b/app/views/registrar/xml_consoles/epp_requests/domain/update.xml index 3318a7e51..c087245e7 100644 --- a/app/views/registrar/xml_consoles/epp_requests/domain/update.xml +++ b/app/views/registrar/xml_consoles/epp_requests/domain/update.xml @@ -1,9 +1,9 @@ - + + xmlns:domain="domain-ee"> example.ee @@ -43,7 +43,7 @@ - + dGVzdCBmYWlsCg== diff --git a/app/views/registrar/xml_consoles/epp_requests/poll/poll.xml b/app/views/registrar/xml_consoles/epp_requests/poll/poll.xml index abf77ae19..5ffed010e 100644 --- a/app/views/registrar/xml_consoles/epp_requests/poll/poll.xml +++ b/app/views/registrar/xml_consoles/epp_requests/poll/poll.xml @@ -1,5 +1,5 @@ - + ABC-12345 diff --git a/config/initializers/load_schemas.rb b/config/initializers/load_schemas.rb index fa0150896..1f34d58df 100644 --- a/config/initializers/load_schemas.rb +++ b/config/initializers/load_schemas.rb @@ -1 +1 @@ -EPP_ALL_SCHEMA = Nokogiri::XML::Schema(File.read('lib/schemas/all-ee-1.1.xsd')) +EPP_ALL_SCHEMA = Nokogiri::XML::Schema(File.read('lib/schemas/all-ee-1.2.xsd')) diff --git a/config/routes.rb b/config/routes.rb index 43cced0a0..0db226cf1 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -34,6 +34,18 @@ Rails.application.routes.draw do end end + constraints(EppConstraint.new(:error)) do + controller('errors') do + post 'command/create', to: 'errors#wrong_schema' + post 'command/update', to: 'errors#wrong_schema' + post 'command/info', to: 'errors#wrong_schema' + post 'command/check', to: 'errors#wrong_schema' + post 'command/transfer', to: 'errors#wrong_schema' + post 'command/renew', to: 'errors#wrong_schema' + post 'command/delete', to: 'errors#wrong_schema' + end + end + post 'command/poll', to: 'polls#poll', as: 'poll', constraints: EppConstraint.new(:poll) get 'error/:command', to: 'errors#error' get 'error', to: 'errors#command_handler' diff --git a/lib/epp_constraint.rb b/lib/epp_constraint.rb index 1720d3202..122be7593 100644 --- a/lib/epp_constraint.rb +++ b/lib/epp_constraint.rb @@ -1,6 +1,9 @@ class EppConstraint OBJECT_TYPES = { - domain: { domain: Xsd::Schema.filename(for_prefix: 'domain-eis') }, + domain: [ + { domain: Xsd::Schema.filename(for_prefix: 'domain-ee') }, + { domain: Xsd::Schema.filename(for_prefix: 'domain-eis') }, + ], contact: { contact: Xsd::Schema.filename(for_prefix: 'contact-ee') }, }.freeze @@ -11,16 +14,45 @@ class EppConstraint # creates parsed_frame, detects epp request object def matches?(request) # TODO: Maybe move this to controller to keep params clean - request.params[:raw_frame] = request.params[:raw_frame].gsub!(/(?<=>)(.*?)(?=<)/) { |s| s.strip} if request.params[:raw_frame] - request.params[:nokogiri_frame] ||= Nokogiri::XML(request.params[:raw_frame] || request.params[:frame]) - request.params[:parsed_frame] ||= request.params[:nokogiri_frame].dup.remove_namespaces! + return redirect_to_error_controller(request) if request.params[:action] == 'wrong_schema' + + request = parse_raw_frame(request) if request.params[:raw_frame] + + request = parse_params(request) unless %i[poll session].include?(@type) element = "//#{@type}:#{request.params[:action]}" - return false if request.params[:nokogiri_frame].xpath("#{element}", OBJECT_TYPES[@type]).none? + + return enumerate_domain_object(request, element) if @type == :domain + + return false if request.params[:nokogiri_frame].xpath(element.to_s, OBJECT_TYPES[@type]).none? end request.params[:epp_object_type] = @type true end + + def parse_raw_frame(request) + request.params[:raw_frame] = request.params[:raw_frame].gsub!(/(?<=>)(.*?)(?=<)/, &:strip) + request + end + + def enumerate_domain_object(request, element) + OBJECT_TYPES[@type].each do |obj| + return true unless request.params[:nokogiri_frame].xpath(element.to_s, obj).none? + end + false + end + + def parse_params(request) + request.params[:nokogiri_frame] ||= Nokogiri::XML(request.params[:raw_frame] || request.params[:frame]) + request.params[:parsed_frame] ||= request.params[:nokogiri_frame].dup.remove_namespaces! + + request + end + + def redirect_to_error_controller(request) + request.params[:epp_object_type] = @error + true + end end diff --git a/lib/schemas/all-ee-1.2.xsd b/lib/schemas/all-ee-1.2.xsd new file mode 100644 index 000000000..5d9e3652a --- /dev/null +++ b/lib/schemas/all-ee-1.2.xsd @@ -0,0 +1,43 @@ + + + + + + + + + + + + + + + + + + + Extensible Provisioning Protocol v1.0 + all schema's grouped together + + + + diff --git a/lib/schemas/domain-ee-1.1.xsd b/lib/schemas/domain-ee-1.1.xsd new file mode 100644 index 000000000..073986ac7 --- /dev/null +++ b/lib/schemas/domain-ee-1.1.xsd @@ -0,0 +1,472 @@ + + + + + + + + + + + + + + Extensible Provisioning Protocol v1.0 + domain provisioning schema. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/lib/xsd/schema.rb b/lib/xsd/schema.rb index 12a0cd6d9..2ac57fb3a 100644 --- a/lib/xsd/schema.rb +++ b/lib/xsd/schema.rb @@ -3,6 +3,22 @@ module Xsd SCHEMA_PATH = 'lib/schemas/'.freeze BASE_URL = 'https://epp.tld.ee/schema/'.freeze + PREFIXES = %w[ + domain-ee + domain-eis + all-ee + changePoll + contact + contact-ee + contact-eis + eis + epp + epp-ee + eppcom + host + secDNS + ].freeze + attr_reader :xsd_schemas, :for_prefix def initialize(params) diff --git a/test/integration/admin_area/domain_update_confirms_test.rb b/test/integration/admin_area/domain_update_confirms_test.rb index bf504983b..5d26a004a 100644 --- a/test/integration/admin_area/domain_update_confirms_test.rb +++ b/test/integration/admin_area/domain_update_confirms_test.rb @@ -18,7 +18,7 @@ class AdminAreaBlockedDomainsIntegrationTest < JavaScriptApplicationSystemTestCa - + #{@domain.name} #{new_registrant.code} @@ -53,7 +53,7 @@ class AdminAreaBlockedDomainsIntegrationTest < JavaScriptApplicationSystemTestCa - + #{@domain.name} #{new_registrant.code} diff --git a/test/integration/epp/base_test.rb b/test/integration/epp/base_test.rb index 51f1f37a9..56ea3f2e8 100644 --- a/test/integration/epp/base_test.rb +++ b/test/integration/epp/base_test.rb @@ -18,25 +18,44 @@ class EppBaseTest < EppTestCase def test_internal_error Rails.application.routes.draw do post 'epp/command/internal_error', to: 'dummy_epp#internal_error', - constraints: EppConstraint.new(:poll) + constraints: EppConstraint.new(:poll) end begin assert_difference 'ApiLog::EppLog.count' do post '/epp/command/internal_error', params: { frame: valid_request_xml }, - headers: { 'HTTP_COOKIE' => 'session=api_bestnames' } + headers: { 'HTTP_COOKIE' => 'session=api_bestnames' } end assert_epp_response :command_failed - rescue + rescue StandardError raise ensure Rails.application.reload_routes! end end + def test_wrong_path_xml + wrong_path_xml = <<-XML + + + + + + #{domains(:shop).name} + + + + + XML + post epp_info_path, params: { frame: wrong_path_xml }, + headers: { 'HTTP_COOKIE' => 'session=api_bestnames' } + + assert_epp_response :wrong_schema + end + def test_additional_error get '/epp/error', params: { frame: valid_request_xml }, - headers: { 'HTTP_COOKIE' => 'session=api_bestnames' } + headers: { 'HTTP_COOKIE' => 'session=api_bestnames' } assert_epp_response :unknown_command end @@ -49,7 +68,7 @@ class EppBaseTest < EppTestCase XML get '/epp/error', params: { frame: invalid_xml }, - headers: { 'HTTP_COOKIE' => 'session=api_bestnames' } + headers: { 'HTTP_COOKIE' => 'session=api_bestnames' } assert_epp_response :unknown_command end @@ -61,7 +80,7 @@ class EppBaseTest < EppTestCase XML post valid_command_path, params: { frame: invalid_xml }, - headers: { 'HTTP_COOKIE' => 'session=api_bestnames' } + headers: { 'HTTP_COOKIE' => 'session=api_bestnames' } assert_epp_response :required_parameter_missing end @@ -72,7 +91,7 @@ class EppBaseTest < EppTestCase - + #{domains(:shop).name} @@ -80,7 +99,7 @@ class EppBaseTest < EppTestCase XML post epp_info_path, params: { frame: xml_of_epp_command_that_requires_authentication }, - headers: { 'HTTP_COOKIE' => 'session=non-existent' } + headers: { 'HTTP_COOKIE' => 'session=non-existent' } assert_epp_response :authorization_error end @@ -96,7 +115,7 @@ class EppBaseTest < EppTestCase - + #{domains(:shop).name} @@ -104,7 +123,7 @@ class EppBaseTest < EppTestCase XML post epp_info_path, params: { frame: xml_of_epp_command_that_requires_authorization }, - headers: { 'HTTP_COOKIE' => "session=#{session.session_id}" } + headers: { 'HTTP_COOKIE' => "session=#{session.session_id}" } assert_epp_response :authorization_error end @@ -122,7 +141,7 @@ class EppBaseTest < EppTestCase - + #{domains(:shop).name} @@ -130,7 +149,7 @@ class EppBaseTest < EppTestCase XML post '/epp/command/info', params: { frame: authentication_enabled_epp_request_xml }, - headers: { 'HTTP_COOKIE' => "session=#{session.session_id}" } + headers: { 'HTTP_COOKIE' => "session=#{session.session_id}" } assert_epp_response :authorization_error assert_nil EppSession.find_by(session_id: session.session_id) @@ -149,7 +168,7 @@ class EppBaseTest < EppTestCase - + #{domains(:shop).name} @@ -158,7 +177,7 @@ class EppBaseTest < EppTestCase XML post '/epp/command/info', params: { frame: authentication_enabled_epp_request_xml }, - headers: { 'HTTP_COOKIE' => "session=#{session.session_id}" } + headers: { 'HTTP_COOKIE' => "session=#{session.session_id}" } session.reload diff --git a/test/integration/epp/domain/base_test.rb b/test/integration/epp/domain/base_test.rb index c13f49eef..e8c905062 100644 --- a/test/integration/epp/domain/base_test.rb +++ b/test/integration/epp/domain/base_test.rb @@ -7,7 +7,7 @@ class EppDomainBaseTest < EppTestCase - + non-existent.test @@ -15,8 +15,27 @@ class EppDomainBaseTest < EppTestCase XML post epp_info_path, params: { frame: request_xml }, - headers: { 'HTTP_COOKIE' => 'session=api_bestnames' } + headers: { 'HTTP_COOKIE' => 'session=api_bestnames' } assert_epp_response :object_does_not_exist end + + def test_invalid_path + request_xml = <<-XML + + + + + + non-existent.test + + + + + XML + post epp_info_path, params: { frame: request_xml }, + headers: { 'HTTP_COOKIE' => 'session=api_bestnames' } + + assert_epp_response :wrong_schema + end end diff --git a/test/integration/epp/domain/check/auction_test.rb b/test/integration/epp/domain/check/auction_test.rb index 3447016e3..ece849b00 100644 --- a/test/integration/epp/domain/check/auction_test.rb +++ b/test/integration/epp/domain/check/auction_test.rb @@ -20,7 +20,7 @@ class EppDomainCheckAuctionTest < EppTestCase - + auction.test @@ -33,8 +33,8 @@ class EppDomainCheckAuctionTest < EppTestCase response_xml = Nokogiri::XML(response.body) assert_epp_response :completed_successfully - assert_equal '0', response_xml.at_xpath('//domain:name', 'domain' => "#{Xsd::Schema.filename(for_prefix: 'domain-eis')}")['avail'] - assert_equal 'Domain is at auction', response_xml.at_xpath('//domain:reason', 'domain' => "#{Xsd::Schema.filename(for_prefix: 'domain-eis')}").text + assert_equal '0', response_xml.at_xpath('//domain:name', 'domain' => "#{Xsd::Schema.filename(for_prefix: 'domain-ee')}")['avail'] + assert_equal 'Domain is at auction', response_xml.at_xpath('//domain:reason', 'domain' => "#{Xsd::Schema.filename(for_prefix: 'domain-ee')}").text end def test_idn_ascii_domain_is_unavailable_when_at_auction @@ -45,7 +45,7 @@ class EppDomainCheckAuctionTest < EppTestCase - + xn--pramiid-n2a.test @@ -58,8 +58,8 @@ class EppDomainCheckAuctionTest < EppTestCase response_xml = Nokogiri::XML(response.body) assert_epp_response :completed_successfully - assert_equal '0', response_xml.at_xpath('//domain:name', 'domain' => "#{Xsd::Schema.filename(for_prefix: 'domain-eis')}")['avail'] - assert_equal 'Domain is at auction', response_xml.at_xpath('//domain:reason', 'domain' => "#{Xsd::Schema.filename(for_prefix: 'domain-eis')}").text + assert_equal '0', response_xml.at_xpath('//domain:name', 'domain' => "#{Xsd::Schema.filename(for_prefix: 'domain-ee')}")['avail'] + assert_equal 'Domain is at auction', response_xml.at_xpath('//domain:reason', 'domain' => "#{Xsd::Schema.filename(for_prefix: 'domain-ee')}").text end def test_idn_unicode_domain_is_unavailable_when_at_auction @@ -70,7 +70,7 @@ class EppDomainCheckAuctionTest < EppTestCase - + püramiid.test @@ -83,8 +83,8 @@ class EppDomainCheckAuctionTest < EppTestCase response_xml = Nokogiri::XML(response.body) assert_epp_response :completed_successfully - assert_equal '0', response_xml.at_xpath('//domain:name', 'domain' => "#{Xsd::Schema.filename(for_prefix: 'domain-eis')}")['avail'] - assert_equal 'Domain is at auction', response_xml.at_xpath('//domain:reason', 'domain' => "#{Xsd::Schema.filename(for_prefix: 'domain-eis')}").text + assert_equal '0', response_xml.at_xpath('//domain:name', 'domain' => "#{Xsd::Schema.filename(for_prefix: 'domain-ee')}")['avail'] + assert_equal 'Domain is at auction', response_xml.at_xpath('//domain:reason', 'domain' => "#{Xsd::Schema.filename(for_prefix: 'domain-ee')}").text end def test_domain_is_unavailable_when_awaiting_payment @@ -95,7 +95,7 @@ class EppDomainCheckAuctionTest < EppTestCase - + auction.test @@ -108,8 +108,8 @@ class EppDomainCheckAuctionTest < EppTestCase response_xml = Nokogiri::XML(response.body) assert_epp_response :completed_successfully - assert_equal '0', response_xml.at_xpath('//domain:name', 'domain' => "#{Xsd::Schema.filename(for_prefix: 'domain-eis')}")['avail'] - assert_equal 'Awaiting payment', response_xml.at_xpath('//domain:reason', 'domain' => "#{Xsd::Schema.filename(for_prefix: 'domain-eis')}").text + assert_equal '0', response_xml.at_xpath('//domain:name', 'domain' => "#{Xsd::Schema.filename(for_prefix: 'domain-ee')}")['avail'] + assert_equal 'Awaiting payment', response_xml.at_xpath('//domain:reason', 'domain' => "#{Xsd::Schema.filename(for_prefix: 'domain-ee')}").text end def test_domain_is_available_when_payment_received @@ -120,7 +120,7 @@ class EppDomainCheckAuctionTest < EppTestCase - + auction.test @@ -133,7 +133,7 @@ class EppDomainCheckAuctionTest < EppTestCase response_xml = Nokogiri::XML(response.body) assert_epp_response :completed_successfully - assert_equal '1', response_xml.at_xpath('//domain:name', 'domain' => "#{Xsd::Schema.filename(for_prefix: 'domain-eis')}")['avail'] - assert_nil response_xml.at_xpath('//domain:reason', 'domain' => "#{Xsd::Schema.filename(for_prefix: 'domain-eis')}") + assert_equal '1', response_xml.at_xpath('//domain:name', 'domain' => "#{Xsd::Schema.filename(for_prefix: 'domain-ee')}")['avail'] + assert_nil response_xml.at_xpath('//domain:reason', 'domain' => "#{Xsd::Schema.filename(for_prefix: 'domain-ee')}") end end diff --git a/test/integration/epp/domain/check/base_test.rb b/test/integration/epp/domain/check/base_test.rb index f418fa8a2..07e1e2081 100644 --- a/test/integration/epp/domain/check/base_test.rb +++ b/test/integration/epp/domain/check/base_test.rb @@ -7,7 +7,7 @@ class EppDomainCheckBaseTest < EppTestCase - + some.test @@ -20,7 +20,7 @@ class EppDomainCheckBaseTest < EppTestCase response_xml = Nokogiri::XML(response.body) assert_epp_response :completed_successfully - assert_equal 'some.test', response_xml.at_xpath('//domain:name', 'domain' => "#{Xsd::Schema.filename(for_prefix: 'domain-eis')}").text + assert_equal 'some.test', response_xml.at_xpath('//domain:name', 'domain' => "#{Xsd::Schema.filename(for_prefix: 'domain-ee')}").text end def test_domain_is_available_when_not_registered_or_blocked @@ -29,7 +29,7 @@ class EppDomainCheckBaseTest < EppTestCase - + available.test @@ -41,8 +41,8 @@ class EppDomainCheckBaseTest < EppTestCase headers: { 'HTTP_COOKIE' => 'session=api_bestnames' } response_xml = Nokogiri::XML(response.body) - assert_equal '1', response_xml.at_xpath('//domain:name', 'domain' => "#{Xsd::Schema.filename(for_prefix: 'domain-eis')}")['avail'] - assert_nil response_xml.at_xpath('//domain:reason', 'domain' => "#{Xsd::Schema.filename(for_prefix: 'domain-eis')}") + assert_equal '1', response_xml.at_xpath('//domain:name', 'domain' => "#{Xsd::Schema.filename(for_prefix: 'domain-ee')}")['avail'] + assert_nil response_xml.at_xpath('//domain:reason', 'domain' => "#{Xsd::Schema.filename(for_prefix: 'domain-ee')}") end def test_domain_is_available_when_reserved @@ -53,7 +53,7 @@ class EppDomainCheckBaseTest < EppTestCase - + reserved.test @@ -65,8 +65,8 @@ class EppDomainCheckBaseTest < EppTestCase headers: { 'HTTP_COOKIE' => 'session=api_bestnames' } response_xml = Nokogiri::XML(response.body) - assert_equal '1', response_xml.at_xpath('//domain:name', 'domain' => "#{Xsd::Schema.filename(for_prefix: 'domain-eis')}")['avail'] - assert_nil response_xml.at_xpath('//domain:reason', 'domain' => "#{Xsd::Schema.filename(for_prefix: 'domain-eis')}") + assert_equal '1', response_xml.at_xpath('//domain:name', 'domain' => "#{Xsd::Schema.filename(for_prefix: 'domain-ee')}")['avail'] + assert_nil response_xml.at_xpath('//domain:reason', 'domain' => "#{Xsd::Schema.filename(for_prefix: 'domain-ee')}") end def test_domain_is_unavailable_when_format_is_invalid @@ -75,7 +75,7 @@ class EppDomainCheckBaseTest < EppTestCase - + invalid @@ -87,8 +87,8 @@ class EppDomainCheckBaseTest < EppTestCase headers: { 'HTTP_COOKIE' => 'session=api_bestnames' } response_xml = Nokogiri::XML(response.body) - assert_equal '0', response_xml.at_xpath('//domain:name', 'domain' => "#{Xsd::Schema.filename(for_prefix: 'domain-eis')}")['avail'] - assert_equal 'invalid format', response_xml.at_xpath('//domain:reason', 'domain' => "#{Xsd::Schema.filename(for_prefix: 'domain-eis')}").text + assert_equal '0', response_xml.at_xpath('//domain:name', 'domain' => "#{Xsd::Schema.filename(for_prefix: 'domain-ee')}")['avail'] + assert_equal 'invalid format', response_xml.at_xpath('//domain:reason', 'domain' => "#{Xsd::Schema.filename(for_prefix: 'domain-ee')}").text end def test_domain_is_unavailable_when_registered @@ -99,7 +99,7 @@ class EppDomainCheckBaseTest < EppTestCase - + shop.test @@ -111,8 +111,8 @@ class EppDomainCheckBaseTest < EppTestCase headers: { 'HTTP_COOKIE' => 'session=api_bestnames' } response_xml = Nokogiri::XML(response.body) - assert_equal '0', response_xml.at_xpath('//domain:name', 'domain' => "#{Xsd::Schema.filename(for_prefix: 'domain-eis')}")['avail'] - assert_equal 'in use', response_xml.at_xpath('//domain:reason', 'domain' => "#{Xsd::Schema.filename(for_prefix: 'domain-eis')}").text + assert_equal '0', response_xml.at_xpath('//domain:name', 'domain' => "#{Xsd::Schema.filename(for_prefix: 'domain-ee')}")['avail'] + assert_equal 'in use', response_xml.at_xpath('//domain:reason', 'domain' => "#{Xsd::Schema.filename(for_prefix: 'domain-ee')}").text end def test_domain_is_unavailable_when_blocked @@ -123,7 +123,7 @@ class EppDomainCheckBaseTest < EppTestCase - + blocked.test @@ -135,8 +135,8 @@ class EppDomainCheckBaseTest < EppTestCase headers: { 'HTTP_COOKIE' => 'session=api_bestnames' } response_xml = Nokogiri::XML(response.body) - assert_equal '0', response_xml.at_xpath('//domain:name', 'domain' => "#{Xsd::Schema.filename(for_prefix: 'domain-eis')}")['avail'] - assert_equal 'Blocked', response_xml.at_xpath('//domain:reason', 'domain' => "#{Xsd::Schema.filename(for_prefix: 'domain-eis')}").text + assert_equal '0', response_xml.at_xpath('//domain:name', 'domain' => "#{Xsd::Schema.filename(for_prefix: 'domain-ee')}")['avail'] + assert_equal 'Blocked', response_xml.at_xpath('//domain:reason', 'domain' => "#{Xsd::Schema.filename(for_prefix: 'domain-ee')}").text end def test_domain_is_unavailable_when_zone_with_the_same_origin_exists @@ -147,7 +147,7 @@ class EppDomainCheckBaseTest < EppTestCase - + test @@ -159,8 +159,8 @@ class EppDomainCheckBaseTest < EppTestCase headers: { 'HTTP_COOKIE' => 'session=api_bestnames' } response_xml = Nokogiri::XML(response.body) - assert_equal '0', response_xml.at_xpath('//domain:name', 'domain' => "#{Xsd::Schema.filename(for_prefix: 'domain-eis')}")['avail'] - assert_equal 'Zone with the same origin exists', response_xml.at_xpath('//domain:reason', 'domain' => "#{Xsd::Schema.filename(for_prefix: 'domain-eis')}").text + assert_equal '0', response_xml.at_xpath('//domain:name', 'domain' => "#{Xsd::Schema.filename(for_prefix: 'domain-ee')}")['avail'] + assert_equal 'Zone with the same origin exists', response_xml.at_xpath('//domain:reason', 'domain' => "#{Xsd::Schema.filename(for_prefix: 'domain-ee')}").text end def test_multiple_domains @@ -169,7 +169,7 @@ class EppDomainCheckBaseTest < EppTestCase - + one.test two.test three.test @@ -183,6 +183,6 @@ class EppDomainCheckBaseTest < EppTestCase headers: { 'HTTP_COOKIE' => 'session=api_bestnames' } response_xml = Nokogiri::XML(response.body) - assert_equal 3, response_xml.xpath('//domain:cd', 'domain' => "#{Xsd::Schema.filename(for_prefix: 'domain-eis')}").size + assert_equal 3, response_xml.xpath('//domain:cd', 'domain' => "#{Xsd::Schema.filename(for_prefix: 'domain-ee')}").size end end diff --git a/test/integration/epp/domain/create/auction_idn_test.rb b/test/integration/epp/domain/create/auction_idn_test.rb index 170b4eb79..2f2fd6fd9 100644 --- a/test/integration/epp/domain/create/auction_idn_test.rb +++ b/test/integration/epp/domain/create/auction_idn_test.rb @@ -24,7 +24,7 @@ class EppDomainCreateAuctionIdnTest < EppTestCase - + xn--pramiid-n2a.test #{contacts(:john).code} @@ -59,7 +59,7 @@ class EppDomainCreateAuctionIdnTest < EppTestCase - + püramiid.test #{contacts(:john).code} @@ -93,7 +93,7 @@ class EppDomainCreateAuctionIdnTest < EppTestCase - + xn--pramiid-n2a.test #{contacts(:john).code} @@ -127,7 +127,7 @@ class EppDomainCreateAuctionIdnTest < EppTestCase - + püramiid.test #{contacts(:john).code} @@ -162,7 +162,7 @@ class EppDomainCreateAuctionIdnTest < EppTestCase - + püramiid.test #{contacts(:john).code} @@ -199,7 +199,7 @@ class EppDomainCreateAuctionIdnTest < EppTestCase - + xn--pramiid-n2a.test #{contacts(:john).code} diff --git a/test/integration/epp/domain/create/auction_test.rb b/test/integration/epp/domain/create/auction_test.rb index 1e9d5fa32..3c2b14d5c 100644 --- a/test/integration/epp/domain/create/auction_test.rb +++ b/test/integration/epp/domain/create/auction_test.rb @@ -16,7 +16,7 @@ class EppDomainCreateAuctionTest < EppTestCase - + not-at-auction.test #{contacts(:john).code} @@ -51,7 +51,7 @@ class EppDomainCreateAuctionTest < EppTestCase - + auction.test #{contacts(:john).code} @@ -84,7 +84,7 @@ class EppDomainCreateAuctionTest < EppTestCase - + auction.test #{contacts(:john).code} @@ -120,7 +120,7 @@ class EppDomainCreateAuctionTest < EppTestCase - + auction.test #{contacts(:john).code} @@ -150,7 +150,7 @@ class EppDomainCreateAuctionTest < EppTestCase - + auction.test #{contacts(:john).code} @@ -182,7 +182,7 @@ class EppDomainCreateAuctionTest < EppTestCase - + auction.test #{contacts(:john).code} @@ -214,7 +214,7 @@ class EppDomainCreateAuctionTest < EppTestCase - + auction.test diff --git a/test/integration/epp/domain/create/base_test.rb b/test/integration/epp/domain/create/base_test.rb index fbfd1e15b..914a6352a 100644 --- a/test/integration/epp/domain/create/base_test.rb +++ b/test/integration/epp/domain/create/base_test.rb @@ -17,7 +17,7 @@ class EppDomainCreateBaseTest < EppTestCase - + #{name} #{registrant.code} @@ -56,7 +56,7 @@ class EppDomainCreateBaseTest < EppTestCase - + #{name} #{registrant.code} @@ -89,7 +89,7 @@ class EppDomainCreateBaseTest < EppTestCase - + #{name} #{registrant.code} @@ -125,7 +125,7 @@ class EppDomainCreateBaseTest < EppTestCase - + #{name} #{registrant.code} @@ -161,7 +161,7 @@ class EppDomainCreateBaseTest < EppTestCase - + #{name} #{registrant.code} @@ -190,7 +190,7 @@ class EppDomainCreateBaseTest < EppTestCase - + #{name} #{registrant.code} #{contacts(:jane).code} @@ -226,7 +226,7 @@ class EppDomainCreateBaseTest < EppTestCase - + #{name} #{registrant.code} #{contact.code} @@ -264,7 +264,7 @@ class EppDomainCreateBaseTest < EppTestCase - + #{name} #{registrant.code} #{contact.code} @@ -301,7 +301,7 @@ class EppDomainCreateBaseTest < EppTestCase - + #{name} #{registrant.code} #{contact.code} @@ -339,7 +339,7 @@ class EppDomainCreateBaseTest < EppTestCase - + #{name} #{registrant.code} #{contact.code} @@ -377,7 +377,7 @@ class EppDomainCreateBaseTest < EppTestCase - + #{name} #{registrant.code} #{contact_two.code} @@ -414,7 +414,7 @@ class EppDomainCreateBaseTest < EppTestCase - + #{name} #{registrant.code} @@ -462,7 +462,7 @@ class EppDomainCreateBaseTest < EppTestCase - + #{name} #{registrant.code} @@ -498,7 +498,7 @@ class EppDomainCreateBaseTest < EppTestCase - + #{name} #{registrant.code} @@ -532,7 +532,7 @@ class EppDomainCreateBaseTest < EppTestCase - + #{reserved_domain.name} #{contacts(:john).code} @@ -568,7 +568,7 @@ class EppDomainCreateBaseTest < EppTestCase - + #{name} #{contacts(:john).code} @@ -601,7 +601,7 @@ class EppDomainCreateBaseTest < EppTestCase - + #{blocked_domain} #{contacts(:john).code} @@ -631,7 +631,7 @@ class EppDomainCreateBaseTest < EppTestCase - + #{SimpleIDN.to_ascii('blockedäöüõ.test')} #{contacts(:john).code} @@ -658,7 +658,7 @@ class EppDomainCreateBaseTest < EppTestCase - + #{reserved_domains(:one).name} #{contacts(:john).code} @@ -690,7 +690,7 @@ class EppDomainCreateBaseTest < EppTestCase - + #{reserved_domain.name} #{contacts(:john).code} @@ -720,7 +720,7 @@ class EppDomainCreateBaseTest < EppTestCase - + new.test #{contacts(:john).code} @@ -748,7 +748,7 @@ class EppDomainCreateBaseTest < EppTestCase - + new.test 2 john-001 diff --git a/test/integration/epp/domain/delete/base_test.rb b/test/integration/epp/domain/delete/base_test.rb index 0e8af8f20..952448c90 100644 --- a/test/integration/epp/domain/delete/base_test.rb +++ b/test/integration/epp/domain/delete/base_test.rb @@ -21,7 +21,7 @@ class EppDomainDeleteBaseTest < EppTestCase - + invalid.test @@ -48,7 +48,7 @@ class EppDomainDeleteBaseTest < EppTestCase - + shop.test @@ -76,7 +76,7 @@ class EppDomainDeleteBaseTest < EppTestCase - + shop.test @@ -110,7 +110,7 @@ class EppDomainDeleteBaseTest < EppTestCase - + shop.test @@ -144,7 +144,7 @@ class EppDomainDeleteBaseTest < EppTestCase - + shop.test @@ -177,7 +177,7 @@ class EppDomainDeleteBaseTest < EppTestCase - + shop.test @@ -210,7 +210,7 @@ class EppDomainDeleteBaseTest < EppTestCase - + shop.test @@ -232,7 +232,7 @@ class EppDomainDeleteBaseTest < EppTestCase - + shop.test diff --git a/test/integration/epp/domain/info/base_test.rb b/test/integration/epp/domain/info/base_test.rb index 71c303fca..214cdfb6f 100644 --- a/test/integration/epp/domain/info/base_test.rb +++ b/test/integration/epp/domain/info/base_test.rb @@ -13,7 +13,7 @@ class EppDomainInfoBaseTest < EppTestCase - + shop.test @@ -22,19 +22,33 @@ class EppDomainInfoBaseTest < EppTestCase XML post epp_info_path, params: { frame: request_xml }, - headers: { 'HTTP_COOKIE' => 'session=api_bestnames' } + headers: { 'HTTP_COOKIE' => 'session=api_bestnames' } response_xml = Nokogiri::XML(response.body) + assert_epp_response :completed_successfully - assert_equal 'shop.test', response_xml.at_xpath('//domain:name', 'domain' => "#{Xsd::Schema.filename(for_prefix: 'domain-eis')}").text - assert_equal 'ok', response_xml.at_xpath('//domain:status', 'domain' => "#{Xsd::Schema.filename(for_prefix: 'domain-eis')}")['s'] - assert_equal 'john-001', response_xml.at_xpath('//domain:registrant', 'domain' => "#{Xsd::Schema.filename(for_prefix: 'domain-eis')}").text - assert_equal '2010-07-05T00:00:00+03:00', response_xml.at_xpath('//domain:crDate', 'domain' => "#{Xsd::Schema.filename(for_prefix: 'domain-eis')}").text - assert_equal '2010-07-06T00:00:00+03:00', response_xml.at_xpath('//domain:upDate', 'domain' => "#{Xsd::Schema.filename(for_prefix: 'domain-eis')}").text - assert_equal '2010-07-07T00:00:00+03:00', response_xml.at_xpath('//domain:exDate', 'domain' => "#{Xsd::Schema.filename(for_prefix: 'domain-eis')}").text + assert assert_schema_is_bigger(response_xml, 'domain-ee', 1.1) + assert_equal 'shop.test', + response_xml.at_xpath('//domain:name', + 'domain' => Xsd::Schema.filename(for_prefix: 'domain-ee').to_s).text + assert_equal 'ok', + response_xml.at_xpath('//domain:status', + 'domain' => Xsd::Schema.filename(for_prefix: 'domain-ee').to_s)['s'] + assert_equal 'john-001', + response_xml.at_xpath('//domain:registrant', + 'domain' => Xsd::Schema.filename(for_prefix: 'domain-ee').to_s).text + assert_equal '2010-07-05T00:00:00+03:00', + response_xml.at_xpath('//domain:crDate', + 'domain' => Xsd::Schema.filename(for_prefix: 'domain-ee').to_s).text + assert_equal '2010-07-06T00:00:00+03:00', + response_xml.at_xpath('//domain:upDate', + 'domain' => Xsd::Schema.filename(for_prefix: 'domain-ee').to_s).text + assert_equal '2010-07-07T00:00:00+03:00', + response_xml.at_xpath('//domain:exDate', + 'domain' => Xsd::Schema.filename(for_prefix: 'domain-ee').to_s).text end - def test_returns_valid_response_if_disputed + def test_returns_valid_response_if_schema_version_is_previous dispute = disputes(:expired) dispute.update!(starts_at: Time.zone.now, expires_at: Time.zone.now + 5.days, closed: nil) @@ -61,7 +75,75 @@ class EppDomainInfoBaseTest < EppTestCase XML post epp_info_path, params: { frame: request_xml }, - headers: { 'HTTP_COOKIE' => 'session=api_bestnames' } + 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 + end + + def test_returns_valid_response_if_disputed + dispute = disputes(:expired) + dispute.update!(starts_at: Time.zone.now, expires_at: Time.zone.now + 5.days, closed: nil) + + domain = domains(:shop) + domain.update_columns(statuses: [DomainStatus::DISPUTED], + created_at: Time.zone.parse('2010-07-05'), + updated_at: Time.zone.parse('2010-07-06'), + creator_str: 'test', + valid_to: Time.zone.parse('2010-07-07')) + + domain.versions.destroy_all + + request_xml = <<-XML + + + + + + shop.test + + + + + XML + + 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 + end + + def test_returns_valid_response_if_release_prohibited + domain = domains(:shop) + domain.update_columns(statuses: [DomainStatus::SERVER_RELEASE_PROHIBITED], + created_at: Time.now - 5.days, + creator_str: 'test', + delete_date: Time.now - 1.day) + + request_xml = <<-XML + + + + + + shop.test + + + + + XML + + 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 @@ -79,7 +161,7 @@ class EppDomainInfoBaseTest < EppTestCase - + shop.test @@ -88,10 +170,12 @@ class EppDomainInfoBaseTest < EppTestCase XML post epp_info_path, params: { frame: request_xml }, - headers: { 'HTTP_COOKIE' => 'session=api_bestnames' } + headers: { 'HTTP_COOKIE' => 'session=api_bestnames' } response_xml = Nokogiri::XML(response.body) - assert_equal '65078d5', response_xml.at_xpath('//domain:authInfo/domain:pw', 'domain' => "#{Xsd::Schema.filename(for_prefix: 'domain-eis')}").text + assert_equal '65078d5', + response_xml.at_xpath('//domain:authInfo/domain:pw', + 'domain' => Xsd::Schema.filename(for_prefix: 'domain-ee').to_s).text end # Transfer code is the only info we conceal from other registrars, hence a bit oddly-looking @@ -104,7 +188,7 @@ class EppDomainInfoBaseTest < EppTestCase - + shop.test 65078d5 @@ -116,10 +200,12 @@ class EppDomainInfoBaseTest < EppTestCase XML post epp_info_path, params: { frame: request_xml }, - headers: { 'HTTP_COOKIE' => 'session=api_goodnames' } + headers: { 'HTTP_COOKIE' => 'session=api_goodnames' } response_xml = Nokogiri::XML(response.body) - assert_equal '65078d5', response_xml.at_xpath('//domain:authInfo/domain:pw', 'domain' => "#{Xsd::Schema.filename(for_prefix: 'domain-eis')}").text + assert_equal '65078d5', + response_xml.at_xpath('//domain:authInfo/domain:pw', + 'domain' => Xsd::Schema.filename(for_prefix: 'domain-ee').to_s).text end def test_conceals_transfer_code_when_domain_is_not_owned_by_current_user @@ -128,7 +214,7 @@ class EppDomainInfoBaseTest < EppTestCase - + shop.test @@ -140,10 +226,10 @@ class EppDomainInfoBaseTest < EppTestCase XML post epp_info_path, params: { frame: request_xml }, - headers: { 'HTTP_COOKIE' => 'session=api_goodnames' } + headers: { 'HTTP_COOKIE' => 'session=api_goodnames' } response_xml = Nokogiri::XML(response.body) assert_nil response_xml.at_xpath('//domain:authInfo/domain:pw', - 'domain' => "#{Xsd::Schema.filename(for_prefix: 'domain-eis')}") + 'domain' => Xsd::Schema.filename(for_prefix: 'domain-ee').to_s) end end diff --git a/test/integration/epp/domain/renew/base_test.rb b/test/integration/epp/domain/renew/base_test.rb index 51f0a553e..50732f163 100644 --- a/test/integration/epp/domain/renew/base_test.rb +++ b/test/integration/epp/domain/renew/base_test.rb @@ -14,7 +14,7 @@ class EppDomainRenewBaseTest < EppTestCase - + #{domain.name} #{domain.expire_time.to_date} 1 @@ -45,7 +45,7 @@ class EppDomainRenewBaseTest < EppTestCase - + #{domain.name} #{domain.expire_time.to_date} 1 @@ -72,7 +72,7 @@ class EppDomainRenewBaseTest < EppTestCase - + #{domain.name} #{domain.valid_to.to_date} 1 @@ -100,7 +100,7 @@ class EppDomainRenewBaseTest < EppTestCase - + #{domain.name} #{domain.valid_to.to_date} 1 @@ -128,7 +128,7 @@ class EppDomainRenewBaseTest < EppTestCase - + #{domain.name} #{domain.expire_time.to_date} 1 @@ -155,7 +155,7 @@ class EppDomainRenewBaseTest < EppTestCase - + #{domain.name} #{domain.expire_time.to_date} 2 @@ -183,7 +183,7 @@ class EppDomainRenewBaseTest < EppTestCase - + #{domain.name} #{provided_expiration_date} @@ -214,7 +214,7 @@ class EppDomainRenewBaseTest < EppTestCase - + #{domain.name} #{domain.expire_time.to_date} 1 diff --git a/test/integration/epp/domain/transfer/query_test.rb b/test/integration/epp/domain/transfer/query_test.rb index 2cd25b8f9..e87be291b 100644 --- a/test/integration/epp/domain/transfer/query_test.rb +++ b/test/integration/epp/domain/transfer/query_test.rb @@ -6,10 +6,10 @@ class EppDomainTransferQueryTest < EppTestCase headers: { 'HTTP_COOKIE' => 'session=api_bestnames' } xml_doc = Nokogiri::XML(response.body) assert_epp_response :completed_successfully - assert_equal 'shop.test', xml_doc.xpath('//domain:name', 'domain' => "#{Xsd::Schema.filename(for_prefix: 'domain-eis')}").text - assert_equal 'serverApproved', xml_doc.xpath('//domain:trStatus', 'domain' => "#{Xsd::Schema.filename(for_prefix: 'domain-eis')}").text - assert_equal 'goodnames', xml_doc.xpath('//domain:reID', 'domain' => "#{Xsd::Schema.filename(for_prefix: 'domain-eis')}").text - assert_equal 'bestnames', xml_doc.xpath('//domain:acID', 'domain' => "#{Xsd::Schema.filename(for_prefix: 'domain-eis')}").text + assert_equal 'shop.test', xml_doc.xpath('//domain:name', 'domain' => "#{Xsd::Schema.filename(for_prefix: 'domain-ee')}").text + assert_equal 'serverApproved', xml_doc.xpath('//domain:trStatus', 'domain' => "#{Xsd::Schema.filename(for_prefix: 'domain-ee')}").text + assert_equal 'goodnames', xml_doc.xpath('//domain:reID', 'domain' => "#{Xsd::Schema.filename(for_prefix: 'domain-ee')}").text + assert_equal 'bestnames', xml_doc.xpath('//domain:acID', 'domain' => "#{Xsd::Schema.filename(for_prefix: 'domain-ee')}").text end def test_wrong_transfer_code @@ -18,7 +18,7 @@ class EppDomainTransferQueryTest < EppTestCase - + shop.test wrong @@ -50,7 +50,7 @@ class EppDomainTransferQueryTest < EppTestCase - + shop.test 65078d5 diff --git a/test/integration/epp/domain/transfer/request_test.rb b/test/integration/epp/domain/transfer/request_test.rb index 6aab45f98..a44533f8b 100644 --- a/test/integration/epp/domain/transfer/request_test.rb +++ b/test/integration/epp/domain/transfer/request_test.rb @@ -119,7 +119,7 @@ class EppDomainTransferRequestTest < EppTestCase post epp_transfer_path, params: { frame: request_xml }, headers: { 'HTTP_COOKIE' => 'session=api_goodnames' } assert_equal 'serverApproved', Nokogiri::XML(response.body).xpath('//domain:trStatus', 'domain' => - "#{Xsd::Schema.filename(for_prefix: 'domain-eis')}").text + "#{Xsd::Schema.filename(for_prefix: 'domain-ee')}").text end def test_assigns_new_registrar @@ -204,7 +204,7 @@ class EppDomainTransferRequestTest < EppTestCase - + shop.test wrong @@ -231,7 +231,7 @@ class EppDomainTransferRequestTest < EppTestCase - + shop.test 65078d5 diff --git a/test/integration/epp/domain/update/base_test.rb b/test/integration/epp/domain/update/base_test.rb index 9db760fe2..e6eba6d1d 100644 --- a/test/integration/epp/domain/update/base_test.rb +++ b/test/integration/epp/domain/update/base_test.rb @@ -23,7 +23,7 @@ class EppDomainUpdateBaseTest < EppTestCase - + shop.test @@ -51,7 +51,7 @@ class EppDomainUpdateBaseTest < EppTestCase - + shop.test @@ -72,7 +72,7 @@ class EppDomainUpdateBaseTest < EppTestCase - + shop.test @@ -93,7 +93,7 @@ class EppDomainUpdateBaseTest < EppTestCase - + #{@domain.name} @@ -106,7 +106,7 @@ class EppDomainUpdateBaseTest < EppTestCase assert_epp_response :object_status_prohibits_operation response_xml = Nokogiri::XML(response.body) - assert_equal DomainStatus::PENDING_UPDATE, response_xml.at_xpath('//domain:status', 'domain' => "#{Xsd::Schema.filename(for_prefix: 'domain-eis')}").text + assert_equal DomainStatus::PENDING_UPDATE, response_xml.at_xpath('//domain:status', 'domain' => "#{Xsd::Schema.filename(for_prefix: 'domain-ee')}").text end def test_requires_verification_from_current_registrant_when_provided_registrant_is_a_new_one @@ -119,7 +119,7 @@ class EppDomainUpdateBaseTest < EppTestCase - + #{@domain.name} #{new_registrant.code} @@ -163,7 +163,7 @@ class EppDomainUpdateBaseTest < EppTestCase - + #{@domain.name} #{new_registrant.code} @@ -198,7 +198,7 @@ class EppDomainUpdateBaseTest < EppTestCase - + #{@domain.name} #{new_registrant.code} @@ -241,7 +241,7 @@ class EppDomainUpdateBaseTest < EppTestCase - + #{@domain.name} #{new_registrant.code} @@ -277,7 +277,7 @@ class EppDomainUpdateBaseTest < EppTestCase - + #{@domain.name} #{new_registrant.code} @@ -311,7 +311,7 @@ class EppDomainUpdateBaseTest < EppTestCase - + #{@domain.name} #{new_registrant.code} @@ -345,7 +345,7 @@ class EppDomainUpdateBaseTest < EppTestCase - + #{@domain.name} #{@domain.registrant.code} @@ -384,7 +384,7 @@ class EppDomainUpdateBaseTest < EppTestCase - + #{@domain.name} #{new_registrant.code} @@ -427,7 +427,7 @@ class EppDomainUpdateBaseTest < EppTestCase - + #{@domain.name} #{new_registrant.code} @@ -466,7 +466,7 @@ class EppDomainUpdateBaseTest < EppTestCase - + #{@domain.name} #{new_registrant.code} @@ -503,7 +503,7 @@ class EppDomainUpdateBaseTest < EppTestCase - + #{@domain.name} #{new_registrant.code} @@ -542,7 +542,7 @@ class EppDomainUpdateBaseTest < EppTestCase - + #{@domain.name} #{new_registrant.code} @@ -579,7 +579,7 @@ class EppDomainUpdateBaseTest < EppTestCase - + #{@domain.name} @@ -611,7 +611,7 @@ class EppDomainUpdateBaseTest < EppTestCase - + shop.test Test @@ -639,7 +639,7 @@ class EppDomainUpdateBaseTest < EppTestCase - + shop.test Test @@ -664,7 +664,7 @@ class EppDomainUpdateBaseTest < EppTestCase - + #{@domain.name} diff --git a/test/integration/epp/login_test.rb b/test/integration/epp/login_test.rb index 369c15e33..c053fc65a 100644 --- a/test/integration/epp/login_test.rb +++ b/test/integration/epp/login_test.rb @@ -25,7 +25,7 @@ class EppLoginTest < EppTestCase en - #{Xsd::Schema.filename(for_prefix: 'domain-eis')} + #{Xsd::Schema.filename(for_prefix: 'domain-ee')} #{Xsd::Schema.filename(for_prefix: 'contact-ee')} urn:ietf:params:xml:ns:host-1.0 urn:ietf:params:xml:ns:keyrelay-1.0 @@ -60,7 +60,7 @@ class EppLoginTest < EppTestCase en - #{Xsd::Schema.filename(for_prefix: 'domain-eis')} + #{Xsd::Schema.filename(for_prefix: 'domain-ee')} #{Xsd::Schema.filename(for_prefix: 'contact-ee')} urn:ietf:params:xml:ns:host-1.0 urn:ietf:params:xml:ns:keyrelay-1.0 @@ -94,7 +94,7 @@ class EppLoginTest < EppTestCase en - #{Xsd::Schema.filename(for_prefix: 'domain-eis')} + #{Xsd::Schema.filename(for_prefix: 'domain-ee')} #{Xsd::Schema.filename(for_prefix: 'contact-ee')} urn:ietf:params:xml:ns:host-1.0 urn:ietf:params:xml:ns:keyrelay-1.0 @@ -129,7 +129,7 @@ class EppLoginTest < EppTestCase en - #{Xsd::Schema.filename(for_prefix: 'domain-eis')} + #{Xsd::Schema.filename(for_prefix: 'domain-ee')} #{Xsd::Schema.filename(for_prefix: 'contact-ee')} urn:ietf:params:xml:ns:host-1.0 urn:ietf:params:xml:ns:keyrelay-1.0 @@ -164,7 +164,7 @@ class EppLoginTest < EppTestCase en - #{Xsd::Schema.filename(for_prefix: 'domain-eis')} + #{Xsd::Schema.filename(for_prefix: 'domain-ee')} #{Xsd::Schema.filename(for_prefix: 'contact-ee')} urn:ietf:params:xml:ns:host-1.0 urn:ietf:params:xml:ns:keyrelay-1.0 diff --git a/test/integration/registrar_area/xml_consoles_test.rb b/test/integration/registrar_area/xml_consoles_test.rb new file mode 100644 index 000000000..442e6f2c0 --- /dev/null +++ b/test/integration/registrar_area/xml_consoles_test.rb @@ -0,0 +1,112 @@ +require 'test_helper' + +class RegistrarXmlConsolesIntegrationTest < ApplicationIntegrationTest + setup do + sign_in users(:api_bestnames) + end + + def test_check_schema_path + post registrar_xml_console_path, params: { frame: payload }, + headers: { 'HTTP_COOKIE' => 'session=api_bestnames' } + + assert_response :ok + end + + def test_load_schema_path + get load_xml_registrar_xml_console_path, params: { obj: 'domain', epp_action: 'update' } + + assert_response :ok + assert_equal update_payload, response.body + end + + private + + def payload + <<~XML + + + + + + auction.test + + + + + XML + end + + def wrong_payload + <<~XML + + + + + + auction.test + + + + + XML + end + + def update_payload + <<~XML + + + + + + example.ee + + + + ns1.example.com + + + ns2.example.com + + + mak21 + + + + + ns1.example.net + + + mak21 + + + mak21 + + newpw + + + + + + + + + 257 + 3 + 8 + 700b97b591ed27ec2590d19f06f88bba700b97b591ed27ec2590d19f + + + + + + dGVzdCBmYWlsCg== + + + + test_bestnames-#{Time.zone.now.to_i} + + + XML + end +end diff --git a/test/models/epp/response/result/code_test.rb b/test/models/epp/response/result/code_test.rb index 184a18438..a78c92d3a 100644 --- a/test/models/epp/response/result/code_test.rb +++ b/test/models/epp/response/result/code_test.rb @@ -15,7 +15,7 @@ class EppResponseResultCodeTest < ActiveSupport::TestCase end def test_invalid_code_value - invalid_code_value = 0000 + invalid_code_value = 0o000 refute_includes Epp::Response::Result::Code.codes.values, invalid_code_value e = assert_raises ArgumentError do @@ -38,6 +38,7 @@ class EppResponseResultCodeTest < ActiveSupport::TestCase required_parameter_missing: 2003, parameter_value_range_error: 2004, parameter_value_syntax_error: 2005, + wrong_schema: 2100, billing_failure: 2104, unimplemented: 2101, object_is_not_eligible_for_renewal: 2105, @@ -51,7 +52,7 @@ class EppResponseResultCodeTest < ActiveSupport::TestCase data_management_policy_violation: 2308, command_failed: 2400, authentication_error_server_closing_connection: 2501, - session_limit_exceeded_server_closing_connection: 2502, + session_limit_exceeded_server_closing_connection: 2502 } assert_equal codes, Epp::Response::Result::Code.codes end @@ -70,6 +71,7 @@ class EppResponseResultCodeTest < ActiveSupport::TestCase 2003 => 'Required parameter missing', 2004 => 'Parameter value range error', 2005 => 'Parameter value syntax error', + 2100 => 'Wrong schema', 2101 => 'Unimplemented command', 2104 => 'Billing failure', 2105 => 'Object is not eligible for renewal', @@ -83,7 +85,7 @@ class EppResponseResultCodeTest < ActiveSupport::TestCase 2308 => 'Data management policy violation', 2400 => 'Command failed', 2501 => 'Authentication error; server closing connection', - 2502 => 'Session limit exceeded; server closing connection', + 2502 => 'Session limit exceeded; server closing connection' } assert_equal descriptions, Epp::Response::Result::Code.default_descriptions end diff --git a/test/system/registrar_area/xml_consoles_test.rb b/test/system/registrar_area/xml_consoles_test.rb new file mode 100644 index 000000000..6fe855a5b --- /dev/null +++ b/test/system/registrar_area/xml_consoles_test.rb @@ -0,0 +1,33 @@ +require 'application_system_test_case' + +class RegistrarAreaXmlConsolesTest < ApplicationSystemTestCase + setup do + sign_in users(:api_bestnames) + end + + def test_epp_server_does_not_response + visit registrar_xml_console_path + fill_in 'payload', with: schema_example + click_on 'Send EPP Request' + + el = page.find('.CodeRay', visible: :all) + assert el.text.include? 'CONNECTION ERROR - Is the EPP server running?' + end + + private + + def schema_example + <<~XML + + + + + + auction.test + + + + + XML + end +end diff --git a/test/test_helper.rb b/test/test_helper.rb index df2e9878e..a8ed1a3ca 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -22,7 +22,6 @@ require 'sidekiq/testing' Sidekiq::Testing.fake! - # `bin/rails test` is not the same as `bin/rake test`. # All tasks will be loaded (and executed) twice when using the former without `Rake::Task.clear`. # https://github.com/rails/rails/issues/28786 @@ -69,4 +68,24 @@ end class EppTestCase < ActionDispatch::IntegrationTest include Assertions::EppAssertions + + def assert_schema_is_bigger(response_xml, prefix, version) + schema_version = prefix_schema_tag(prefix, response_xml) + + assert schema_version >= version + end + + private + + def prefix_schema_tag(prefix, response_xml) + if Xsd::Schema::PREFIXES.include? prefix + version_regex = /-\d+\S\d+/ + domain_schema_tag = response_xml.to_s.scan(%r{https://epp.tld.ee/schema/#{prefix}\S+}) + version = domain_schema_tag.to_s.match(version_regex)[0] + + -version.to_f + else + raise Exception.new('Wrong prefix') + end + end end