Refactor domain create xmls to builders

This commit is contained in:
Martin Lensment 2014-11-07 17:52:13 +02:00
parent e5ac9f32f6
commit 952b379aaf
4 changed files with 67 additions and 63 deletions

View file

@ -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'

View file

@ -1,30 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
<command>
<create>
<domain:create
xmlns:domain="urn:ietf:params:xml:ns:domain-1.0">
<domain:name>example.ee</domain:name>
<domain:period unit="y">1</domain:period>
<domain:ns>
<domain:hostAttr>
<domain:hostName>ns1.example.net</domain:hostName>
<domain:hostAddr ip="v4">192.0.2.2</domain:hostAddr>
<domain:hostAddr ip="v6">1080:0:0:0:8:800:200C:417A</domain:hostAddr>
</domain:hostAttr>
<domain:hostAttr>
<domain:hostName>ns2.example.net</domain:hostName>
</domain:hostAttr>
</domain:ns>
<domain:registrant>jd1234</domain:registrant>
<domain:contact type="admin">sh8013</domain:contact>
<domain:contact type="tech">sh8013</domain:contact>
<domain:contact type="tech">sh801333</domain:contact>
<domain:authInfo>
<domain:pw>2fooBAR</domain:pw>
</domain:authInfo>
</domain:create>
</create>
<clTRID>ABC-12345</clTRID>
</command>
</epp>

View file

@ -1,30 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
<command>
<create>
<domain:create
xmlns:domain="urn:ietf:params:xml:ns:domain-1.0">
<domain:name>example.ee</domain:name>
<domain:period unit="y">1</domain:period>
<domain:ns>
<domain:hostAttr>
<domain:hostName>ns1.example.net</domain:hostName>
<domain:hostAddr ip="v4">192.0.2.2.invalid</domain:hostAddr>
</domain:hostAttr>
<domain:hostAttr>
<domain:hostName>ns2.example.net</domain:hostName>
<domain:hostAddr ip="v6">invalid_ipv6</domain:hostAddr>
</domain:hostAttr>
</domain:ns>
<domain:registrant>jd1234</domain:registrant>
<domain:contact type="admin">sh8013</domain:contact>
<domain:contact type="tech">sh8013</domain:contact>
<domain:contact type="tech">sh801333</domain:contact>
<domain:authInfo>
<domain:pw>2fooBAR</domain:pw>
</domain:authInfo>
</domain:create>
</create>
<clTRID>ABC-12345</clTRID>
</command>
</epp>

View file

@ -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' }