mirror of
https://github.com/internetee/registry.git
synced 2025-05-18 02:09:39 +02:00
Merge branch 'master' of github.com:internetee/registry
This commit is contained in:
commit
54d72db6cd
6 changed files with 71 additions and 10 deletions
|
@ -1,21 +1,17 @@
|
||||||
module Epp::DomainsHelper
|
module Epp::DomainsHelper
|
||||||
def create_domain
|
def create_domain
|
||||||
domain = Domain.create!(domain_params)
|
domain = Domain.create!(domain_create_params)
|
||||||
render '/epp/domains/create'
|
render '/epp/domains/create'
|
||||||
end
|
end
|
||||||
|
|
||||||
def check_domain
|
def check_domain
|
||||||
cp = command_params_for('check')
|
@domains = Domain.check_availability(domain_check_params[:names])
|
||||||
|
|
||||||
@domain = cp[:name]
|
|
||||||
@avail = Domain.find_by(name: @domain) ? '0' : '1'
|
|
||||||
|
|
||||||
render '/epp/domains/check'
|
render '/epp/domains/check'
|
||||||
end
|
end
|
||||||
|
|
||||||
### HELPER METHODS ###
|
### HELPER METHODS ###
|
||||||
|
|
||||||
def domain_params
|
def domain_create_params
|
||||||
cp = command_params_for('create')
|
cp = command_params_for('create')
|
||||||
{
|
{
|
||||||
name: cp[:name],
|
name: cp[:name],
|
||||||
|
@ -26,4 +22,9 @@ module Epp::DomainsHelper
|
||||||
auth_info: cp[:authInfo]
|
auth_info: cp[:authInfo]
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def domain_check_params
|
||||||
|
node_set = parsed_frame.css('epp command check check name')
|
||||||
|
node_set.inject({names: []}){ |hash, obj| hash[:names] << obj.text; hash }
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -4,4 +4,15 @@ class Domain < ActiveRecord::Base
|
||||||
belongs_to :owner_contact, class_name: 'Contact'
|
belongs_to :owner_contact, class_name: 'Contact'
|
||||||
belongs_to :technical_contact, class_name: 'Contact'
|
belongs_to :technical_contact, class_name: 'Contact'
|
||||||
belongs_to :admin_contact, class_name: 'Contact'
|
belongs_to :admin_contact, class_name: 'Contact'
|
||||||
|
|
||||||
|
class << self
|
||||||
|
def check_availability(domains)
|
||||||
|
res = []
|
||||||
|
domains.each do |x|
|
||||||
|
res << {name: x, avail: Domain.find_by(name: x) ? 0 : 1}
|
||||||
|
end
|
||||||
|
|
||||||
|
res
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -6,8 +6,10 @@ xml.epp_head do
|
||||||
|
|
||||||
xml.resData do
|
xml.resData do
|
||||||
xml.tag!('domain:chkData', 'xmlns:domain' => 'http://www.nic.cz/xml/epp/domain-1.4', 'xsi:schemaLocation' => 'http://www.nic.cz/xml/epp/domain-1.4 domain-1.4.xsd') do
|
xml.tag!('domain:chkData', 'xmlns:domain' => 'http://www.nic.cz/xml/epp/domain-1.4', 'xsi:schemaLocation' => 'http://www.nic.cz/xml/epp/domain-1.4 domain-1.4.xsd') do
|
||||||
|
@domains.each do |x|
|
||||||
xml.tag!('domain:cd') do
|
xml.tag!('domain:cd') do
|
||||||
xml.tag!('domain:name', @domain, 'avail' => @avail)
|
xml.tag!('domain:name', x[:name], 'avail' => x[:avail])
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -16,7 +16,7 @@ describe 'EPP Domain', epp: true do
|
||||||
end
|
end
|
||||||
|
|
||||||
# incomplete
|
# incomplete
|
||||||
it 'checks domain' do
|
it 'checks a domain' do
|
||||||
response = epp_request('domains/check.xml')
|
response = epp_request('domains/check.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')
|
||||||
|
@ -33,5 +33,37 @@ describe 'EPP Domain', epp: true do
|
||||||
expect(domain[:avail]).to eq('0')
|
expect(domain[:avail]).to eq('0')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'checks multiple domains' do
|
||||||
|
response = epp_request('domains/check_multiple.xml')
|
||||||
|
expect(response[:result_code]).to eq('1000')
|
||||||
|
expect(response[:msg]).to eq('Command completed successfully')
|
||||||
|
|
||||||
|
domain = response[:parsed].css('resData chkData cd name').first
|
||||||
|
expect(domain.text).to eq('test.ee')
|
||||||
|
expect(domain[:avail]).to eq('1')
|
||||||
|
|
||||||
|
domain = response[:parsed].css('resData chkData cd name').last
|
||||||
|
expect(domain.text).to eq('bla.ee')
|
||||||
|
expect(domain[:avail]).to eq('1')
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'checks invalid format domain' do
|
||||||
|
response = epp_request('domains/check_multiple_with_invalid.xml')
|
||||||
|
expect(response[:result_code]).to eq('1000')
|
||||||
|
expect(response[:msg]).to eq('Command completed successfully')
|
||||||
|
|
||||||
|
domain = response[:parsed].css('resData chkData cd name').first
|
||||||
|
expect(domain.text).to eq('test.ee')
|
||||||
|
expect(domain[:avail]).to eq('1')
|
||||||
|
|
||||||
|
domain = response[:parsed].css('resData chkData cd').last
|
||||||
|
name = domain.css('name').first
|
||||||
|
reason = domain.css('reason').first
|
||||||
|
|
||||||
|
expect(name.text).to eq('asdasd')
|
||||||
|
expect(name[:avail]).to eq('0')
|
||||||
|
expect(reason.text).to eq('invalid format')
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
7
spec/epp/requests/domains/check_multiple.xml
Normal file
7
spec/epp/requests/domains/check_multiple.xml
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8" standalone="no"?><epp xmlns="urn:ietf:params:xml:ns:epp-1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:ietf:params:xml:ns:epp-1.0 epp-1.0.xsd"><command><check><domain:check xmlns:domain="http://www.nic.cz/xml/epp/domain-1.4" xsi:schemaLocation="http://www.nic.cz/xml/epp/domain-1.4 domain-1.4.xsd"><domain:name>test.ee</domain:name>
|
||||||
|
<domain:name>bla.ee</domain:name>
|
||||||
|
</domain:check>
|
||||||
|
</check>
|
||||||
|
<clTRID>naug002#14-06-30at10:45:27</clTRID>
|
||||||
|
</command>
|
||||||
|
</epp>
|
|
@ -0,0 +1,8 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8" standalone="no"?><epp xmlns="urn:ietf:params:xml:ns:epp-1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:ietf:params:xml:ns:epp-1.0 epp-1.0.xsd"><command><check><domain:check xmlns:domain="http://www.nic.cz/xml/epp/domain-1.4" xsi:schemaLocation="http://www.nic.cz/xml/epp/domain-1.4 domain-1.4.xsd"><domain:name>test.ee</domain:name>
|
||||||
|
<domain:name>bla.ee</domain:name>
|
||||||
|
<domain:name>asdasd</domain:name>
|
||||||
|
</domain:check>
|
||||||
|
</check>
|
||||||
|
<clTRID>ixsz002#14-06-30at11:43:32</clTRID>
|
||||||
|
</command>
|
||||||
|
</epp>
|
Loading…
Add table
Add a link
Reference in a new issue