Fix some CC issues

This commit is contained in:
Karl Erik Õunapuu 2020-12-29 13:16:45 +02:00
parent 221e4ba578
commit 7caa544c83
No known key found for this signature in database
GPG key ID: C9DD647298A34764
8 changed files with 50 additions and 53 deletions

View file

@ -40,7 +40,8 @@ module Epp
authorize!(:update, @domain, @password)
registrar_id = current_user.registrar.id
update_params = ::Deserializers::Xml::DomainUpdate.new(params[:parsed_frame], registrar_id).call
update_params = ::Deserializers::Xml::DomainUpdate.new(params[:parsed_frame],
registrar_id).call
action = Actions::DomainUpdate.new(@domain, update_params, false)
if action.call
pending = @domain.epp_pending_update.present?

View file

@ -24,13 +24,10 @@ module Domains
user = ApiUser.find(domain.pending_json['current_user_id'])
frame = domain.pending_json['frame'] ? domain.pending_json['frame'].with_indifferent_access : {}
#self.statuses.delete(DomainStatus::PENDING_UPDATE)
domain.upid = user.registrar.id if user.registrar
domain.up_date = Time.zone.now
Actions::DomainUpdate.new(domain, frame, true).call
#save!
end
end
end

View file

@ -69,7 +69,7 @@ module Actions
attrs = []
params[:admin_domain_contacts_attributes].each do |c|
contact = Contact.find_by(code: c)
domain.add_epp_error('2303', 'contact', c, %i[domain_contacts not_found]) unless contact.present?
domain.add_epp_error('2303', 'contact', c, %i[domain_contacts not_found]) if contact.blank?
attrs << { contact_id: contact.id, contact_code_cache: contact.code } if contact
end
@ -80,7 +80,7 @@ module Actions
attrs = []
params[:tech_domain_contacts_attributes].each do |c|
contact = Contact.find_by(code: c)
domain.add_epp_error('2303', 'contact', c, %i[domain_contacts not_found]) unless contact.present?
domain.add_epp_error('2303', 'contact', c, %i[domain_contacts not_found]) if contact.blank?
attrs << { contact_id: contact.id, contact_code_cache: contact.code } if contact
end
@ -104,9 +104,9 @@ module Actions
return
end
domain.registrar.debit!({ sum: @domain_pricelist.price.amount, price: @domain_pricelist,
description: "#{I18n.t('create')} #{domain.name}",
activity_type: AccountActivity::CREATE })
domain.registrar.debit!(sum: @domain_pricelist.price.amount, price: @domain_pricelist,
description: "#{I18n.t('create')} #{domain.name}",
activity_type: AccountActivity::CREATE)
end
def process_auction_and_disputes

View file

@ -33,7 +33,10 @@ module Actions
def assign_new_registrant
return unless params[:registrant]
domain.add_epp_error('2306', nil, nil, %i[registrant cannot_be_missing]) unless params[:registrant][:code]
unless params[:registrant][:code]
domain.add_epp_error('2306', nil, nil, %i[registrant cannot_be_missing])
end
regt = Registrant.find_by(code: params[:registrant][:code])
if regt.present?
return if domain.registrant == regt
@ -51,7 +54,10 @@ module Actions
nameservers = []
params[:nameservers].select { |ns| ns[:action] == 'rem' }.each do |ns_attr|
ns = domain.nameservers.find_by_hash_params(ns_attr.except(:action)).first
domain.add_epp_error('2303', 'hostAttr', ns_attr[:hostname], %i[nameservers not_found]) and break unless ns
unless ns
domain.add_epp_error('2303', 'hostAttr', ns_attr[:hostname], %i[nameservers not_found])
break
end
nameservers << { id: ns.id, _destroy: 1 }
end
@ -59,7 +65,7 @@ module Actions
nameservers << ns_attr.except(:action)
end
return unless nameservers.present?
return if nameservers.blank?
domain.nameservers_attributes = nameservers
end
@ -95,7 +101,8 @@ module Actions
contacts = params[:contacts].select { |c| c[:type] == 'admin' }
if contacts.present? && domain.admin_change_prohibited?
domain.add_epp_error('2304', 'admin', DomainStatus::SERVER_ADMIN_CHANGE_PROHIBITED, I18n.t(:object_status_prohibits_operation))
domain.add_epp_error('2304', 'admin', DomainStatus::SERVER_ADMIN_CHANGE_PROHIBITED,
I18n.t(:object_status_prohibits_operation))
return
end
@ -109,10 +116,11 @@ module Actions
end
contacts.select { |c| c[:action] == 'add' }.each do |c|
contact = Epp::Contact.find_by_epp_code(c[:code])
contact = Epp::Contact.find_by(code: c[:code])
if contact.present?
if contact.org?
domain.add_epp_error('2306', 'contact', c[:code], %i[domain_contacts admin_contact_can_be_only_private_person])
domain.add_epp_error('2306', 'contact', c[:code],
%i[domain_contacts admin_contact_can_be_only_private_person])
else
props << { contact_id: contact.id, contact_code_cache: contact.code }
end
@ -121,7 +129,7 @@ module Actions
end
end
return unless props.present?
return if props.blank?
domain.admin_domain_contacts_attributes = props
end
@ -133,7 +141,8 @@ module Actions
contacts = params[:contacts].select { |c| c[:type] == 'tech' }
if contacts.present? && domain.tech_change_prohibited?
domain.add_epp_error('2304', 'tech', DomainStatus::SERVER_TECH_CHANGE_PROHIBITED, I18n.t(:object_status_prohibits_operation))
domain.add_epp_error('2304', 'tech', DomainStatus::SERVER_TECH_CHANGE_PROHIBITED,
I18n.t(:object_status_prohibits_operation))
return
end
@ -147,7 +156,7 @@ module Actions
end
contacts.select { |c| c[:action] == 'add' }.each do |c|
contact = Epp::Contact.find_by_epp_code(c[:code])
contact = Epp::Contact.find_by(code: c[:code])
if contact.present?
props << { contact_id: contact.id, contact_code_cache: contact.code }
else
@ -155,7 +164,7 @@ module Actions
end
end
return unless props.present?
return if props.blank?
domain.tech_domain_contacts_attributes = props
end
@ -203,10 +212,12 @@ module Actions
Dispute.close_by_domain(domain.name)
return false
else
domain.add_epp_error('2202', nil, nil, 'Invalid authorization information; invalid reserved>pw value')
domain.add_epp_error('2202', nil, nil,
'Invalid authorization information; invalid reserved>pw value')
end
else
domain.add_epp_error('2304', nil, nil, 'Required parameter missing; reservedpw element required for dispute domains')
domain.add_epp_error('2304', nil, nil, "Required parameter missing; reservedpw element " \
'required for dispute domains')
end
true

