Merge pull request #2043 from internetee/2030-support-multiple-schema-file-versions

fixed bag, added test
This commit is contained in:
Timo Võhmar 2021-06-18 16:06:18 +03:00 committed by GitHub
commit e606db8200
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 113 additions and 18 deletions

View file

@ -3,9 +3,9 @@ module Depp
include ActiveModel::Model
attr_accessor :id, :name, :email, :phone, :org_name,
:ident, :ident_type, :ident_country_code,
:street, :city, :zip, :state, :country_code,
:password, :legal_document, :statuses, :code
:ident, :ident_type, :ident_country_code,
:street, :city, :zip, :state, :country_code,
:password, :legal_document, :statuses, :code
DISABLED = 'Disabled'
DISCLOSURE_TYPES = [DISABLED, '1', '0']
@ -77,7 +77,8 @@ module Depp
def user=(user)
@user = user
@epp_xml = EppXml::Contact.new(cl_trid_prefix: user.tag)
@epp_xml = EppXml::Contact.new(cl_trid_prefix: user.tag, schema_prefix: 'contact-ee',
schema_version: '1.1')
end
def info_xml(id, password = nil)
@ -236,11 +237,11 @@ module Depp
case action
when :create
ident = ident_xml[:_anonymus].try(:first)
ident = ident_xml[:_anonymus].try(:first)
when :update
# detect if any ident has changed, nb! ident and self.ident is not always same
if !(ident == self.ident && ident == self.ident_type && ident_country_code == self.ident_country_code)
ident = ident_xml[:_anonymus].try(:first)
ident = ident_xml[:_anonymus].try(:first)
end
end

View file

@ -53,11 +53,6 @@ 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)
@ -66,7 +61,8 @@ module Depp
period = domain_params[:period].to_i.to_s
period_unit = domain_params[:period][-1].to_s
xml = if hostname_present
xml = if domain_params[:nameservers_attributes]
.select { |_key, value| value['hostname'].present? }.any?
epp_xml.create({
name: { value: domain_params[:name] },
period: { value: period, attrs: { unit: period_unit } },
@ -242,12 +238,11 @@ module Depp
rem_arr << { ns: rem_ns } if rem_ns.any?
rem_arr << { _anonymus: rem_anon } if rem_anon.any?
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' } } }]
if domain_params[:registrant] != old_domain_params[:registrant]
chg = [{ registrant: { value: domain_params[:registrant] } }] unless domain_params[:verified].present?
if domain_params[:verified]
chg = [{ registrant: { value: domain_params[:registrant], attrs: { verified: 'yes' } } }]
end
end
add_arr = nil if add_arr.none?