diff --git a/app/controllers/epp/domains_controller.rb b/app/controllers/epp/domains_controller.rb index 078447d69..28930ba8d 100644 --- a/app/controllers/epp/domains_controller.rb +++ b/app/controllers/epp/domains_controller.rb @@ -51,6 +51,7 @@ class Epp::DomainsController < EppController # @domain.parse_and_update_domain_dependencies(params[:parsed_frame].css('chg')) # @domain.attach_legal_document(Epp::EppDomain.parse_legal_document_from_frame(params[:parsed_frame])) # binding.pry + if @domain.update(params[:parsed_frame], current_user) render_epp_response '/epp/domains/success' else diff --git a/app/models/epp/epp_domain.rb b/app/models/epp/epp_domain.rb index a506e0545..68cfd19a0 100644 --- a/app/models/epp/epp_domain.rb +++ b/app/models/epp/epp_domain.rb @@ -68,12 +68,14 @@ class Epp::EppDomain < Domain at = {}.with_indifferent_access code = frame.css('registrant').first.try(:text) - oc = Contact.find_by(code: code).try(:id) + if code.present? + oc = Contact.find_by(code: code).try(:id) - if oc - at[:owner_contact_id] = oc - else - add_epp_error('2303', 'registrant', code, [:owner_contact, :not_found]) + if oc + at[:owner_contact_id] = oc + else + add_epp_error('2303', 'registrant', code, [:owner_contact, :not_found]) + end end at[:name] = frame.css('name').text if new_record? @@ -109,7 +111,7 @@ class Epp::EppDomain < Domain ns_list.each do |ns_attrs| nameserver = nameservers.where(ns_attrs).try(:first) if nameserver.blank? - add_epp_error('2303', 'hostAttr', ns_attrs[:hostname], I18n.t('nameserver_not_found')) + add_epp_error('2303', 'hostAttr', ns_attrs[:hostname], [:nameservers, :not_found]) else to_destroy << { id: nameserver.id, @@ -130,7 +132,13 @@ class Epp::EppDomain < Domain if action == 'rem' to_destroy = [] contact_list.each do |dc| - domain_contact_id = domain_contacts.find_by(contact_id: dc[:contact_id]).id + domain_contact_id = domain_contacts.find_by(contact_id: dc[:contact_id]).try(:id) + + unless domain_contact_id + add_epp_error('2303', 'contact', dc[:contact_code_cache], [:domain_contacts, :not_found]) + next + end + to_destroy << { id: domain_contact_id, _destroy: 1 @@ -148,12 +156,6 @@ class Epp::EppDomain < Domain frame.css('contact').each do |x| c = Contact.find_by(code: x.text) - # contact = Contact.find_by(code: x[:contact]) - # unless contact - # add_epp_error('2303', 'contact', x[:contact], [:domain_contacts, :not_found]) - # next - # end - unless c add_epp_error('2303', 'contact', x.text, [:domain_contacts, :not_found]) next @@ -288,7 +290,7 @@ class Epp::EppDomain < Domain frame.css('status').each do |x| unless DomainStatus::CLIENT_STATUSES.include?(x['s']) - add_epp_error('2303', 'status', x[:value], [:domain_statuses, :not_found]) + add_epp_error('2303', 'status', x['s'], [:domain_statuses, :not_found]) next end @@ -323,7 +325,7 @@ class Epp::EppDomain < Domain at[:dnskeys_attributes] += at_add[:dnskeys_attributes] at[:domain_statuses_attributes] += at_add[:domain_statuses_attributes] - super(at) + errors.empty? && super(at) end diff --git a/spec/epp/domain_spec.rb b/spec/epp/domain_spec.rb index cb5ed37f5..254078728 100644 --- a/spec/epp/domain_spec.rb +++ b/spec/epp/domain_spec.rb @@ -1248,13 +1248,14 @@ describe 'EPP Domain', epp: true do rem_cnt.should be_falsey response = epp_plain_request(xml, :xml) + response[:results][0][:result_code].should == '2303' - response[:results][0][:msg].should == 'Contact was not found' - response[:results][0][:value].should == 'citizen_1234' + response[:results][0][:msg].should == 'Nameserver was not found' + response[:results][0][:value].should == 'ns1.example.com' response[:results][1][:result_code].should == '2303' - response[:results][1][:msg].should == 'Nameserver was not found' - response[:results][1][:value].should == 'ns1.example.com' + response[:results][1][:msg].should == 'Contact was not found' + response[:results][1][:value].should == 'citizen_1234' response[:results][2][:result_code].should == '2303' response[:results][2][:msg].should == 'Status was not found'