View file

@ -129,26 +129,6 @@ class Epp::Domain < Domain
self.legal_document_id = doc.id
end
def apply_pending_update!
preclean_pendings
user = ApiUser.find(pending_json['current_user_id'])
frame = pending_json['frame'] ? pending_json['frame'].with_indifferent_access : {}
self.statuses.delete(DomainStatus::PENDING_UPDATE)
self.upid = user.registrar.id if user.registrar
self.up_date = Time.zone.now
return unless Actions::DomainUpdate.new(self, frame, true).call
clean_pendings!
save!
WhoisRecord.find_by(domain_id: id).save # need to reload model
true
end
def apply_pending_delete!
preclean_pendings
statuses.delete(DomainStatus::PENDING_DELETE_CONFIRMATION)

View file

@ -3,9 +3,10 @@ module Deserializers
class DnssecKey
attr_reader :frame, :dsa
KEY_INTERFACE = { flags: 'flags', protocol: 'protocol', alg: 'alg', public_key: 'pubKey' }
KEY_INTERFACE = { flags: 'flags', protocol: 'protocol', alg: 'alg',
public_key: 'pubKey' }.freeze
DS_INTERFACE = { ds_key_tag: 'keyTag', ds_alg: 'alg', ds_digest_type: 'digestType',
ds_digest: 'digest' }
ds_digest: 'digest' }.freeze
def initialize(frame, dsa)
@frame = frame

View file

@ -14,8 +14,9 @@ module Deserializers
def call
obj = { domain: frame.css('name')&.text, registrant: registrant, contacts: contacts,
auth_info: if_present('authInfo > pw'), nameservers: nameservers, dns_keys: dns_keys,
registrar_id: registrar, statuses: statuses, reserved_pw: if_present('reserved > pw') }
auth_info: if_present('authInfo > pw'), nameservers: nameservers,
registrar_id: registrar, statuses: statuses, dns_keys: dns_keys,
reserved_pw: if_present('reserved > pw') }
obj.reject { |_key, val| val.blank? }
end
@ -23,7 +24,8 @@ module Deserializers
def registrant
return if frame.css('chg > registrant').blank?
{ code: frame.css('chg > registrant').text, verified: frame.css('chg > registrant').attr('verified').to_s.downcase == 'yes' }
{ code: frame.css('chg > registrant').text,
verified: frame.css('chg > registrant').attr('verified').to_s.downcase == 'yes' }
end
def contacts
@ -36,7 +38,7 @@ module Deserializers
contacts << { code: c.text, type: c['type'], action: 'rem' }
end
contacts.present? ? contacts : nil
contacts.presence
end
def nameservers
@ -53,7 +55,7 @@ module Deserializers
nameservers << nsrv
end
nameservers.present? ? nameservers : nil
nameservers.presence
end
def dns_keys
@ -62,18 +64,23 @@ module Deserializers
removed = ::Deserializers::Xml::DnssecKeys.new(frame.css('rem')).call
removed.each { |k| k[:action] = 'rem' }
return unless (added + removed).present?
return if (added + removed).blank?
added + removed
end
def statuses
return unless frame.css('status').present?
return if frame.css('status').blank?
statuses = []
frame.css('add > status').each { |entry| statuses << { status: entry.attr('s').to_s, action: 'add' } }
frame.css('rem > status').each { |entry| statuses << { status: entry.attr('s').to_s, action: 'rem' } }
frame.css('add > status').each do |e|
statuses << { status: e.attr('s').to_s, action: 'add' }
end
frame.css('rem > status').each do |e|
statuses << { status: e.attr('s').to_s, action: 'rem' }
end
statuses
end

View file

@ -11,7 +11,7 @@ module Deserializers
{
hostname: frame.css('hostName').text,
ipv4: frame.css('hostAddr[ip="v4"]').map(&:text).compact,
ipv6: frame.css('hostAddr[ip="v6"]').map(&:text).compact
ipv6: frame.css('hostAddr[ip="v6"]').map(&:text).compact,
}
end
end