mirror of
https://github.com/internetee/registry.git
synced 2025-05-19 10:49:39 +02:00
Info request for domain
This commit is contained in:
parent
ed73278620
commit
c34f01aeb3
6 changed files with 116 additions and 0 deletions
|
@ -26,6 +26,12 @@ module Epp::DomainsHelper
|
||||||
render '/epp/domains/renew'
|
render '/epp/domains/renew'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def info_domain
|
||||||
|
@domain = find_domain
|
||||||
|
|
||||||
|
render '/epp/domains/info'
|
||||||
|
end
|
||||||
|
|
||||||
### HELPER METHODS ###
|
### HELPER METHODS ###
|
||||||
private
|
private
|
||||||
|
|
||||||
|
@ -58,6 +64,13 @@ module Epp::DomainsHelper
|
||||||
xml_attrs_present?(@ph, [['name'], ['curExpDate'], ['period']])
|
xml_attrs_present?(@ph, [['name'], ['curExpDate'], ['period']])
|
||||||
end
|
end
|
||||||
|
|
||||||
|
## INFO
|
||||||
|
def validate_domain_info_request
|
||||||
|
@ph = params_hash['epp']['command']['info']['info']
|
||||||
|
xml_attrs_present?(@ph, [['name']])
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
## SHARED
|
## SHARED
|
||||||
def find_domain
|
def find_domain
|
||||||
domain = Domain.find_by(name: @ph[:name])
|
domain = Domain.find_by(name: @ph[:name])
|
||||||
|
|
|
@ -32,6 +32,9 @@ class Domain < ActiveRecord::Base
|
||||||
|
|
||||||
has_and_belongs_to_many :nameservers
|
has_and_belongs_to_many :nameservers
|
||||||
|
|
||||||
|
delegate :code, to: :owner_contact, prefix: true
|
||||||
|
delegate :name, to: :registrar, prefix: true
|
||||||
|
|
||||||
validates :name_dirty, domain_name: true, uniqueness: true
|
validates :name_dirty, domain_name: true, uniqueness: true
|
||||||
validates :period, numericality: { only_integer: true }
|
validates :period, numericality: { only_integer: true }
|
||||||
validates :name, :owner_contact, presence: true
|
validates :name, :owner_contact, presence: true
|
||||||
|
|
53
app/views/epp/domains/info.xml.builder
Normal file
53
app/views/epp/domains/info.xml.builder
Normal file
|
@ -0,0 +1,53 @@
|
||||||
|
xml.epp_head do
|
||||||
|
xml.response do
|
||||||
|
xml.result('code' => '1000') do
|
||||||
|
xml.msg 'Command completed successfully'
|
||||||
|
end
|
||||||
|
|
||||||
|
xml.resData do
|
||||||
|
xml.tag!('domain:infData', 'xmlns:domain' => 'urn:ietf:params:xml:ns:domain-1.0') do
|
||||||
|
xml.tag!('domain:name', @domain.name)
|
||||||
|
xml.tag!('domain:status', 's' => @domain.status) if @domain.status
|
||||||
|
xml.tag!('domain:registrant', @domain.owner_contact_code)
|
||||||
|
|
||||||
|
@domain.tech_contacts.each do |x|
|
||||||
|
xml.tag!('domain:contact', x.code, 'type' => 'tech')
|
||||||
|
end
|
||||||
|
|
||||||
|
@domain.admin_contacts.each do |x|
|
||||||
|
xml.tag!('domain:contact', x.code, 'type' => 'admin')
|
||||||
|
end
|
||||||
|
|
||||||
|
xml.tag!('domain:ns') do
|
||||||
|
@domain.nameservers.each do |x|
|
||||||
|
xml.tag!('domain:hostObj', x.hostname)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
## TODO Find out what this domain:host is all about
|
||||||
|
|
||||||
|
xml.tag!('domain:clID', @domain.owner_contact_code)
|
||||||
|
|
||||||
|
xml.tag!('domain:crID', @domain.registrar_name)
|
||||||
|
|
||||||
|
xml.tag!('domain:crDate', @domain.created_at)
|
||||||
|
|
||||||
|
xml.tag!('domain:exDate', @domain.valid_to)
|
||||||
|
|
||||||
|
# TODO Make domain stampable
|
||||||
|
#xml.tag!('domain:upID', @domain.updated_by)
|
||||||
|
|
||||||
|
xml.tag!('domain:upDate', @domain.updated_at) if @domain.updated_at != @domain.created_at
|
||||||
|
|
||||||
|
# TODO Make domain transferrable
|
||||||
|
#xml.tag!('domain:trDate', @domain.transferred_at) if @domain.transferred_at
|
||||||
|
|
||||||
|
xml.tag!('domain:authInfo') do
|
||||||
|
xml.tag!('domain:pw', @domain.auth_info)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
xml << render('/epp/shared/trID')
|
||||||
|
end
|
|
@ -201,6 +201,39 @@ describe 'EPP Domain', epp: true do
|
||||||
expect(response[:results][0][:msg]).to eq('Period must add up to 1, 2 or 3 years')
|
expect(response[:results][0][:msg]).to eq('Period must add up to 1, 2 or 3 years')
|
||||||
expect(response[:results][0][:value]).to eq('4')
|
expect(response[:results][0][:value]).to eq('4')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'returns domain info' do
|
||||||
|
d = Domain.first
|
||||||
|
|
||||||
|
response = epp_request('domains/info.xml')
|
||||||
|
expect(response[:results][0][:result_code]).to eq('1000')
|
||||||
|
expect(response[:results][0][:msg]).to eq('Command completed successfully')
|
||||||
|
|
||||||
|
inf_data = response[:parsed].css('resData infData')
|
||||||
|
expect(inf_data.css('name').text).to eq('example.ee')
|
||||||
|
expect(inf_data.css('registrant').text).to eq(d.owner_contact_code)
|
||||||
|
|
||||||
|
admin_contacts_from_request = inf_data.css('contact[type="admin"]').collect{|x| x.text }
|
||||||
|
admin_contacts_existing = d.admin_contacts.pluck(:code)
|
||||||
|
|
||||||
|
expect(admin_contacts_from_request).to eq(admin_contacts_existing)
|
||||||
|
|
||||||
|
hosts_from_request = inf_data.css('hostObj').collect{|x| x.text }
|
||||||
|
hosts_existing = d.nameservers.pluck(:hostname)
|
||||||
|
|
||||||
|
expect(hosts_from_request).to eq(hosts_existing)
|
||||||
|
expect(inf_data.css('crDate').text).to eq(d.created_at.to_time.utc.to_s)
|
||||||
|
expect(inf_data.css('exDate').text).to eq(d.valid_to.to_time.utc.to_s)
|
||||||
|
|
||||||
|
expect(inf_data.css('pw').text).to eq(d.auth_info)
|
||||||
|
|
||||||
|
d.touch
|
||||||
|
|
||||||
|
response = epp_request('domains/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
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'checks a domain' do
|
it 'checks a domain' do
|
||||||
|
|
12
spec/epp/requests/domains/info.xml
Normal file
12
spec/epp/requests/domains/info.xml
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
<?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:info>
|
||||||
|
</info>
|
||||||
|
<clTRID>ABC-12345</clTRID>
|
||||||
|
</command>
|
||||||
|
</epp>
|
|
@ -6,4 +6,6 @@ Fabricator(:domain) do
|
||||||
owner_contact(fabricator: :contact)
|
owner_contact(fabricator: :contact)
|
||||||
nameservers(count: 3)
|
nameservers(count: 3)
|
||||||
admin_contacts(count: 1) { Fabricate(:contact) }
|
admin_contacts(count: 1) { Fabricate(:contact) }
|
||||||
|
registrar
|
||||||
|
auth_info '98oiewslkfkd'
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue