diff --git a/app/helpers/epp/domains_helper.rb b/app/helpers/epp/domains_helper.rb index fff6fc4e0..4ef04679a 100644 --- a/app/helpers/epp/domains_helper.rb +++ b/app/helpers/epp/domains_helper.rb @@ -6,7 +6,7 @@ module Epp::DomainsHelper handle_errors(@domain) and return unless @domain.parse_and_attach_domain_dependencies(@ph, parsed_frame) handle_errors(@domain) and return unless @domain.save - render '/epp/domains/success' + render '/epp/domains/create' end end diff --git a/app/views/epp/domains/create.xml.builder b/app/views/epp/domains/create.xml.builder new file mode 100644 index 000000000..ada6b7362 --- /dev/null +++ b/app/views/epp/domains/create.xml.builder @@ -0,0 +1,17 @@ +xml.epp_head do + xml.response do + xml.result('code' => '1000') do + xml.msg 'Command completed successfully' + end + + xml.resData do + xml.tag!('domain:creData', 'xmlns:domain' => 'urn:ietf:params:xml:ns:domain-1.0') do + xml.tag!('domain:name', @domain.name) + xml.tag!('domain:crDate', @domain.created_at) + xml.tag!('domain:exDate', @domain.valid_to) + end + end + end + + xml << render('/epp/shared/trID') +end 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..7f82a7b36 100644 --- a/spec/epp/domain_spec.rb +++ b/spec/epp/domain_spec.rb @@ -38,15 +38,25 @@ describe 'EPP Domain', epp: true do it 'creates a domain' do response = epp_request(domain_create_xml, :xml) + + d = Domain.first + expect(response[:result_code]).to eq('1000') expect(response[:msg]).to eq('Command completed successfully') + + cre_data = response[:parsed].css('creData') + + expect(cre_data.css('name').text).to eq('example.ee') + expect(cre_data.css('crDate').text).to eq(d.created_at.to_time.utc.to_s) + expect(cre_data.css('exDate').text).to eq(d.valid_to.to_time.utc.to_s) + expect(response[:clTRID]).to eq('ABC-12345') - expect(Domain.first.registrar.name).to eq('Zone Media OÜ') - expect(Domain.first.tech_contacts.count).to eq 2 - expect(Domain.first.admin_contacts.count).to eq 1 + expect(d.registrar.name).to eq('Zone Media OÜ') + expect(d.tech_contacts.count).to eq 2 + expect(d.admin_contacts.count).to eq 1 - expect(Domain.first.nameservers.count).to eq(2) + expect(d.nameservers.count).to eq(2) end it 'does not create duplicate domain' do @@ -209,6 +219,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 +237,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)