mirror of
https://github.com/internetee/registry.git
synced 2025-07-20 09:46:09 +02:00
Refactor delete.xml to builder
This commit is contained in:
parent
08a4650f4a
commit
afc69629ef
5 changed files with 72 additions and 14 deletions
|
@ -103,6 +103,20 @@
|
|||
</command>
|
||||
</epp>
|
||||
|
||||
<!-- DOMAIN DELETE -->
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
|
||||
<command>
|
||||
<delete>
|
||||
<domain:delete
|
||||
xmlns:domain="urn:ietf:params:xml:ns:domain-1.0">
|
||||
<domain:name>example.ee</domain:name>
|
||||
</domain:delete>
|
||||
</delete>
|
||||
<clTRID>ABC-12345</clTRID>
|
||||
</command>
|
||||
</epp>
|
||||
|
||||
<!-- CREATE CONTACT -->
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
|
||||
|
|
|
@ -440,9 +440,9 @@ describe 'EPP Domain', epp: true do
|
|||
expect(d.auth_info).to eq('2BARfoo')
|
||||
end
|
||||
|
||||
it 'does not delete domain if there are relations' do
|
||||
it 'deletes domain' do
|
||||
expect(DomainContact.count).to eq(1)
|
||||
response = epp_request('domains/delete.xml')
|
||||
response = epp_request(domain_delete_xml, :xml)
|
||||
expect(response[:result_code]).to eq('1000')
|
||||
|
||||
expect(Domain.first).to eq(nil)
|
||||
|
|
|
@ -320,5 +320,42 @@ describe 'EPP Helper', epp: true do
|
|||
generated = Nokogiri::XML(xml).to_s.squish
|
||||
expect(generated).to eq(expected)
|
||||
end
|
||||
|
||||
it 'generates valid delete 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>
|
||||
<delete>
|
||||
<domain:delete
|
||||
xmlns:domain="urn:ietf:params:xml:ns:domain-1.0">
|
||||
<domain:name>example.ee</domain:name>
|
||||
</domain:delete>
|
||||
</delete>
|
||||
<clTRID>ABC-12345</clTRID>
|
||||
</command>
|
||||
</epp>
|
||||
').to_s.squish
|
||||
|
||||
generated = Nokogiri::XML(domain_delete_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>
|
||||
<delete>
|
||||
<domain:delete
|
||||
xmlns:domain="urn:ietf:params:xml:ns:domain-1.0">
|
||||
<domain:name>one.ee</domain:name>
|
||||
</domain:delete>
|
||||
</delete>
|
||||
<clTRID>ABC-12345</clTRID>
|
||||
</command>
|
||||
</epp>
|
||||
').to_s.squish
|
||||
|
||||
generated = Nokogiri::XML(domain_delete_xml(name: 'one.ee')).to_s.squish
|
||||
expect(generated).to eq(expected)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,12 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
|
||||
<command>
|
||||
<delete>
|
||||
<domain:delete
|
||||
xmlns:domain="urn:ietf:params:xml:ns:domain-1.0">
|
||||
<domain:name>example.ee</domain:name>
|
||||
</domain:delete>
|
||||
</delete>
|
||||
<clTRID>ABC-12345</clTRID>
|
||||
</command>
|
||||
</epp>
|
|
@ -216,6 +216,25 @@ module Epp
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
def domain_delete_xml(xml_params = {})
|
||||
xml_params[:name] = xml_params[:name] || 'example.ee'
|
||||
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.delete do
|
||||
xml.tag!('domain:delete', 'xmlns:domain' => 'urn:ietf:params:xml:ns:domain-1.0') do
|
||||
if xml_params[:name] != false
|
||||
xml.tag!('domain:name', xml_params[:name])
|
||||
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