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

@ -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')