diff --git a/app/controllers/concerns/epp/common.rb b/app/controllers/concerns/epp/common.rb index f2509753b..89aa8c638 100644 --- a/app/controllers/concerns/epp/common.rb +++ b/app/controllers/concerns/epp/common.rb @@ -12,6 +12,7 @@ module Epp::Common end def proxy + @errors = [] @svTRID = "ccReg-#{'%010d' % rand(10 ** 10)}" send(params[:command]) end @@ -34,10 +35,10 @@ module Epp::Common xsd = Nokogiri::XML::Schema(File.read("doc/schemas/#{type}-1.0.xsd")) doc = Nokogiri::XML(params[:frame]) - @extValues = xsd.validate(doc) - if @extValues.any? - @code = '2001' - @msg = 'Command syntax error' + ext_values = xsd.validate(doc) + @errors = [] + if ext_values.any? + @errors << {code: '2001', msg: 'Command syntax error', ext_values: ext_values} render '/epp/error' and return end end diff --git a/app/controllers/epp/errors_controller.rb b/app/controllers/epp/errors_controller.rb index 41990e4c6..79469cba2 100644 --- a/app/controllers/epp/errors_controller.rb +++ b/app/controllers/epp/errors_controller.rb @@ -2,7 +2,8 @@ class Epp::ErrorsController < ApplicationController include Epp::Common def error - @code, @msg = params[:code], params[:msg] + @errors = [] + @errors << {code: params[:code], msg: params[:msg]} render '/epp/error' end end diff --git a/app/helpers/epp/contacts_helper.rb b/app/helpers/epp/contacts_helper.rb index 5647774a9..392f50eed 100644 --- a/app/helpers/epp/contacts_helper.rb +++ b/app/helpers/epp/contacts_helper.rb @@ -2,7 +2,7 @@ module Epp::ContactsHelper def create_contact ph = params_hash['epp']['command']['create']['create'] - ph[:ident] ? @contact = Contact.where(ident: ph[:ident]).first_or_initialize : @contact = Contact.new + ph[:ident] ? @contact = Contact.where(ident: ph[:ident]).first_or_initialize : @contact = Contact.new if @contact.new_record? @contact.assign_attributes( code: ph[:id], @@ -10,7 +10,7 @@ module Epp::ContactsHelper ident: ph[:ident], email: ph[:email] ) - end + end @contact.name = ph[:postalInfo][:name] @contact.ident_type = ident_type @@ -32,12 +32,10 @@ module Epp::ContactsHelper @contact.destroy render '/epp/contacts/delete' rescue NoMethodError => e - @code = '2303' - @msg = "Object does not exist" + @errors << {code: '2303', msg: "Object does not exist"} render '/epp/error' rescue - @code = '2400' - @msg = "Command failed" + @errors << {code: '2400', msg: "Command failed"} render '/epp/error' end end @@ -49,8 +47,7 @@ module Epp::ContactsHelper if @contacts.any? render '/epp/contacts/check' else - @code = '2303' - @msg = "Object does not exist" + @errors << {code: '2303', msg: "Object does not exist"} render 'epp/error' end end @@ -59,9 +56,9 @@ module Epp::ContactsHelper def ident_type result = params[:frame].slice(/(?<=\ @code) do - xml.msg(@msg, 'lang' => 'en') - end - end + @errors.each do |x| + xml.result('code' => x[:code]) do + xml.msg(x[:msg], 'lang' => 'en') + + x[:ext_values].each do |y| + xml.extValue do + xml.value do + # xml.tag!() + xml.reason y.to_s + end + end + end if x[:ext_values] - @extValues.each do |x| - xml.extValue do - xml.value do - # xml.tag!() - xml.reason x.to_s end end - end if @extValues && @extValues.any? + end xml << render('/epp/shared/trID') end diff --git a/spec/epp/domain_spec.rb b/spec/epp/domain_spec.rb index 9cc797e25..f2ee9f326 100644 --- a/spec/epp/domain_spec.rb +++ b/spec/epp/domain_spec.rb @@ -31,6 +31,10 @@ describe 'EPP Domain', epp: true do expect(response[:clTRID]).to eq('ABC-12345') end + it 'does not create a domain with false period' do + + end + it 'checks a domain' do response = epp_request('domains/check.xml') expect(response[:result_code]).to eq('1000')