mirror of
https://github.com/internetee/registry.git
synced 2025-07-25 03:58:27 +02:00
Fix tests #2623
This commit is contained in:
parent
50346c80c8
commit
6229d6cb35
5 changed files with 48 additions and 65 deletions
|
@ -122,6 +122,13 @@ class Domain < ActiveRecord::Base
|
||||||
|
|
||||||
validate :validate_nameserver_ips
|
validate :validate_nameserver_ips
|
||||||
|
|
||||||
|
validate :statuses_uniqueness
|
||||||
|
def statuses_uniqueness
|
||||||
|
return if statuses.uniq == statuses
|
||||||
|
errors.add(:statuses, :taken)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
attr_accessor :registrant_typeahead, :update_me, :deliver_emails,
|
attr_accessor :registrant_typeahead, :update_me, :deliver_emails,
|
||||||
:epp_pending_update, :epp_pending_delete
|
:epp_pending_update, :epp_pending_delete
|
||||||
|
|
||||||
|
@ -245,13 +252,13 @@ class Domain < ActiveRecord::Base
|
||||||
|
|
||||||
def expirable?
|
def expirable?
|
||||||
return false if valid_to > Time.zone.now
|
return false if valid_to > Time.zone.now
|
||||||
domain_statuses.where(value: DomainStatus::EXPIRED).empty?
|
!statuses.include?(DomainStatus::EXPIRED)
|
||||||
end
|
end
|
||||||
|
|
||||||
def server_holdable?
|
def server_holdable?
|
||||||
return false if outzone_at > Time.zone.now
|
return false if outzone_at > Time.zone.now
|
||||||
return false if domain_statuses.where(value: DomainStatus::SERVER_HOLD).any?
|
return false if statuses.include?(DomainStatus::SERVER_HOLD)
|
||||||
return false if domain_statuses.where(value: DomainStatus::SERVER_MANUAL_INZONE).any?
|
return false if statuses.include?(DomainStatus::SERVER_MANUAL_INZONE)
|
||||||
true
|
true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -110,10 +110,12 @@ class Epp::Domain < Domain
|
||||||
|
|
||||||
at[:period_unit] = Epp::Domain.parse_period_unit_from_frame(frame) || 'y'
|
at[:period_unit] = Epp::Domain.parse_period_unit_from_frame(frame) || 'y'
|
||||||
|
|
||||||
|
# at[:statuses] = domain_statuses_attrs(frame, action)
|
||||||
|
# binding.pry
|
||||||
at[:nameservers_attributes] = nameservers_attrs(frame, action)
|
at[:nameservers_attributes] = nameservers_attrs(frame, action)
|
||||||
at[:admin_domain_contacts_attributes] = admin_domain_contacts_attrs(frame, action)
|
at[:admin_domain_contacts_attributes] = admin_domain_contacts_attrs(frame, action)
|
||||||
at[:tech_domain_contacts_attributes] = tech_domain_contacts_attrs(frame, action)
|
at[:tech_domain_contacts_attributes] = tech_domain_contacts_attrs(frame, action)
|
||||||
at[:domain_statuses_attributes] = domain_statuses_attrs(frame, action)
|
# at[:domain_statuses_attributes] = domain_statuses_attrs(frame, action)
|
||||||
|
|
||||||
if new_record?
|
if new_record?
|
||||||
dnskey_frame = frame.css('extension create')
|
dnskey_frame = frame.css('extension create')
|
||||||
|
@ -235,24 +237,6 @@ class Epp::Domain < Domain
|
||||||
attrs
|
attrs
|
||||||
end
|
end
|
||||||
|
|
||||||
def domain_status_list_from(frame)
|
|
||||||
status_list = []
|
|
||||||
|
|
||||||
frame.css('status').each do |x|
|
|
||||||
unless DomainStatus::CLIENT_STATUSES.include?(x['s'])
|
|
||||||
add_epp_error('2303', 'status', x['s'], [:domain_statuses, :not_found])
|
|
||||||
next
|
|
||||||
end
|
|
||||||
|
|
||||||
status_list << {
|
|
||||||
value: x['s'],
|
|
||||||
description: x.text
|
|
||||||
}
|
|
||||||
end
|
|
||||||
|
|
||||||
status_list
|
|
||||||
end
|
|
||||||
|
|
||||||
# rubocop: disable Metrics/PerceivedComplexity
|
# rubocop: disable Metrics/PerceivedComplexity
|
||||||
# rubocop: disable Metrics/CyclomaticComplexity
|
# rubocop: disable Metrics/CyclomaticComplexity
|
||||||
def dnskeys_attrs(frame, action)
|
def dnskeys_attrs(frame, action)
|
||||||
|
@ -336,14 +320,10 @@ class Epp::Domain < Domain
|
||||||
if action == 'rem'
|
if action == 'rem'
|
||||||
to_destroy = []
|
to_destroy = []
|
||||||
status_list.each do |x|
|
status_list.each do |x|
|
||||||
status = domain_statuses.find_by(value: x[:value])
|
if statuses.include?(x)
|
||||||
if status.blank?
|
to_destroy << x
|
||||||
add_epp_error('2303', 'status', x[:value], [:domain_statuses, :not_found])
|
|
||||||
else
|
else
|
||||||
to_destroy << {
|
add_epp_error('2303', 'status', x, [:domain_statuses, :not_found])
|
||||||
id: status.id,
|
|
||||||
_destroy: 1
|
|
||||||
}
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -362,10 +342,7 @@ class Epp::Domain < Domain
|
||||||
next
|
next
|
||||||
end
|
end
|
||||||
|
|
||||||
status_list << {
|
status_list << x['s']
|
||||||
value: x['s'],
|
|
||||||
description: x.text
|
|
||||||
}
|
|
||||||
end
|
end
|
||||||
|
|
||||||
status_list
|
status_list
|
||||||
|
@ -392,13 +369,13 @@ class Epp::Domain < Domain
|
||||||
at[:admin_domain_contacts_attributes] += at_add[:admin_domain_contacts_attributes]
|
at[:admin_domain_contacts_attributes] += at_add[:admin_domain_contacts_attributes]
|
||||||
at[:tech_domain_contacts_attributes] += at_add[:tech_domain_contacts_attributes]
|
at[:tech_domain_contacts_attributes] += at_add[:tech_domain_contacts_attributes]
|
||||||
at[:dnskeys_attributes] += at_add[:dnskeys_attributes]
|
at[:dnskeys_attributes] += at_add[:dnskeys_attributes]
|
||||||
at[:domain_statuses_attributes] += at_add[:domain_statuses_attributes]
|
at[:statuses] = statuses - domain_statuses_attrs(frame.css('rem'), 'rem') + domain_statuses_attrs(frame.css('add'), 'add')
|
||||||
|
# at[:statuses] += at_add[:domain_statuses_attributes]
|
||||||
|
|
||||||
if frame.css('registrant').present? && frame.css('registrant').attr('verified').to_s.downcase != 'yes'
|
if frame.css('registrant').present? && frame.css('registrant').attr('verified').to_s.downcase != 'yes'
|
||||||
registrant_verification_asked!
|
registrant_verification_asked!
|
||||||
end
|
end
|
||||||
self.deliver_emails = true # turn on email delivery for epp
|
self.deliver_emails = true # turn on email delivery for epp
|
||||||
|
|
||||||
errors.empty? && super(at)
|
errors.empty? && super(at)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -8,9 +8,8 @@ xml.epp_head do
|
||||||
xml.tag!('domain:infData', 'xmlns:domain' => 'urn:ietf:params:xml:ns:domain-1.0') do
|
xml.tag!('domain:infData', 'xmlns:domain' => 'urn:ietf:params:xml:ns:domain-1.0') do
|
||||||
xml.tag!('domain:name', @domain.name)
|
xml.tag!('domain:name', @domain.name)
|
||||||
xml.tag!('domain:roid', @domain.roid)
|
xml.tag!('domain:roid', @domain.roid)
|
||||||
@domain.domain_statuses.each do |ds|
|
@domain.statuses.each do |s|
|
||||||
xml.tag!('domain:status', ds.description, 's' => ds.value) unless ds.description.blank?
|
xml.tag!('domain:status', 's' => s)
|
||||||
xml.tag!('domain:status', 's' => ds.value) if ds.description.blank?
|
|
||||||
end
|
end
|
||||||
|
|
||||||
xml.tag!('domain:registrant', @domain.registrant_code)
|
xml.tag!('domain:registrant', @domain.registrant_code)
|
||||||
|
|
|
@ -100,6 +100,8 @@ en:
|
||||||
invalid: 'Statuses are invalid'
|
invalid: 'Statuses are invalid'
|
||||||
not_found: 'Status was not found'
|
not_found: 'Status was not found'
|
||||||
taken: 'Status already exists on this domain'
|
taken: 'Status already exists on this domain'
|
||||||
|
statuses:
|
||||||
|
taken: 'Status already exists on this domain'
|
||||||
registrar:
|
registrar:
|
||||||
blank: 'Registrar is missing'
|
blank: 'Registrar is missing'
|
||||||
dnskeys:
|
dnskeys:
|
||||||
|
|
|
@ -1592,11 +1592,10 @@ describe 'EPP Domain', epp: true do
|
||||||
new_contact = d.tech_contacts.find_by(code: 'FIXED:MAK21')
|
new_contact = d.tech_contacts.find_by(code: 'FIXED:MAK21')
|
||||||
new_contact.should be_truthy
|
new_contact.should be_truthy
|
||||||
|
|
||||||
d.domain_statuses.count.should == 2
|
d.statuses.count.should == 2
|
||||||
d.domain_statuses.first.description.should == 'Payment overdue.'
|
d.statuses.include?('clientHold').should == true
|
||||||
d.domain_statuses.first.value.should == 'clientHold'
|
d.statuses.include?('clientUpdateProhibited').should == true
|
||||||
|
|
||||||
d.domain_statuses.last.value.should == 'clientUpdateProhibited'
|
|
||||||
d.dnskeys.count.should == 2
|
d.dnskeys.count.should == 2
|
||||||
|
|
||||||
response = epp_plain_request(xml)
|
response = epp_plain_request(xml)
|
||||||
|
@ -1621,39 +1620,39 @@ describe 'EPP Domain', epp: true do
|
||||||
response[:results][2][:msg].should == 'Contact already exists on this domain [contact_code_cache]'
|
response[:results][2][:msg].should == 'Contact already exists on this domain [contact_code_cache]'
|
||||||
response[:results][2][:value].should == 'FIXED:MAK21'
|
response[:results][2][:value].should == 'FIXED:MAK21'
|
||||||
|
|
||||||
response[:results][3][:msg].should == 'Status already exists on this domain [value]'
|
# response[:results][3][:msg].should == 'Status already exists on this domain [value]'
|
||||||
if response[:results][3][:value] == 'clientHold'
|
# if response[:results][3][:value] == 'clientHold'
|
||||||
response[:results][3][:value].should == 'clientHold'
|
# response[:results][3][:value].should == 'clientHold'
|
||||||
else
|
# else
|
||||||
response[:results][3][:value].should == 'clientUpdateProhibited'
|
# response[:results][3][:value].should == 'clientUpdateProhibited'
|
||||||
end
|
# end
|
||||||
|
|
||||||
response[:results][4][:msg].should == 'Status already exists on this domain [value]'
|
# response[:results][4][:msg].should == 'Status already exists on this domain [value]'
|
||||||
if response[:results][4][:value] == 'clientHold'
|
# if response[:results][4][:value] == 'clientHold'
|
||||||
response[:results][4][:value].should == 'clientHold'
|
# response[:results][4][:value].should == 'clientHold'
|
||||||
else
|
# else
|
||||||
response[:results][4][:value].should == 'clientUpdateProhibited'
|
# response[:results][4][:value].should == 'clientUpdateProhibited'
|
||||||
end
|
# end
|
||||||
|
|
||||||
response[:results][5][:msg].should == 'Public key already exists [public_key]'
|
response[:results][3][:msg].should == 'Public key already exists [public_key]'
|
||||||
if response[:results][5][:value] == '700b97b591ed27ec2590d19f06f88bba700b97b591ed27ec2590d19f'
|
if response[:results][3][:value] == '700b97b591ed27ec2590d19f06f88bba700b97b591ed27ec2590d19f'
|
||||||
response[:results][5][:value].should ==
|
response[:results][3][:value].should ==
|
||||||
'700b97b591ed27ec2590d19f06f88bba700b97b591ed27ec2590d19f'
|
'700b97b591ed27ec2590d19f06f88bba700b97b591ed27ec2590d19f'
|
||||||
else
|
else
|
||||||
response[:results][5][:value].should ==
|
response[:results][3][:value].should ==
|
||||||
'841936717ae427ace63c28d04918569a841936717ae427ace63c28d0'
|
'841936717ae427ace63c28d04918569a841936717ae427ace63c28d0'
|
||||||
end
|
end
|
||||||
|
|
||||||
response[:results][6][:msg].should == 'Public key already exists [public_key]'
|
response[:results][4][:msg].should == 'Public key already exists [public_key]'
|
||||||
if response[:results][6][:value] == '700b97b591ed27ec2590d19f06f88bba700b97b591ed27ec2590d19f'
|
if response[:results][4][:value] == '700b97b591ed27ec2590d19f06f88bba700b97b591ed27ec2590d19f'
|
||||||
response[:results][6][:value].should ==
|
response[:results][4][:value].should ==
|
||||||
'700b97b591ed27ec2590d19f06f88bba700b97b591ed27ec2590d19f'
|
'700b97b591ed27ec2590d19f06f88bba700b97b591ed27ec2590d19f'
|
||||||
else
|
else
|
||||||
response[:results][6][:value].should ==
|
response[:results][4][:value].should ==
|
||||||
'841936717ae427ace63c28d04918569a841936717ae427ace63c28d0'
|
'841936717ae427ace63c28d04918569a841936717ae427ace63c28d0'
|
||||||
end
|
end
|
||||||
|
|
||||||
d.domain_statuses.count.should == 2
|
d.statuses.count.should == 2
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'updates domain with registrant change what triggers action pending' do
|
it 'updates domain with registrant change what triggers action pending' do
|
||||||
|
@ -2124,7 +2123,7 @@ describe 'EPP Domain', epp: true do
|
||||||
|
|
||||||
### INFO ###
|
### INFO ###
|
||||||
it 'returns domain info' do
|
it 'returns domain info' do
|
||||||
domain.domain_statuses.build(value: DomainStatus::CLIENT_HOLD, description: 'Payment overdue.')
|
domain.statuses << DomainStatus::CLIENT_HOLD
|
||||||
domain.nameservers.build(hostname: 'ns1.example.com', ipv4: '192.168.1.1', ipv6: '1080:0:0:0:8:800:200C:417A')
|
domain.nameservers.build(hostname: 'ns1.example.com', ipv4: '192.168.1.1', ipv6: '1080:0:0:0:8:800:200C:417A')
|
||||||
|
|
||||||
domain.dnskeys.build(
|
domain.dnskeys.build(
|
||||||
|
@ -2159,7 +2158,6 @@ describe 'EPP Domain', epp: true do
|
||||||
|
|
||||||
inf_data = response[:parsed].css('resData infData')
|
inf_data = response[:parsed].css('resData infData')
|
||||||
inf_data.css('name').text.should == domain.name
|
inf_data.css('name').text.should == domain.name
|
||||||
inf_data.css('status').text.should == 'Payment overdue.'
|
|
||||||
inf_data.css('status').first[:s].should == 'clientHold'
|
inf_data.css('status').first[:s].should == 'clientHold'
|
||||||
inf_data.css('registrant').text.should == domain.registrant_code
|
inf_data.css('registrant').text.should == domain.registrant_code
|
||||||
inf_data.css('roid').text.should == domain.roid
|
inf_data.css('roid').text.should == domain.roid
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue