diff --git a/Gemfile b/Gemfile
index 11ada97ca..9a83dfb83 100644
--- a/Gemfile
+++ b/Gemfile
@@ -85,7 +85,7 @@ group :development, :test do
gem 'epp', '~> 1.4.0'
# EPP XMLs
- gem 'epp-xml', '~> 0.1.0'
+ gem 'epp-xml', '~> 0.2.0'
# Replacement for fixtures
gem 'fabrication', '~> 2.11.3'
diff --git a/Gemfile.lock b/Gemfile.lock
index 75bfcd682..c23970e87 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -93,7 +93,7 @@ GEM
epp (1.4.0)
hpricot
libxml-ruby
- epp-xml (0.1.0)
+ epp-xml (0.2.0)
activesupport (~> 4.1)
builder (~> 3.2)
equalizer (0.0.9)
@@ -362,7 +362,7 @@ DEPENDENCIES
database_cleaner (~> 1.3.0)
devise (~> 3.3.0)
epp (~> 1.4.0)
- epp-xml (~> 0.1.0)
+ epp-xml (~> 0.2.0)
fabrication (~> 2.11.3)
faker (~> 1.3.0)
guard (~> 2.6.1)
diff --git a/app/helpers/epp/domains_helper.rb b/app/helpers/epp/domains_helper.rb
index 7b8295f35..d8d8aca9a 100644
--- a/app/helpers/epp/domains_helper.rb
+++ b/app/helpers/epp/domains_helper.rb
@@ -51,10 +51,10 @@ module Epp::DomainsHelper
handle_errors(@domain) and return unless @domain
- @domain.parse_and_attach_domain_dependencies(parsed_frame.css('add'))
- @domain.parse_and_attach_ds_data(parsed_frame.css('extension add'))
@domain.parse_and_detach_domain_dependencies(parsed_frame.css('rem'))
@domain.parse_and_detach_ds_data(parsed_frame.css('extension rem'))
+ @domain.parse_and_attach_domain_dependencies(parsed_frame.css('add'))
+ @domain.parse_and_attach_ds_data(parsed_frame.css('extension add'))
@domain.parse_and_update_domain_dependencies(parsed_frame.css('chg'))
if @domain.errors.any?
diff --git a/app/models/epp/epp_domain.rb b/app/models/epp/epp_domain.rb
index 87dfb6878..3148ff9ed 100644
--- a/app/models/epp/epp_domain.rb
+++ b/app/models/epp/epp_domain.rb
@@ -171,7 +171,6 @@ class Epp::EppDomain < Domain
to_delete << nameserver
end
end
-
nameservers.delete(to_delete)
end
@@ -239,7 +238,6 @@ class Epp::EppDomain < Domain
def detach_dnskeys(dnssec_data)
return false unless validate_dnssec_data(dnssec_data)
-
to_delete = []
dnssec_data[:ds_data].each do |x|
ds = dnskeys.where(ds_key_tag: x[:ds_key_tag])
@@ -250,7 +248,6 @@ class Epp::EppDomain < Domain
end
end
- to_delete = []
dnssec_data[:key_data].each do |x|
ds = dnskeys.where(public_key: x[:public_key])
if ds.blank?
@@ -392,11 +389,13 @@ class Epp::EppDomain < Domain
def parse_nameservers_from_frame(parsed_frame)
res = []
parsed_frame.css('hostAttr').each do |x|
- res << {
+ host_attr = {
hostname: x.css('hostName').first.try(:text),
ipv4: x.css('hostAddr[ip="v4"]').first.try(:text),
ipv6: x.css('hostAddr[ip="v6"]').first.try(:text)
}
+
+ res << host_attr.delete_if { |_k, v| v.blank? }
end
parsed_frame.css('hostObj').each do |x|
diff --git a/spec/epp/domain_spec.rb b/spec/epp/domain_spec.rb
index 67e6a16b9..984bcc003 100644
--- a/spec/epp/domain_spec.rb
+++ b/spec/epp/domain_spec.rb
@@ -810,7 +810,7 @@ describe 'EPP Domain', epp: true do
end
it 'updates domain and adds objects', pending: true do
- xml = domain_update_xml({
+ xml = EppXml::Domain.update({
add: [
{
ns: [
@@ -893,7 +893,7 @@ describe 'EPP Domain', epp: true do
it 'updates a domain and removes objects' do
Fabricate(:contact, code: 'mak21')
- xml = domain_update_xml({
+ xml = EppXml::Domain.update({
add: [
{
ns: [
@@ -931,7 +931,7 @@ describe 'EPP Domain', epp: true do
d = Domain.last
expect(d.dnskeys.count).to eq(2)
- xml = domain_update_xml({
+ xml = EppXml::Domain.update({
rem: [
{
ns: [
@@ -982,7 +982,7 @@ describe 'EPP Domain', epp: true do
it 'does not add duplicate objects to domain' do
Fabricate(:contact, code: 'mak21')
- xml = domain_update_xml({
+ xml = EppXml::Domain.update({
add: [
ns: [
{ hostObj: { value: 'ns1.example.com' } }
@@ -1008,7 +1008,7 @@ describe 'EPP Domain', epp: true do
]
}
- response = epp_request(domain_update_xml(xml_params), :xml)
+ response = epp_request(EppXml::Domain.update(xml_params), :xml)
expect(response[:results][0][:result_code]).to eq('1000')
d = Domain.last
@@ -1018,7 +1018,7 @@ describe 'EPP Domain', epp: true do
end
it 'does not assign invalid status to domain' do
- xml = domain_update_xml({
+ xml = EppXml::Domain.update({
add: [
status: { value: '', attrs: { s: 'invalidStatus' } }
]
diff --git a/spec/epp/epp_helper_spec.rb b/spec/epp/epp_helper_spec.rb
index 61346d231..00d49c933 100644
--- a/spec/epp/epp_helper_spec.rb
+++ b/spec/epp/epp_helper_spec.rb
@@ -43,158 +43,6 @@ describe 'EPP Helper', epp: true do
expect(generated).to eq(expected)
end
- it 'generates valid update xml' do
- # Detailed update
- expected = Nokogiri::XML('
-
-
-
-
- example.ee
-
-
- ns2.example.com
-
- mak21
-
- Payment overdue.
-
-
-
- ns1.example.com
-
- sh8013
-
-
-
- mak21
-
-
-
- ABC-12345
-
-
- ').to_s.squish
-
- xml = domain_update_xml(
- name: { value: 'example.ee' },
- add: [
- { ns:
- [
- hostObj: { value: 'ns1.example.com' },
- hostObj: { value: 'ns2.example.com' }
- ]
- },
- { contact: { attrs: { type: 'tech' }, value: 'mak21' } },
- { status: { attrs: { s: 'clientUpdateProhibited' }, value: '' } },
- { status: { attrs: { s: 'clientHold', lang: 'en' }, value: 'Payment overdue.' } }
- ],
- rem: [
- ns: [
- hostObj: { value: 'ns1.example.com' }
- ],
- contact: { attrs: { type: 'tech' }, value: 'sh8013' },
- status: { attrs: { s: 'clientUpdateProhibited' }, value: '' }
- ],
- chg: [
- registrant: { value: 'mak21' }
- ]
- )
-
- generated = Nokogiri::XML(xml).to_s.squish
- expect(generated).to eq(expected)
-
- # Update with NS IP-s
-
- expected = Nokogiri::XML('
-
-
-
-
- one.ee
-
- sh8013
- Payment overdue.
-
-
-
-
- ns1.example.net
- 192.0.2.2
- 1080:0:0:0:8:800:200C:417A
-
-
- sh8013
-
-
-
- sh8013
-
-
-
- ABC-12345
-
-
- ').to_s.squish
-
- xml = domain_update_xml(
- name: { value: 'one.ee' },
- add: [
- ns: nil,
- contact: { value: 'sh8013', attrs: { type: 'admin' } },
- status: { value: 'Payment overdue.', attrs: { s: 'testStatus', lang: 'et' } }
- ],
- rem: [
- ns: [
- hostAttr: [
- { hostName: { value: 'ns1.example.net' } },
- { hostAddr: { value: '192.0.2.2', attrs: { ip: 'v4' } } },
- { hostAddr: { value: '1080:0:0:0:8:800:200C:417A', attrs: { ip: 'v6' } } }
- ]
- ],
- contact: { attrs: { type: 'tech' }, value: 'sh8013' },
- status: { attrs: { s: 'clientUpdateProhibited' }, value: '' }
- ],
- chg: [
- registrant: { value: 'sh8013' }
- ]
- )
-
- generated = Nokogiri::XML(xml).to_s.squish
- expect(generated).to eq(expected)
-
- ## Update with chg
-
- expected = Nokogiri::XML('
-
-
-
-
- example.ee
-
- mak21
-
-
-
- ABC-12345
-
-
- ').to_s.squish
-
- xml = domain_update_xml(
- chg: [
- registrant: { value: 'mak21' }
- ]
- )
- generated = Nokogiri::XML(xml).to_s.squish
- expect(generated).to eq(expected)
- end
-
it 'generates valid transfer xml' do
expected = Nokogiri::XML('
diff --git a/spec/support/epp.rb b/spec/support/epp.rb
index ecb254a0d..ab57f2b26 100644
--- a/spec/support/epp.rb
+++ b/spec/support/epp.rb
@@ -73,34 +73,6 @@ module Epp
end
end
- def domain_update_xml(xml_params = {}, dnssec_params = false)
- defaults = {
- name: { value: 'example.ee' }
- }
-
- xml_params = defaults.deep_merge(xml_params)
-
- xml = Builder::XmlMarkup.new
-
- xml.instruct!(:xml, standalone: 'no')
- xml.epp('xmlns' => 'urn:ietf:params:xml:ns:epp-1.0') do
- xml.command do
- xml.update do
- xml.tag!('domain:update', 'xmlns:domain' => 'urn:ietf:params:xml:ns:domain-1.0') do
- generate_xml_from_hash(xml_params, xml, 'domain:')
- end
- end
-
- xml.extension do
- xml.tag!('secDNS:create', 'xmlns:secDNS' => 'urn:ietf:params:xml:ns:secDNS-1.1') do
- generate_xml_from_hash(dnssec_params, xml, 'secDNS:')
- end
- end if dnssec_params != false
- xml.clTRID 'ABC-12345'
- end
- end
- end
-
def generate_xml_from_hash(xml_params, xml, ns = '')
xml_params.each do |k, v|
# Value is a hash which has string type value