From df6394d7712680d8e2d8879319691033e5fa3f8a Mon Sep 17 00:00:00 2001 From: Martin Lensment Date: Wed, 27 Aug 2014 14:05:17 +0300 Subject: [PATCH] Return detailed ns info with info request --- app/views/epp/domains/info.xml.builder | 10 +++++++++- spec/epp/domain_spec.rb | 8 +++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/app/views/epp/domains/info.xml.builder b/app/views/epp/domains/info.xml.builder index 4fa2d1b48..564487370 100644 --- a/app/views/epp/domains/info.xml.builder +++ b/app/views/epp/domains/info.xml.builder @@ -24,7 +24,15 @@ xml.epp_head do xml.tag!('domain:ns') do @domain.nameservers.each do |x| - xml.tag!('domain:hostObj', x.hostname) + if x.ipv4.present? || x.ipv6.present? + xml.tag!('domain:hostAttr') do + xml.tag!('domain:hostName', x.hostname) + xml.tag!('domain:hostAddr', x.ipv4, 'ip' => 'v4') if x.ipv4.present? + xml.tag!('domain:hostAddr', x.ipv6, 'ip' => 'v6') if x.ipv6.present? + end + else + xml.tag!('domain:hostObj', x.hostname) + end end end diff --git a/spec/epp/domain_spec.rb b/spec/epp/domain_spec.rb index 192358de8..6a58a7767 100644 --- a/spec/epp/domain_spec.rb +++ b/spec/epp/domain_spec.rb @@ -209,6 +209,8 @@ describe 'EPP Domain', epp: true do it 'returns domain info' do d = Domain.first d.domain_statuses.create(setting: Setting.find_by(code: 'client_hold'), description: 'Payment overdue.') + d.nameservers.create(hostname: 'ns1.example.com', ipv4: '192.168.1.1', ipv6: '1080:0:0:0:8:800:200C:417A') + response = epp_request(domain_info_xml, :xml) expect(response[:results][0][:result_code]).to eq('1000') expect(response[:results][0][:msg]).to eq('Command completed successfully') @@ -225,9 +227,13 @@ describe 'EPP Domain', epp: true do expect(admin_contacts_from_request).to eq(admin_contacts_existing) hosts_from_request = inf_data.css('hostObj').map { |x| x.text } - hosts_existing = d.nameservers.pluck(:hostname) + hosts_existing = d.nameservers.where(ipv4: nil).pluck(:hostname) expect(hosts_from_request).to eq(hosts_existing) + + expect(inf_data.css('hostName').first.text).to eq('ns1.example.com') + expect(inf_data.css('hostAddr').first.text).to eq('192.168.1.1') + expect(inf_data.css('hostAddr').last.text).to eq('1080:0:0:0:8:800:200C:417A') expect(inf_data.css('crDate').text).to eq(d.created_at.to_time.utc.to_s) expect(inf_data.css('exDate').text).to eq(d.valid_to.to_time.utc.to_s)