mirror of
https://github.com/internetee/registry.git
synced 2025-07-04 02:03:36 +02:00
Add update.xml test
This commit is contained in:
parent
ad2236a5f4
commit
45f72d45ec
2 changed files with 70 additions and 4 deletions
|
@ -225,5 +225,30 @@ describe 'EPP Helper', epp: true do
|
|||
generated = Nokogiri::XML(domain_renew_xml(name: 'one.ee', curExpDate: '2009-11-15', period_value: '365', period_unit: 'd')).to_s.squish
|
||||
expect(generated).to eq(expected)
|
||||
end
|
||||
|
||||
it 'generates valid update xml' do
|
||||
expected = Nokogiri::XML('<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
|
||||
<command>
|
||||
<update>
|
||||
<domain:update
|
||||
xmlns:domain="urn:ietf:params:xml:ns:domain-1.0">
|
||||
<domain:name>example.ee</domain:name>
|
||||
<domain:chg>
|
||||
<domain:registrant>mak21</domain:registrant>
|
||||
<domain:authInfo>
|
||||
<domain:pw>2BARfoo</domain:pw>
|
||||
</domain:authInfo>
|
||||
</domain:chg>
|
||||
</domain:update>
|
||||
</update>
|
||||
<clTRID>ABC-12345</clTRID>
|
||||
</command>
|
||||
</epp>
|
||||
').to_s.squish
|
||||
|
||||
generated = Nokogiri::XML(domain_update_xml).to_s.squish
|
||||
expect(generated).to eq(expected)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -46,7 +46,11 @@ module Epp
|
|||
### REQUEST TEMPLATES ###
|
||||
|
||||
def domain_create_xml(xml_params = {})
|
||||
xml_params[:nameservers] = xml_params[:nameservers] || [{ hostObj: 'ns1.example.net' }, { hostObj: 'ns2.example.net' }]
|
||||
xml_params[:nameservers] = xml_params[:nameservers] || [
|
||||
{ hostObj: 'ns1.example.net' },
|
||||
{ hostObj: 'ns2.example.net' }
|
||||
]
|
||||
|
||||
xml_params[:contacts] = xml_params[:contacts] || [
|
||||
{ contact_value: 'sh8013', contact_type: 'admin' },
|
||||
{ contact_value: 'sh8013', contact_type: 'tech' },
|
||||
|
@ -65,7 +69,9 @@ module Epp
|
|||
|
||||
xml.tag!('domain:name', (xml_params[:name] || 'example.ee')) if xml_params[:name] != false
|
||||
|
||||
xml.tag!('domain:period', (xml_params[:period_value] || 1), 'unit' => (xml_params[:period_unit] || 'y')) if xml_params[:period] != false
|
||||
if xml_params[:period] != false
|
||||
xml.tag!('domain:period', (xml_params[:period_value] || 1), 'unit' => (xml_params[:period_unit] || 'y'))
|
||||
end
|
||||
|
||||
xml.tag!('domain:ns') do
|
||||
xml_params[:nameservers].each do |x|
|
||||
|
@ -99,7 +105,10 @@ module Epp
|
|||
xml.tag!('domain:renew', 'xmlns:domain' => 'urn:ietf:params:xml:ns:domain-1.0') do
|
||||
xml.tag!('domain:name', (xml_params[:name] || 'example.ee')) if xml_params[:name] != false
|
||||
xml.tag!('domain:curExpDate', (xml_params[:curExpDate] || '2014-08-07')) if xml_params[:curExpDate] != false
|
||||
xml.tag!('domain:period', (xml_params[:period_value] || 1), 'unit' => (xml_params[:period_unit] || 'y')) if xml_params[:period] != false
|
||||
|
||||
if xml_params[:period] != false
|
||||
xml.tag!('domain:period', (xml_params[:period_value] || 1), 'unit' => (xml_params[:period_unit] || 'y'))
|
||||
end
|
||||
end
|
||||
end
|
||||
xml.clTRID 'ABC-12345'
|
||||
|
@ -138,7 +147,9 @@ module Epp
|
|||
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
|
||||
if xml_params[:name] != false
|
||||
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
|
||||
|
@ -148,6 +159,36 @@ module Epp
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
def domain_update_xml(xml_params = {})
|
||||
xml_params[:name_value] = xml_params[:name_value] || 'example.ee'
|
||||
xml_params[:registrant] = xml_params[:registrant] || 'mak21'
|
||||
xml_params[:pw] = xml_params[:pw] || '2BARfoo'
|
||||
|
||||
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.update do
|
||||
xml.tag!('domain:update', 'xmlns:domain' => 'urn:ietf:params:xml:ns:domain-1.0') do
|
||||
if xml_params[:name] != false
|
||||
xml.tag!('domain:name', xml_params[:name_value])
|
||||
end
|
||||
|
||||
xml.tag!('domain:chg') do
|
||||
xml.tag!('domain:registrant', xml_params[:registrant]) if xml_params[:registrant] != false
|
||||
|
||||
xml.tag!('domain:authInfo') do
|
||||
xml.tag!('domain:pw', xml_params[:pw])
|
||||
end if xml_params[:authInfo] != false
|
||||
end
|
||||
end
|
||||
end
|
||||
xml.clTRID 'ABC-12345'
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
RSpec.configure do |c|
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue