From 952b379aaff0b4ddbbac0db550964c6f08858206 Mon Sep 17 00:00:00 2001 From: Martin Lensment Date: Fri, 7 Nov 2014 17:52:13 +0200 Subject: [PATCH] Refactor domain create xmls to builders --- spec/epp/domain_spec.rb | 5 +- .../requests/domains/create_w_host_attrs.xml | 30 --------- .../domains/create_w_invalid_ns_ip.xml | 30 --------- spec/support/epp.rb | 65 +++++++++++++++++++ 4 files changed, 67 insertions(+), 63 deletions(-) delete mode 100644 spec/epp/requests/domains/create_w_host_attrs.xml delete mode 100644 spec/epp/requests/domains/create_w_invalid_ns_ip.xml diff --git a/spec/epp/domain_spec.rb b/spec/epp/domain_spec.rb index c533576c3..83076ba3d 100644 --- a/spec/epp/domain_spec.rb +++ b/spec/epp/domain_spec.rb @@ -323,7 +323,6 @@ describe 'EPP Domain', epp: true do { hostObj: { value: 'invalid1-' } }, { hostObj: { value: '-invalid2' } } ] - }) response = epp_request(xml, :xml) @@ -332,7 +331,7 @@ describe 'EPP Domain', epp: true do end it 'creates domain with nameservers with ips' do - epp_request('domains/create_w_host_attrs.xml') + epp_request(domain_create_with_host_attrs, :xml) expect(Domain.first.nameservers.count).to eq(2) ns = Domain.first.nameservers.first expect(ns.ipv4).to eq('192.0.2.2') @@ -340,7 +339,7 @@ describe 'EPP Domain', epp: true do end it 'returns error when nameserver has invalid ips' do - response = epp_request('domains/create_w_invalid_ns_ip.xml') + response = epp_request(domain_create_with_invalid_ns_ip_xml, :xml) expect(response[:results][0][:result_code]).to eq '2005' expect(response[:results][0][:msg]).to eq 'IPv4 is invalid' expect(response[:results][0][:value]).to eq '192.0.2.2.invalid' diff --git a/spec/epp/requests/domains/create_w_host_attrs.xml b/spec/epp/requests/domains/create_w_host_attrs.xml deleted file mode 100644 index 173649aff..000000000 --- a/spec/epp/requests/domains/create_w_host_attrs.xml +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - example.ee - 1 - - - ns1.example.net - 192.0.2.2 - 1080:0:0:0:8:800:200C:417A - - - ns2.example.net - - - jd1234 - sh8013 - sh8013 - sh801333 - - 2fooBAR - - - - ABC-12345 - - diff --git a/spec/epp/requests/domains/create_w_invalid_ns_ip.xml b/spec/epp/requests/domains/create_w_invalid_ns_ip.xml deleted file mode 100644 index 80ef19ec2..000000000 --- a/spec/epp/requests/domains/create_w_invalid_ns_ip.xml +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - example.ee - 1 - - - ns1.example.net - 192.0.2.2.invalid - - - ns2.example.net - invalid_ipv6 - - - jd1234 - sh8013 - sh8013 - sh801333 - - 2fooBAR - - - - ABC-12345 - - diff --git a/spec/support/epp.rb b/spec/support/epp.rb index 3c482d97a..b32d314b3 100644 --- a/spec/support/epp.rb +++ b/spec/support/epp.rb @@ -64,6 +64,7 @@ module Epp EppXml::Domain.info(xml_params) end + # rubocop: disable Metrics/MethodLength def domain_create_xml(xml_params = {}, dnssec_params = {}) defaults = { name: { value: 'example.ee' }, @@ -97,6 +98,70 @@ module Epp EppXml::Domain.create(xml_params, dnssec_params) end + def domain_create_with_invalid_ns_ip_xml + xml_params = { + name: { value: 'example.ee' }, + period: { value: '1', attrs: { unit: 'y' } }, + ns: [ + { + hostAttr: { + hostName: { value: 'ns1.example.net' }, + hostAddr: { value: '192.0.2.2.invalid', attrs: { ip: 'v4' } } + } + }, + { + hostAttr: { + hostName: { value: 'ns2.example.net' }, + hostAddr: { value: 'invalid_ipv6', attrs: { ip: 'v6' } } + } + } + ], + registrant: { value: 'jd1234' }, + contact: { value: 'sh8013', attrs: { type: 'admin' } }, + contact: { value: 'sh8013', attrs: { type: 'tech' } }, + contact: { value: 'sh801333', attrs: { type: 'tech' } }, + authInfo: { + pw: { + value: '2fooBAR' + } + } + } + + EppXml::Domain.create(xml_params, false) + end + + def domain_create_with_host_attrs + xml_params = { + name: { value: 'example.ee' }, + period: { value: '1', attrs: { unit: 'y' } }, + 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' } } } + ] + }, + { + hostAttr: { + hostName: { value: 'ns2.example.net' } + } + } + ], + registrant: { value: 'jd1234' }, + contact: { value: 'sh8013', attrs: { type: 'admin' } }, + contact: { value: 'sh8013', attrs: { type: 'tech' } }, + contact: { value: 'sh801333', attrs: { type: 'tech' } }, + authInfo: { + pw: { + value: '2fooBAR' + } + } + } + + EppXml::Domain.create(xml_params, false) + end + def domain_update_xml(xml_params = {}, dnssec_params = false) defaults = { name: { value: 'example.ee' }