mirror of
https://github.com/internetee/registry.git
synced 2025-05-16 09:27:19 +02:00
parent
ffd29f6a67
commit
b9df5aa92d
11 changed files with 411 additions and 281 deletions
20
app/models/concerns/domain/activatable.rb
Normal file
20
app/models/concerns/domain/activatable.rb
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
module Concerns::Domain::Activatable
|
||||||
|
extend ActiveSupport::Concern
|
||||||
|
|
||||||
|
def active?
|
||||||
|
!inactive?
|
||||||
|
end
|
||||||
|
|
||||||
|
def inactive?
|
||||||
|
statuses.include?(DomainStatus::INACTIVE)
|
||||||
|
end
|
||||||
|
|
||||||
|
def activate
|
||||||
|
statuses.delete(DomainStatus::INACTIVE)
|
||||||
|
end
|
||||||
|
|
||||||
|
def deactivate
|
||||||
|
return if inactive?
|
||||||
|
statuses << DomainStatus::INACTIVE
|
||||||
|
end
|
||||||
|
end
|
|
@ -40,13 +40,22 @@ module Depp
|
||||||
keys = Domain.create_dnskeys_hash(domain_params)
|
keys = Domain.create_dnskeys_hash(domain_params)
|
||||||
dns_hash[:_anonymus] = keys if keys.any?
|
dns_hash[:_anonymus] = keys if keys.any?
|
||||||
|
|
||||||
xml = epp_xml.create({
|
if domain_params[:nameservers_attributes].select { |key, value| value['hostname'].present? }.any?
|
||||||
name: { value: domain_params[:name] },
|
xml = epp_xml.create({
|
||||||
period: { value: domain_params[:period].to_s[0], attrs: { unit: domain_params[:period].to_s[1] } },
|
name: { value: domain_params[:name] },
|
||||||
ns: Domain.create_nameservers_hash(domain_params),
|
period: { value: domain_params[:period].to_s[0], attrs: { unit: domain_params[:period].to_s[1] } },
|
||||||
registrant: { value: domain_params[:registrant] },
|
ns: Domain.create_nameservers_hash(domain_params),
|
||||||
_anonymus: Domain.create_contacts_hash(domain_params)
|
registrant: { value: domain_params[:registrant] },
|
||||||
}, dns_hash, Domain.construct_custom_params_hash(domain_params))
|
_anonymus: Domain.create_contacts_hash(domain_params)
|
||||||
|
}, dns_hash, Domain.construct_custom_params_hash(domain_params))
|
||||||
|
else
|
||||||
|
xml = epp_xml.create({
|
||||||
|
name: { value: domain_params[:name] },
|
||||||
|
period: { value: domain_params[:period].to_s[0], attrs: { unit: domain_params[:period].to_s[1] } },
|
||||||
|
registrant: { value: domain_params[:registrant] },
|
||||||
|
_anonymus: Domain.create_contacts_hash(domain_params)
|
||||||
|
}, dns_hash, Domain.construct_custom_params_hash(domain_params))
|
||||||
|
end
|
||||||
|
|
||||||
current_user.request(xml)
|
current_user.request(xml)
|
||||||
end
|
end
|
||||||
|
|
|
@ -4,6 +4,7 @@ class Domain < ActiveRecord::Base
|
||||||
include Versions # version/domain_version.rb
|
include Versions # version/domain_version.rb
|
||||||
include Statuses
|
include Statuses
|
||||||
include Concerns::Domain::Expirable
|
include Concerns::Domain::Expirable
|
||||||
|
include Concerns::Domain::Activatable
|
||||||
|
|
||||||
has_paper_trail class_name: "DomainVersion", meta: { children: :children_log }
|
has_paper_trail class_name: "DomainVersion", meta: { children: :children_log }
|
||||||
|
|
||||||
|
@ -694,8 +695,8 @@ class Domain < ActiveRecord::Base
|
||||||
statuses << DomainStatus::SERVER_HOLD if p_d && s_h
|
statuses << DomainStatus::SERVER_HOLD if p_d && s_h
|
||||||
|
|
||||||
if !self.class.nameserver_required?
|
if !self.class.nameserver_required?
|
||||||
statuses << DomainStatus::INACTIVE if nameservers.empty?
|
deactivate if nameservers.reject(&:marked_for_destruction?).empty?
|
||||||
statuses.delete(DomainStatus::INACTIVE) if nameservers.size >= Setting.ns_min_count
|
activate if nameservers.reject(&:marked_for_destruction?).size >= Setting.ns_min_count
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
# rubocop: enable Metrics/CyclomaticComplexity
|
# rubocop: enable Metrics/CyclomaticComplexity
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
class DomainNameserverValidator < ActiveModel::EachValidator
|
class DomainNameserverValidator < ActiveModel::EachValidator
|
||||||
def validate_each(record, attribute, value)
|
def validate_each(record, attribute, value)
|
||||||
return true if !Domain.nameserver_required? && value.empty?
|
|
||||||
|
|
||||||
min, max = options[:min].call, options[:max].call
|
min, max = options[:min].call, options[:max].call
|
||||||
values = value.reject(&:marked_for_destruction?)
|
values = value.reject(&:marked_for_destruction?)
|
||||||
|
|
||||||
|
return true if !Domain.nameserver_required? && values.empty?
|
||||||
|
|
||||||
return if values.size.between?(min, max)
|
return if values.size.between?(min, max)
|
||||||
association = options[:association] || attribute
|
association = options[:association] || attribute
|
||||||
record.errors.add(association, :out_of_range, { min: min, max: max })
|
record.errors.add(association, :out_of_range, { min: min, max: max })
|
||||||
|
|
|
@ -9,10 +9,11 @@
|
||||||
.panel-body
|
.panel-body
|
||||||
.form-group
|
.form-group
|
||||||
.col-md-3.control-label
|
.col-md-3.control-label
|
||||||
= label_tag "domain_nameservers_attributes_#{k}_hostname", t(:hostname), class: 'required'
|
= label_tag "domain_nameservers_attributes_#{k}_hostname", t(:hostname),
|
||||||
|
class: Domain.nameserver_required? ? 'required' : nil
|
||||||
.col-md-7
|
.col-md-7
|
||||||
= text_field_tag "domain[nameservers_attributes][#{k}][hostname]", v['hostname'],
|
= text_field_tag "domain[nameservers_attributes][#{k}][hostname]", v['hostname'],
|
||||||
class: 'form-control', required: true
|
class: 'form-control', required: Domain.nameserver_required?
|
||||||
.form-group
|
.form-group
|
||||||
.col-md-3.control-label
|
.col-md-3.control-label
|
||||||
= label_tag "domain_nameservers_attributes_#{k}_ipv4", t(:ipv4)
|
= label_tag "domain_nameservers_attributes_#{k}_ipv4", t(:ipv4)
|
||||||
|
|
68
spec/models/concerns/domain/activatable_spec.rb
Normal file
68
spec/models/concerns/domain/activatable_spec.rb
Normal file
|
@ -0,0 +1,68 @@
|
||||||
|
require 'rails_helper'
|
||||||
|
|
||||||
|
RSpec.describe Domain, db: false do
|
||||||
|
describe '#active?' do
|
||||||
|
context 'when :statuses does not contain :inactive' do
|
||||||
|
let(:domain) { described_class.new(statuses: []) }
|
||||||
|
|
||||||
|
it 'returns true' do
|
||||||
|
expect(domain.active?).to be true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'when :statuses contains :inactive' do
|
||||||
|
let(:domain) { described_class.new(statuses: [DomainStatus::INACTIVE]) }
|
||||||
|
|
||||||
|
it 'returns false' do
|
||||||
|
expect(domain.active?).to be false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
describe '#inactive?' do
|
||||||
|
context 'when :statuses contains :inactive' do
|
||||||
|
let(:domain) { described_class.new(statuses: [DomainStatus::INACTIVE]) }
|
||||||
|
|
||||||
|
it 'returns true' do
|
||||||
|
expect(domain.inactive?).to be true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'when :statuses does not contain :inactive' do
|
||||||
|
let(:domain) { described_class.new(statuses: []) }
|
||||||
|
|
||||||
|
it 'returns false' do
|
||||||
|
expect(domain.inactive?).to be false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
describe '#activate' do
|
||||||
|
let(:domain) { described_class.new(statuses: [DomainStatus::INACTIVE]) }
|
||||||
|
|
||||||
|
it 'activates domain' do
|
||||||
|
domain.activate
|
||||||
|
expect(domain).to be_active
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
describe '#deactivate' do
|
||||||
|
context 'when active' do
|
||||||
|
let(:domain) { described_class.new }
|
||||||
|
|
||||||
|
it 'deactivates domain' do
|
||||||
|
domain.deactivate
|
||||||
|
expect(domain).to be_inactive
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'when inactive' do
|
||||||
|
let(:domain) { described_class.new(statuses: [DomainStatus::INACTIVE]) }
|
||||||
|
|
||||||
|
it 'does not add :inactive status' do
|
||||||
|
domain.deactivate
|
||||||
|
expect(domain.statuses).to eq([DomainStatus::INACTIVE])
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -31,7 +31,7 @@ RSpec.describe 'EPP domain:create' do
|
||||||
allow(Domain).to receive(:nameserver_required?).and_return(false)
|
allow(Domain).to receive(:nameserver_required?).and_return(false)
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when minimum nameserver count is not satisfied' do
|
context 'when minimum nameserver count requirement is not satisfied' do
|
||||||
let(:request_xml) { <<-XML
|
let(:request_xml) { <<-XML
|
||||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
|
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
|
||||||
|
@ -43,7 +43,6 @@ RSpec.describe 'EPP domain:create' do
|
||||||
<domain:ns>
|
<domain:ns>
|
||||||
<domain:hostAttr>
|
<domain:hostAttr>
|
||||||
<domain:hostName>ns.test.com</domain:hostName>
|
<domain:hostName>ns.test.com</domain:hostName>
|
||||||
<domain:hostAddr ip="v4">192.168.1.1</domain:hostAddr>
|
|
||||||
</domain:hostAttr>
|
</domain:hostAttr>
|
||||||
</domain:ns>
|
</domain:ns>
|
||||||
<domain:registrant>test</domain:registrant>
|
<domain:registrant>test</domain:registrant>
|
||||||
|
@ -122,77 +121,4 @@ RSpec.describe 'EPP domain:create' do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when nameserver is required' do
|
|
||||||
before :example do
|
|
||||||
allow(Domain).to receive(:nameserver_required?).and_return(true)
|
|
||||||
Setting.ns_min_count = 1
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'when nameserver is present' do
|
|
||||||
let(:request_xml) { <<-XML
|
|
||||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
|
||||||
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
|
|
||||||
<command>
|
|
||||||
<create>
|
|
||||||
<domain:create xmlns:domain="https://epp.tld.ee/schema/domain-eis-1.0.xsd">
|
|
||||||
<domain:name>test.com</domain:name>
|
|
||||||
<domain:period unit="y">1</domain:period>
|
|
||||||
<domain:ns>
|
|
||||||
<domain:hostAttr>
|
|
||||||
<domain:hostName>ns.test.com</domain:hostName>
|
|
||||||
<domain:hostAddr ip="v4">192.168.1.1</domain:hostAddr>
|
|
||||||
</domain:hostAttr>
|
|
||||||
</domain:ns>
|
|
||||||
<domain:registrant>test</domain:registrant>
|
|
||||||
<domain:contact type="admin">test</domain:contact>
|
|
||||||
<domain:contact type="tech">test</domain:contact>
|
|
||||||
</domain:create>
|
|
||||||
</create>
|
|
||||||
<extension>
|
|
||||||
<eis:extdata xmlns:eis="https://epp.tld.ee/schema/eis-1.0.xsd">
|
|
||||||
<eis:legalDocument type="pdf">#{Base64.encode64('a' * 5000)}</eis:legalDocument>
|
|
||||||
</eis:extdata>
|
|
||||||
</extension>
|
|
||||||
</command>
|
|
||||||
</epp>
|
|
||||||
XML
|
|
||||||
}
|
|
||||||
|
|
||||||
it 'returns epp code of 1000' do
|
|
||||||
post '/epp/command/create', frame: request_xml
|
|
||||||
expect(response_code).to eq('1000'), "Expected EPP code of 1000, got #{response_code} (#{response_description})"
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'when nameserver is absent' do
|
|
||||||
let(:request_xml) { <<-XML
|
|
||||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
|
||||||
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
|
|
||||||
<command>
|
|
||||||
<create>
|
|
||||||
<domain:create xmlns:domain="https://epp.tld.ee/schema/domain-eis-1.0.xsd">
|
|
||||||
<domain:name>test.com</domain:name>
|
|
||||||
<domain:period unit="y">1</domain:period>
|
|
||||||
<domain:registrant>test</domain:registrant>
|
|
||||||
<domain:contact type="admin">test</domain:contact>
|
|
||||||
<domain:contact type="tech">test</domain:contact>
|
|
||||||
</domain:create>
|
|
||||||
</create>
|
|
||||||
<extension>
|
|
||||||
<eis:extdata xmlns:eis="https://epp.tld.ee/schema/eis-1.0.xsd">
|
|
||||||
<eis:legalDocument type="pdf">#{Base64.encode64('a' * 5000)}</eis:legalDocument>
|
|
||||||
</eis:extdata>
|
|
||||||
</extension>
|
|
||||||
</command>
|
|
||||||
</epp>
|
|
||||||
XML
|
|
||||||
}
|
|
||||||
|
|
||||||
it 'returns epp code of 2003' do
|
|
||||||
post '/epp/command/create', frame: request_xml
|
|
||||||
expect(response_code).to eq('2003')
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
100
spec/requests/epp/domain/create/required_nameserver_spec.rb
Normal file
100
spec/requests/epp/domain/create/required_nameserver_spec.rb
Normal file
|
@ -0,0 +1,100 @@
|
||||||
|
require 'rails_helper'
|
||||||
|
|
||||||
|
RSpec.describe 'EPP domain:create' do
|
||||||
|
subject(:response_xml) { Nokogiri::XML(response.body) }
|
||||||
|
subject(:response_code) { response_xml.xpath('//xmlns:result').first['code'] }
|
||||||
|
subject(:response_description) { response_xml.css('result msg').text }
|
||||||
|
|
||||||
|
before :example do
|
||||||
|
travel_to Time.zone.parse('05.07.2010')
|
||||||
|
|
||||||
|
registrar = create(:registrar)
|
||||||
|
user = create(:api_user_epp, registrar: registrar)
|
||||||
|
create(:account, registrar: registrar, balance: 1.0)
|
||||||
|
|
||||||
|
create(:contact, code: 'test')
|
||||||
|
|
||||||
|
create(:pricelist,
|
||||||
|
category: 'com',
|
||||||
|
duration: '1year',
|
||||||
|
price: 1.to_money,
|
||||||
|
operation_category: 'create',
|
||||||
|
valid_from: Time.zone.parse('05.07.2010'),
|
||||||
|
valid_to: Time.zone.parse('05.07.2010')
|
||||||
|
)
|
||||||
|
|
||||||
|
sign_in_to_epp_area(user: user)
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'when nameserver is required' do
|
||||||
|
before :example do
|
||||||
|
allow(Domain).to receive(:nameserver_required?).and_return(true)
|
||||||
|
Setting.ns_min_count = 1
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'when minimum nameserver count requirement is satisfied' do
|
||||||
|
let(:request_xml) { <<-XML
|
||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
|
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
|
||||||
|
<command>
|
||||||
|
<create>
|
||||||
|
<domain:create xmlns:domain="https://epp.tld.ee/schema/domain-eis-1.0.xsd">
|
||||||
|
<domain:name>test.com</domain:name>
|
||||||
|
<domain:period unit="y">1</domain:period>
|
||||||
|
<domain:ns>
|
||||||
|
<domain:hostAttr>
|
||||||
|
<domain:hostName>ns.test.com</domain:hostName>
|
||||||
|
</domain:hostAttr>
|
||||||
|
</domain:ns>
|
||||||
|
<domain:registrant>test</domain:registrant>
|
||||||
|
<domain:contact type="admin">test</domain:contact>
|
||||||
|
<domain:contact type="tech">test</domain:contact>
|
||||||
|
</domain:create>
|
||||||
|
</create>
|
||||||
|
<extension>
|
||||||
|
<eis:extdata xmlns:eis="https://epp.tld.ee/schema/eis-1.0.xsd">
|
||||||
|
<eis:legalDocument type="pdf">#{Base64.encode64('a' * 5000)}</eis:legalDocument>
|
||||||
|
</eis:extdata>
|
||||||
|
</extension>
|
||||||
|
</command>
|
||||||
|
</epp>
|
||||||
|
XML
|
||||||
|
}
|
||||||
|
|
||||||
|
it 'returns epp code of 1000' do
|
||||||
|
post '/epp/command/create', frame: request_xml
|
||||||
|
expect(response_code).to eq('1000'), "Expected EPP code of 1000, got #{response_code} (#{response_description})"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'when nameservers are absent' do
|
||||||
|
let(:request_xml) { <<-XML
|
||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
|
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
|
||||||
|
<command>
|
||||||
|
<create>
|
||||||
|
<domain:create xmlns:domain="https://epp.tld.ee/schema/domain-eis-1.0.xsd">
|
||||||
|
<domain:name>test.com</domain:name>
|
||||||
|
<domain:period unit="y">1</domain:period>
|
||||||
|
<domain:registrant>test</domain:registrant>
|
||||||
|
<domain:contact type="admin">test</domain:contact>
|
||||||
|
<domain:contact type="tech">test</domain:contact>
|
||||||
|
</domain:create>
|
||||||
|
</create>
|
||||||
|
<extension>
|
||||||
|
<eis:extdata xmlns:eis="https://epp.tld.ee/schema/eis-1.0.xsd">
|
||||||
|
<eis:legalDocument type="pdf">#{Base64.encode64('a' * 5000)}</eis:legalDocument>
|
||||||
|
</eis:extdata>
|
||||||
|
</extension>
|
||||||
|
</command>
|
||||||
|
</epp>
|
||||||
|
XML
|
||||||
|
}
|
||||||
|
|
||||||
|
it 'returns epp code of 2003' do
|
||||||
|
post '/epp/command/create', frame: request_xml
|
||||||
|
expect(response_code).to eq('2003')
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
92
spec/requests/epp/domain/update/nameserver_add_spec.rb
Normal file
92
spec/requests/epp/domain/update/nameserver_add_spec.rb
Normal file
|
@ -0,0 +1,92 @@
|
||||||
|
require 'rails_helper'
|
||||||
|
|
||||||
|
RSpec.describe 'EPP domain:update' do
|
||||||
|
let!(:domain) { create(:domain, name: 'test.com') }
|
||||||
|
subject(:response_xml) { Nokogiri::XML(response.body) }
|
||||||
|
subject(:response_code) { response_xml.xpath('//xmlns:result').first['code'] }
|
||||||
|
subject(:response_description) { response_xml.css('result msg').text }
|
||||||
|
|
||||||
|
before :example do
|
||||||
|
sign_in_to_epp_area
|
||||||
|
|
||||||
|
allow(Domain).to receive(:nameserver_required?).and_return(false)
|
||||||
|
Setting.ns_min_count = 2
|
||||||
|
Setting.ns_max_count = 3
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'when nameserver count is less than minimum' do
|
||||||
|
let(:request_xml) { <<-XML
|
||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
|
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
|
||||||
|
<command>
|
||||||
|
<update>
|
||||||
|
<domain:update xmlns:domain="https://epp.tld.ee/schema/domain-eis-1.0.xsd">
|
||||||
|
<domain:name>test.com</domain:name>
|
||||||
|
<domain:add>
|
||||||
|
<domain:ns>
|
||||||
|
<domain:hostAttr>
|
||||||
|
<domain:hostName>ns1.test.ee</domain:hostName>
|
||||||
|
</domain:hostAttr>
|
||||||
|
</domain:ns>
|
||||||
|
</domain:add>
|
||||||
|
</domain:update>
|
||||||
|
</update>
|
||||||
|
</command>
|
||||||
|
</epp>
|
||||||
|
XML
|
||||||
|
}
|
||||||
|
|
||||||
|
it 'returns epp code of 2308' do
|
||||||
|
post '/epp/command/update', frame: request_xml
|
||||||
|
expect(response_code).to eq('2308'), "Expected EPP code of 2308, got #{response_code} (#{response_description})"
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'returns epp description' do
|
||||||
|
post '/epp/command/update', frame: request_xml
|
||||||
|
|
||||||
|
description = 'Data management policy violation;' \
|
||||||
|
" Nameserver count must be between #{Setting.ns_min_count}-#{Setting.ns_max_count}" \
|
||||||
|
' for active domains [nameservers]'
|
||||||
|
expect(response_description).to eq(description)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'when nameserver count satisfies required minimum' do
|
||||||
|
let!(:domain) { create(:domain, name: 'test.com') }
|
||||||
|
let(:request_xml) { <<-XML
|
||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
|
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
|
||||||
|
<command>
|
||||||
|
<update>
|
||||||
|
<domain:update xmlns:domain="https://epp.tld.ee/schema/domain-eis-1.0.xsd">
|
||||||
|
<domain:name>test.com</domain:name>
|
||||||
|
<domain:add>
|
||||||
|
<domain:ns>
|
||||||
|
<domain:hostAttr>
|
||||||
|
<domain:hostName>ns1.test.ee</domain:hostName>
|
||||||
|
</domain:hostAttr>
|
||||||
|
<domain:hostAttr>
|
||||||
|
<domain:hostName>ns2.test.ee</domain:hostName>
|
||||||
|
</domain:hostAttr>
|
||||||
|
</domain:ns>
|
||||||
|
</domain:add>
|
||||||
|
</domain:update>
|
||||||
|
</update>
|
||||||
|
</command>
|
||||||
|
</epp>
|
||||||
|
XML
|
||||||
|
}
|
||||||
|
|
||||||
|
it 'returns epp code of 1000' do
|
||||||
|
post '/epp/command/update', frame: request_xml
|
||||||
|
expect(response_code).to eq('1000'), "Expected EPP code of 1000, got #{response_code} (#{response_description})"
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'removes inactive status' do
|
||||||
|
post '/epp/command/update', frame: request_xml
|
||||||
|
|
||||||
|
domain = Domain.find_by(name: 'test.com')
|
||||||
|
expect(domain.statuses).to_not include(DomainStatus::INACTIVE)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
106
spec/requests/epp/domain/update/nameserver_remove_spec.rb
Normal file
106
spec/requests/epp/domain/update/nameserver_remove_spec.rb
Normal file
|
@ -0,0 +1,106 @@
|
||||||
|
require 'rails_helper'
|
||||||
|
|
||||||
|
RSpec.describe 'EPP domain:update' do
|
||||||
|
subject(:response_xml) { Nokogiri::XML(response.body) }
|
||||||
|
subject(:response_code) { response_xml.xpath('//xmlns:result').first['code'] }
|
||||||
|
subject(:response_description) { response_xml.css('result msg').text }
|
||||||
|
|
||||||
|
before :example do
|
||||||
|
sign_in_to_epp_area
|
||||||
|
|
||||||
|
allow(Domain).to receive(:nameserver_required?).and_return(false)
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'when remaining nameserver count is less than required minimum' do
|
||||||
|
let!(:domain) { create(:domain, name: 'test.com') }
|
||||||
|
let(:request_xml) { <<-XML
|
||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
|
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
|
||||||
|
<command>
|
||||||
|
<update>
|
||||||
|
<domain:update xmlns:domain="https://epp.tld.ee/schema/domain-eis-1.0.xsd">
|
||||||
|
<domain:name>test.com</domain:name>
|
||||||
|
<domain:rem>
|
||||||
|
<domain:ns>
|
||||||
|
<domain:hostAttr>
|
||||||
|
<domain:hostName>ns1.test.ee</domain:hostName>
|
||||||
|
</domain:hostAttr>
|
||||||
|
</domain:ns>
|
||||||
|
</domain:rem>
|
||||||
|
</domain:update>
|
||||||
|
</update>
|
||||||
|
</command>
|
||||||
|
</epp>
|
||||||
|
XML
|
||||||
|
}
|
||||||
|
|
||||||
|
before :example do
|
||||||
|
Setting.ns_min_count = 2
|
||||||
|
Setting.ns_max_count = 3
|
||||||
|
|
||||||
|
domain.nameservers << create(:nameserver, hostname: 'ns1.test.ee')
|
||||||
|
domain.nameservers << create(:nameserver, hostname: 'ns2.test.ee')
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'returns epp code of 2308' do
|
||||||
|
post '/epp/command/update', frame: request_xml
|
||||||
|
expect(response_code).to eq('2308'), "Expected EPP code of 2308, got #{response_code} (#{response_description})"
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'returns epp description' do
|
||||||
|
post '/epp/command/update', frame: request_xml
|
||||||
|
|
||||||
|
description = 'Data management policy violation;' \
|
||||||
|
" Nameserver count must be between #{Setting.ns_min_count}-#{Setting.ns_max_count}" \
|
||||||
|
' for active domains [nameservers]'
|
||||||
|
expect(response_description).to eq(description)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'when all nameservers are removed' do
|
||||||
|
let!(:domain) { create(:domain, name: 'test.com') }
|
||||||
|
let(:request_xml) { <<-XML
|
||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
|
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
|
||||||
|
<command>
|
||||||
|
<update>
|
||||||
|
<domain:update xmlns:domain="https://epp.tld.ee/schema/domain-eis-1.0.xsd">
|
||||||
|
<domain:name>test.com</domain:name>
|
||||||
|
<domain:rem>
|
||||||
|
<domain:ns>
|
||||||
|
<domain:hostAttr>
|
||||||
|
<domain:hostName>ns1.test.ee</domain:hostName>
|
||||||
|
</domain:hostAttr>
|
||||||
|
<domain:hostAttr>
|
||||||
|
<domain:hostName>ns2.test.ee</domain:hostName>
|
||||||
|
</domain:hostAttr>
|
||||||
|
</domain:ns>
|
||||||
|
</domain:rem>
|
||||||
|
</domain:update>
|
||||||
|
</update>
|
||||||
|
</command>
|
||||||
|
</epp>
|
||||||
|
XML
|
||||||
|
}
|
||||||
|
|
||||||
|
before :example do
|
||||||
|
domain.nameservers << create(:nameserver, hostname: 'ns1.test.ee')
|
||||||
|
domain.nameservers << create(:nameserver, hostname: 'ns2.test.ee')
|
||||||
|
domain.activate
|
||||||
|
domain.save!
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'returns epp code of 1000' do
|
||||||
|
post '/epp/command/update', frame: request_xml
|
||||||
|
expect(response_code).to eq('1000'), "Expected EPP code of 1000, got #{response_code} (#{response_description})"
|
||||||
|
end
|
||||||
|
|
||||||
|
describe 'domain' do
|
||||||
|
it 'has status of inactive' do
|
||||||
|
post '/epp/command/update', frame: request_xml
|
||||||
|
domain = Domain.find_by(name: 'test.com')
|
||||||
|
expect(domain.statuses).to include(DomainStatus::INACTIVE)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -1,193 +0,0 @@
|
||||||
require 'rails_helper'
|
|
||||||
|
|
||||||
RSpec.describe 'EPP domain:update' do
|
|
||||||
let!(:domain) { create(:domain, name: 'test.com') }
|
|
||||||
subject(:response_xml) { Nokogiri::XML(response.body) }
|
|
||||||
subject(:response_code) { response_xml.xpath('//xmlns:result').first['code'] }
|
|
||||||
subject(:response_description) { response_xml.css('result msg').text }
|
|
||||||
|
|
||||||
before :example do
|
|
||||||
sign_in_to_epp_area
|
|
||||||
|
|
||||||
allow(Domain).to receive(:nameserver_required?).and_return(false)
|
|
||||||
Setting.ns_min_count = 2
|
|
||||||
Setting.ns_max_count = 3
|
|
||||||
end
|
|
||||||
|
|
||||||
describe 'nameserver add' do
|
|
||||||
context 'when nameserver count is less than minimum' do
|
|
||||||
let(:request_xml) { <<-XML
|
|
||||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
|
||||||
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
|
|
||||||
<command>
|
|
||||||
<update>
|
|
||||||
<domain:update xmlns:domain="https://epp.tld.ee/schema/domain-eis-1.0.xsd">
|
|
||||||
<domain:name>test.com</domain:name>
|
|
||||||
<domain:add>
|
|
||||||
<domain:ns>
|
|
||||||
<domain:hostAttr>
|
|
||||||
<domain:hostName>ns1.test.ee</domain:hostName>
|
|
||||||
</domain:hostAttr>
|
|
||||||
</domain:ns>
|
|
||||||
</domain:add>
|
|
||||||
</domain:update>
|
|
||||||
</update>
|
|
||||||
<extension>
|
|
||||||
<secDNS:update xmlns:secDNS="urn:ietf:params:xml:ns:secDNS-1.1"/>
|
|
||||||
<eis:extdata xmlns:eis="https://epp.tld.ee/schema/eis-1.0.xsd">
|
|
||||||
<eis:legalDocument type="pdf">#{Base64.encode64('a' * 5000)}</eis:legalDocument>
|
|
||||||
</eis:extdata>
|
|
||||||
</extension>
|
|
||||||
</command>
|
|
||||||
</epp>
|
|
||||||
XML
|
|
||||||
}
|
|
||||||
|
|
||||||
it 'returns epp code of 2308' do
|
|
||||||
post '/epp/command/update', frame: request_xml
|
|
||||||
expect(response_code).to eq('2308'), "Expected EPP code of 2308, got #{response_code} (#{response_description})"
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'returns epp description' do
|
|
||||||
post '/epp/command/update', frame: request_xml
|
|
||||||
|
|
||||||
description = 'Data management policy violation;' \
|
|
||||||
" Nameserver count must be between #{Setting.ns_min_count}-#{Setting.ns_max_count}" \
|
|
||||||
' for active domains [nameservers]'
|
|
||||||
expect(response_description).to eq(description)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'when nameserver count satisfies required minimum' do
|
|
||||||
let!(:domain) { create(:domain, name: 'test.com') }
|
|
||||||
let(:request_xml) { <<-XML
|
|
||||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
|
||||||
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
|
|
||||||
<command>
|
|
||||||
<update>
|
|
||||||
<domain:update xmlns:domain="https://epp.tld.ee/schema/domain-eis-1.0.xsd">
|
|
||||||
<domain:name>test.com</domain:name>
|
|
||||||
<domain:add>
|
|
||||||
<domain:ns>
|
|
||||||
<domain:hostAttr>
|
|
||||||
<domain:hostName>ns1.test.ee</domain:hostName>
|
|
||||||
</domain:hostAttr>
|
|
||||||
<domain:hostAttr>
|
|
||||||
<domain:hostName>ns2.test.ee</domain:hostName>
|
|
||||||
</domain:hostAttr>
|
|
||||||
</domain:ns>
|
|
||||||
</domain:add>
|
|
||||||
</domain:update>
|
|
||||||
</update>
|
|
||||||
<extension>
|
|
||||||
<secDNS:update xmlns:secDNS="urn:ietf:params:xml:ns:secDNS-1.1"/>
|
|
||||||
<eis:extdata xmlns:eis="https://epp.tld.ee/schema/eis-1.0.xsd">
|
|
||||||
<eis:legalDocument type="pdf">#{Base64.encode64('a' * 5000)}</eis:legalDocument>
|
|
||||||
</eis:extdata>
|
|
||||||
</extension>
|
|
||||||
</command>
|
|
||||||
</epp>
|
|
||||||
XML
|
|
||||||
}
|
|
||||||
|
|
||||||
it 'returns epp code of 1000' do
|
|
||||||
post '/epp/command/update', frame: request_xml
|
|
||||||
expect(response_code).to eq('1000'), "Expected EPP code of 1000, got #{response_code} (#{response_description})"
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'removes inactive status' do
|
|
||||||
post '/epp/command/update', frame: request_xml
|
|
||||||
|
|
||||||
domain = Domain.find_by(name: 'test.com')
|
|
||||||
expect(domain.statuses).to_not include(DomainStatus::INACTIVE)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
describe 'nameserver remove' do
|
|
||||||
before :example do
|
|
||||||
domain.nameservers << create(:nameserver, hostname: 'ns1.test.ee')
|
|
||||||
domain.nameservers << create(:nameserver, hostname: 'ns2.test.ee')
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'when nameserver count is less than minimum' do
|
|
||||||
let(:request_xml) { <<-XML
|
|
||||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
|
||||||
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
|
|
||||||
<command>
|
|
||||||
<update>
|
|
||||||
<domain:update xmlns:domain="https://epp.tld.ee/schema/domain-eis-1.0.xsd">
|
|
||||||
<domain:name>test.com</domain:name>
|
|
||||||
<domain:rem>
|
|
||||||
<domain:ns>
|
|
||||||
<domain:hostAttr>
|
|
||||||
<domain:hostName>ns1.test.ee</domain:hostName>
|
|
||||||
</domain:hostAttr>
|
|
||||||
</domain:ns>
|
|
||||||
</domain:rem>
|
|
||||||
</domain:update>
|
|
||||||
</update>
|
|
||||||
<extension>
|
|
||||||
<secDNS:update xmlns:secDNS="urn:ietf:params:xml:ns:secDNS-1.1"/>
|
|
||||||
<eis:extdata xmlns:eis="https://epp.tld.ee/schema/eis-1.0.xsd">
|
|
||||||
<eis:legalDocument type="pdf">#{Base64.encode64('a' * 5000)}</eis:legalDocument>
|
|
||||||
</eis:extdata>
|
|
||||||
</extension>
|
|
||||||
</command>
|
|
||||||
</epp>
|
|
||||||
XML
|
|
||||||
}
|
|
||||||
|
|
||||||
it 'returns epp code of 2308' do
|
|
||||||
post '/epp/command/update', frame: request_xml
|
|
||||||
expect(response_code).to eq('2308'), "Expected EPP code of 2308, got #{response_code} (#{response_description})"
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'returns epp description' do
|
|
||||||
post '/epp/command/update', frame: request_xml
|
|
||||||
|
|
||||||
description = 'Data management policy violation;' \
|
|
||||||
" Nameserver count must be between #{Setting.ns_min_count}-#{Setting.ns_max_count}" \
|
|
||||||
' for active domains [nameservers]'
|
|
||||||
expect(response_description).to eq(description)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'when all nameservers are removed' do
|
|
||||||
let(:request_xml) { <<-XML
|
|
||||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
|
||||||
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
|
|
||||||
<command>
|
|
||||||
<update>
|
|
||||||
<domain:update xmlns:domain="https://epp.tld.ee/schema/domain-eis-1.0.xsd">
|
|
||||||
<domain:name>test.com</domain:name>
|
|
||||||
<domain:rem>
|
|
||||||
<domain:ns>
|
|
||||||
<domain:hostAttr>
|
|
||||||
<domain:hostName>ns1.test.ee</domain:hostName>
|
|
||||||
</domain:hostAttr>
|
|
||||||
<domain:hostAttr>
|
|
||||||
<domain:hostName>ns2.test.ee</domain:hostName>
|
|
||||||
</domain:hostAttr>
|
|
||||||
</domain:ns>
|
|
||||||
</domain:rem>
|
|
||||||
</domain:update>
|
|
||||||
</update>
|
|
||||||
<extension>
|
|
||||||
<secDNS:update xmlns:secDNS="urn:ietf:params:xml:ns:secDNS-1.1"/>
|
|
||||||
<eis:extdata xmlns:eis="https://epp.tld.ee/schema/eis-1.0.xsd">
|
|
||||||
<eis:legalDocument type="pdf">#{Base64.encode64('a' * 5000)}</eis:legalDocument>
|
|
||||||
</eis:extdata>
|
|
||||||
</extension>
|
|
||||||
</command>
|
|
||||||
</epp>
|
|
||||||
XML
|
|
||||||
}
|
|
||||||
|
|
||||||
it 'returns epp code of 1000' do
|
|
||||||
post '/epp/command/update', frame: request_xml
|
|
||||||
expect(response_code).to eq('2308'), "Expected EPP code of 1000, got #{response_code} (#{response_description})"
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
Loading…
Add table
Add a link
Reference in a new issue