mirror of
https://github.com/internetee/registry.git
synced 2025-05-19 02:39:37 +02:00
Refactor domain info builder
This commit is contained in:
parent
7e5d6204c6
commit
5464e4c342
3 changed files with 22 additions and 12 deletions
|
@ -743,7 +743,7 @@ describe 'EPP Domain', epp: true do
|
||||||
|
|
||||||
d.save
|
d.save
|
||||||
|
|
||||||
xml = domain_info_xml(name_value: 'Example.ee')
|
xml = domain_info_xml(name: { value: 'Example.ee' })
|
||||||
|
|
||||||
response = epp_request(xml, :xml)
|
response = epp_request(xml, :xml)
|
||||||
expect(response[:results][0][:result_code]).to eq('1000')
|
expect(response[:results][0][:result_code]).to eq('1000')
|
||||||
|
@ -804,7 +804,7 @@ describe 'EPP Domain', epp: true do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'returns error when domain can not be found' do
|
it 'returns error when domain can not be found' do
|
||||||
response = epp_request(domain_info_xml(name_value: 'test.ee'), :xml)
|
response = epp_request(domain_info_xml(name: { value: 'test.ee' }), :xml)
|
||||||
expect(response[:results][0][:result_code]).to eq('2303')
|
expect(response[:results][0][:result_code]).to eq('2303')
|
||||||
expect(response[:results][0][:msg]).to eq('Domain not found')
|
expect(response[:results][0][:msg]).to eq('Domain not found')
|
||||||
end
|
end
|
||||||
|
@ -952,6 +952,8 @@ describe 'EPP Domain', epp: true do
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
|
|
||||||
|
puts Nokogiri::XML(xml).to_s
|
||||||
|
|
||||||
epp_request(xml, :xml)
|
epp_request(xml, :xml)
|
||||||
|
|
||||||
expect(d.dnskeys.count).to eq(1)
|
expect(d.dnskeys.count).to eq(1)
|
||||||
|
|
|
@ -158,7 +158,14 @@ describe 'EPP Helper', epp: true do
|
||||||
</epp>
|
</epp>
|
||||||
').to_s.squish
|
').to_s.squish
|
||||||
|
|
||||||
generated = Nokogiri::XML(domain_info_xml(name_value: 'one.ee', name_hosts: 'sub', pw: 'b3rafsla')).to_s.squish
|
xml = domain_info_xml({
|
||||||
|
name: { value: 'one.ee', attrs: { hosts: 'sub' } },
|
||||||
|
authInfo: {
|
||||||
|
pw: { value: 'b3rafsla' }
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
generated = Nokogiri::XML(xml).to_s.squish
|
||||||
expect(generated).to eq(expected)
|
expect(generated).to eq(expected)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -145,9 +145,14 @@ module Epp
|
||||||
end
|
end
|
||||||
|
|
||||||
def domain_info_xml(xml_params = {})
|
def domain_info_xml(xml_params = {})
|
||||||
xml_params[:name_value] = xml_params[:name_value] || 'example.ee'
|
defaults = {
|
||||||
xml_params[:name_hosts] = xml_params[:name_hosts] || 'all'
|
name: { value: 'example.ee', attrs: { hosts: 'all' } },
|
||||||
xml_params[:pw] = xml_params[:pw] || '2fooBAR'
|
authInfo: {
|
||||||
|
pw: { value: '2fooBAR' }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
xml_params = defaults.deep_merge(xml_params)
|
||||||
|
|
||||||
xml = Builder::XmlMarkup.new
|
xml = Builder::XmlMarkup.new
|
||||||
|
|
||||||
|
@ -156,17 +161,13 @@ module Epp
|
||||||
xml.command do
|
xml.command do
|
||||||
xml.info do
|
xml.info do
|
||||||
xml.tag!('domain:info', 'xmlns:domain' => 'urn:ietf:params:xml:ns:domain-1.0') do
|
xml.tag!('domain:info', 'xmlns:domain' => 'urn:ietf:params:xml:ns:domain-1.0') do
|
||||||
if xml_params[:name] != false
|
generate_xml_from_hash(xml_params, xml, 'domain')
|
||||||
xml.tag!('domain:name', xml_params[:name_value], 'hosts' => xml_params[:name_hosts])
|
|
||||||
end
|
|
||||||
xml.tag!('domain:authInfo') do
|
|
||||||
xml.tag!('domain:pw', xml_params[:pw])
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
xml.clTRID 'ABC-12345'
|
xml.clTRID 'ABC-12345'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def domain_update_xml(xml_params = {}, dnssec_params = false)
|
def domain_update_xml(xml_params = {}, dnssec_params = false)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue