Refactor domain info xml to gem

This commit is contained in:
Martin Lensment 2014-10-22 17:22:35 +03:00
parent 2574bb9329
commit 95b5094d52
5 changed files with 7 additions and 82 deletions

View file

@ -1,6 +1,6 @@
GIT
remote: git@github.com:gitlabeu/epp-xml.git
revision: 4c506960b70246ece25a3e7352075b9aa9060d03
revision: bd353d79764ba10ce189add76dfd2f4672649175
specs:
epp-xml (0.0.1)
activesupport (~> 4.1, >= 4.1.4)

View file

@ -38,7 +38,7 @@ describe 'EPP Domain', epp: true do
end
it 'can not see other registrar domains' do
response = epp_request(domain_info_xml, :xml, :elkdata)
response = epp_request(EppXml::Domain.info, :xml, :elkdata)
expect(response[:result_code]).to eq('2302')
expect(response[:msg]).to eq('Domain exists but belongs to other registrar')
end
@ -709,7 +709,7 @@ describe 'EPP Domain', epp: true do
end
it 'sets ok status by default' do
response = epp_request(domain_info_xml, :xml)
response = epp_request(EppXml::Domain.info, :xml)
inf_data = response[:parsed].css('resData infData')
expect(inf_data.css('status').first[:s]).to eq('ok')
end
@ -743,7 +743,7 @@ describe 'EPP Domain', epp: true do
d.save
xml = domain_info_xml(name: { value: 'Example.ee' })
xml = EppXml::Domain.info(name: { value: 'Example.ee' })
response = epp_request(xml, :xml)
expect(response[:results][0][:result_code]).to eq('1000')
@ -797,14 +797,14 @@ describe 'EPP Domain', epp: true do
d.touch
response = epp_request(domain_info_xml, :xml)
response = epp_request(EppXml::Domain.info, :xml)
inf_data = response[:parsed].css('resData infData')
expect(inf_data.css('upDate').text).to eq(d.updated_at.to_time.utc.to_s)
end
it 'returns error when domain can not be found' do
response = epp_request(domain_info_xml(name: { value: 'test.ee' }), :xml)
response = epp_request(EppXml::Domain.info(name: { value: 'test.ee' }), :xml)
expect(response[:results][0][:result_code]).to eq('2303')
expect(response[:results][0][:msg]).to eq('Domain not found')
end

View file

@ -2,55 +2,6 @@ require 'rails_helper'
describe 'EPP Helper', epp: true do
context 'in context of Domain' do
it 'generates valid info 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>
<info>
<domain:info
xmlns:domain="urn:ietf:params:xml:ns:domain-1.0">
<domain:name hosts="all">example.ee</domain:name>
<domain:authInfo>
<domain:pw>2fooBAR</domain:pw>
</domain:authInfo>
</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:authInfo>
<domain:pw>b3rafsla</domain:pw>
</domain:authInfo>
</domain:info>
</info>
<clTRID>ABC-12345</clTRID>
</command>
</epp>
').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)
end
it 'generates valid check xml' do
expected = Nokogiri::XML('<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<epp xmlns="urn:ietf:params:xml:ns:epp-1.0">

View file

@ -29,7 +29,7 @@ describe 'EPP Session', epp: true do
end
it 'prohibits further actions unless logged in' do
response = epp_plain_request(domain_create_xml, :xml)
response = epp_plain_request(EppXml::Domain.create, :xml)
expect(response[:result_code]).to eq('2002')
expect(response[:msg]).to eq('You need to login first.')
expect(response[:clTRID]).to eq('ABC-12345')

View file

@ -92,32 +92,6 @@ module Epp
end
end
def domain_info_xml(xml_params = {})
defaults = {
name: { value: 'example.ee', attrs: { hosts: 'all' } },
authInfo: {
pw: { value: '2fooBAR' }
}
}
xml_params = defaults.deep_merge(xml_params)
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
generate_xml_from_hash(xml_params, xml, 'domain:')
end
end
xml.clTRID 'ABC-12345'
end
end
end
def domain_update_xml(xml_params = {}, dnssec_params = false)
defaults = {
name: { value: 'example.ee' }