mirror of
https://github.com/internetee/registry.git
synced 2025-05-17 01:47:18 +02:00
Refactor domain info request to builder
This commit is contained in:
parent
0349e63ccd
commit
d747d92d2b
2 changed files with 57 additions and 0 deletions
|
@ -105,5 +105,43 @@ describe 'EPP Helper', epp: true do
|
||||||
generated = Nokogiri::XML(xml).to_s.squish
|
generated = Nokogiri::XML(xml).to_s.squish
|
||||||
expect(generated).to eq(expected)
|
expect(generated).to eq(expected)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'creates valid info request' do
|
||||||
|
expected = Nokogiri::XML('<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
|
<epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
|
||||||
|
<command>
|
||||||
|
<info>
|
||||||
|
<domain:info
|
||||||
|
xmlns:domain="urn:ietf:params:xml:ns:domain-1.0">
|
||||||
|
<domain:name hosts="all">example.ee</domain:name>
|
||||||
|
</domain:info>
|
||||||
|
</info>
|
||||||
|
<clTRID>ABC-12345</clTRID>
|
||||||
|
</command>
|
||||||
|
</epp>
|
||||||
|
').to_s.squish
|
||||||
|
|
||||||
|
|
||||||
|
generated = Nokogiri::XML(domain_info_xml).to_s.squish
|
||||||
|
expect(generated).to eq(expected)
|
||||||
|
|
||||||
|
expected = Nokogiri::XML('<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
|
<epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
|
||||||
|
<command>
|
||||||
|
<info>
|
||||||
|
<domain:info
|
||||||
|
xmlns:domain="urn:ietf:params:xml:ns:domain-1.0">
|
||||||
|
<domain:name hosts="sub">one.ee</domain:name>
|
||||||
|
</domain:info>
|
||||||
|
</info>
|
||||||
|
<clTRID>ABC-12345</clTRID>
|
||||||
|
</command>
|
||||||
|
</epp>
|
||||||
|
').to_s.squish
|
||||||
|
|
||||||
|
|
||||||
|
generated = Nokogiri::XML(domain_info_xml(name_value: 'one.ee', name_hosts: 'sub')).to_s.squish
|
||||||
|
expect(generated).to eq(expected)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -124,6 +124,25 @@ module Epp
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def domain_info_xml(xml_params={})
|
||||||
|
xml_params[:name_value] = xml_params[:name_value] || 'example.ee'
|
||||||
|
xml_params[:name_hosts] = xml_params[:name_hosts] || 'all'
|
||||||
|
|
||||||
|
xml = Builder::XmlMarkup.new
|
||||||
|
|
||||||
|
xml.instruct!(:xml, :standalone => 'no')
|
||||||
|
xml.epp('xmlns' => 'urn:ietf:params:xml:ns:epp-1.0') do
|
||||||
|
xml.command do
|
||||||
|
xml.info do
|
||||||
|
xml.tag!('domain:info', 'xmlns:domain' => 'urn:ietf:params:xml:ns:domain-1.0') do
|
||||||
|
xml.tag!('domain:name', xml_params[:name_value], 'hosts' => xml_params[:name_hosts]) if xml_params[:name] != false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
xml.clTRID 'ABC-12345'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
RSpec.configure do |c|
|
RSpec.configure do |c|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue