mirror of
https://github.com/internetee/registry.git
synced 2025-07-25 20:18:22 +02:00
Refactor domain check tests
This commit is contained in:
parent
838782fd62
commit
a846a51444
5 changed files with 29 additions and 34 deletions
|
@ -9,7 +9,7 @@ describe 'EPP Domain', epp: true do
|
||||||
it 'returns error if contact does not exists' do
|
it 'returns error if contact does not exists' do
|
||||||
Fabricate(:contact, code: 'jd1234')
|
Fabricate(:contact, code: 'jd1234')
|
||||||
|
|
||||||
response = epp_request(domain_create_xml, :xml)
|
response = epp_request('domains/create.xml')
|
||||||
expect(response[:results][0][:result_code]).to eq('2303')
|
expect(response[:results][0][:result_code]).to eq('2303')
|
||||||
expect(response[:results][0][:msg]).to eq('Contact was not found')
|
expect(response[:results][0][:msg]).to eq('Contact was not found')
|
||||||
expect(response[:results][0][:value]).to eq('sh8013')
|
expect(response[:results][0][:value]).to eq('sh8013')
|
||||||
|
@ -202,23 +202,25 @@ describe 'EPP Domain', epp: true do
|
||||||
expect(response[:msg]).to eq('Command completed successfully')
|
expect(response[:msg]).to eq('Command completed successfully')
|
||||||
|
|
||||||
domain = response[:parsed].css('resData chkData cd name').first
|
domain = response[:parsed].css('resData chkData cd name').first
|
||||||
expect(domain.text).to eq('one.ee')
|
expect(domain.text).to eq('example.ee')
|
||||||
expect(domain[:avail]).to eq('1')
|
expect(domain[:avail]).to eq('1')
|
||||||
|
|
||||||
Fabricate(:domain, name: 'one.ee')
|
Fabricate(:domain, name: 'example.ee')
|
||||||
|
|
||||||
response = epp_request('domains/check.xml')
|
response = epp_request('domains/check.xml')
|
||||||
domain = response[:parsed].css('resData chkData cd').first
|
domain = response[:parsed].css('resData chkData cd').first
|
||||||
name = domain.css('name').first
|
name = domain.css('name').first
|
||||||
reason = domain.css('reason').first
|
reason = domain.css('reason').first
|
||||||
|
|
||||||
expect(name.text).to eq('one.ee')
|
expect(name.text).to eq('example.ee')
|
||||||
expect(name[:avail]).to eq('0')
|
expect(name[:avail]).to eq('0')
|
||||||
expect(reason.text).to eq('in use') #confirm this with current API
|
expect(reason.text).to eq('in use') #confirm this with current API
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'checks multiple domains' do
|
it 'checks multiple domains' do
|
||||||
response = epp_request('domains/check_multiple.xml')
|
xml = domain_check_xml(names: ['one.ee', 'two.ee', 'three.ee'])
|
||||||
|
|
||||||
|
response = epp_request(xml, :xml)
|
||||||
expect(response[:result_code]).to eq('1000')
|
expect(response[:result_code]).to eq('1000')
|
||||||
expect(response[:msg]).to eq('Command completed successfully')
|
expect(response[:msg]).to eq('Command completed successfully')
|
||||||
|
|
||||||
|
@ -232,7 +234,9 @@ describe 'EPP Domain', epp: true do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'checks invalid format domain' do
|
it 'checks invalid format domain' do
|
||||||
response = epp_request('domains/check_multiple_with_invalid.xml')
|
xml = domain_check_xml(names: ['one.ee', 'notcorrectdomain'])
|
||||||
|
|
||||||
|
response = epp_request(xml, :xml)
|
||||||
expect(response[:result_code]).to eq('1000')
|
expect(response[:result_code]).to eq('1000')
|
||||||
expect(response[:msg]).to eq('Command completed successfully')
|
expect(response[:msg]).to eq('Command completed successfully')
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
<check>
|
<check>
|
||||||
<domain:check
|
<domain:check
|
||||||
xmlns:domain="urn:ietf:params:xml:ns:domain-1.0">
|
xmlns:domain="urn:ietf:params:xml:ns:domain-1.0">
|
||||||
<domain:name>one.ee</domain:name>
|
<domain:name>example.ee</domain:name>
|
||||||
</domain:check>
|
</domain:check>
|
||||||
</check>
|
</check>
|
||||||
<clTRID>ABC-12345</clTRID>
|
<clTRID>ABC-12345</clTRID>
|
||||||
|
|
|
@ -1,14 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
|
||||||
<epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
|
|
||||||
<command>
|
|
||||||
<check>
|
|
||||||
<domain:check
|
|
||||||
xmlns:domain="urn:ietf:params:xml:ns:domain-1.0">
|
|
||||||
<domain:name>one.ee</domain:name>
|
|
||||||
<domain:name>two.ee</domain:name>
|
|
||||||
<domain:name>three.ee</domain:name>
|
|
||||||
</domain:check>
|
|
||||||
</check>
|
|
||||||
<clTRID>ABC-12345</clTRID>
|
|
||||||
</command>
|
|
||||||
</epp>
|
|
|
@ -1,13 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
|
||||||
<epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
|
|
||||||
<command>
|
|
||||||
<check>
|
|
||||||
<domain:check
|
|
||||||
xmlns:domain="urn:ietf:params:xml:ns:domain-1.0">
|
|
||||||
<domain:name>one.ee</domain:name>
|
|
||||||
<domain:name>notcorrectdomain</domain:name>
|
|
||||||
</domain:check>
|
|
||||||
</check>
|
|
||||||
<clTRID>ABC-12345</clTRID>
|
|
||||||
</command>
|
|
||||||
</epp>
|
|
|
@ -107,6 +107,24 @@ module Epp
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def domain_check_xml(xml_params={})
|
||||||
|
xml_params[:names] = xml_params[:names] || ['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.check do
|
||||||
|
xml.tag!('domain:check', 'xmlns:domain' => 'urn:ietf:params:xml:ns:domain-1.0') do
|
||||||
|
xml_params[:names].each do |x|
|
||||||
|
xml.tag!('domain:name', (x || 'example.ee'))
|
||||||
|
end if xml_params[:names].any?
|
||||||
|
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