mirror of
https://github.com/internetee/registry.git
synced 2025-05-17 01:47:18 +02:00
parent
3d6a0936c7
commit
a63e2b9dd2
3 changed files with 86 additions and 16 deletions
|
@ -1,6 +1,7 @@
|
||||||
class Epp::ContactsController < EppController
|
class Epp::ContactsController < EppController
|
||||||
before_action :find_contact, only: [:info, :update, :delete]
|
before_action :find_contact, only: [:info, :update, :delete]
|
||||||
before_action :find_password, only: [:info, :update, :delete]
|
before_action :find_password, only: [:info, :update, :delete]
|
||||||
|
helper_method :address_processing?
|
||||||
|
|
||||||
def info
|
def info
|
||||||
authorize! :info, @contact, @password
|
authorize! :info, @contact, @password
|
||||||
|
@ -24,7 +25,7 @@ class Epp::ContactsController < EppController
|
||||||
@contact.generate_code
|
@contact.generate_code
|
||||||
|
|
||||||
if @contact.save
|
if @contact.save
|
||||||
if !Contact.address_processing? && address_given?
|
if !address_processing? && address_given?
|
||||||
@response_code = 1100
|
@response_code = 1100
|
||||||
@response_description = t('epp.contacts.completed_without_address')
|
@response_description = t('epp.contacts.completed_without_address')
|
||||||
else
|
else
|
||||||
|
@ -44,7 +45,7 @@ class Epp::ContactsController < EppController
|
||||||
frame = params[:parsed_frame]
|
frame = params[:parsed_frame]
|
||||||
|
|
||||||
if @contact.update_attributes(frame, current_user)
|
if @contact.update_attributes(frame, current_user)
|
||||||
if !Contact.address_processing? && address_given?
|
if !address_processing? && address_given?
|
||||||
@response_code = 1100
|
@response_code = 1100
|
||||||
@response_description = t('epp.contacts.completed_without_address')
|
@response_description = t('epp.contacts.completed_without_address')
|
||||||
else
|
else
|
||||||
|
@ -125,7 +126,7 @@ class Epp::ContactsController < EppController
|
||||||
'postalInfo > addr > cc',
|
'postalInfo > addr > cc',
|
||||||
]
|
]
|
||||||
|
|
||||||
required_attributes.concat(address_attributes) if Contact.address_processing?
|
required_attributes.concat(address_attributes) if address_processing?
|
||||||
|
|
||||||
requires(*required_attributes)
|
requires(*required_attributes)
|
||||||
ident = params[:parsed_frame].css('ident')
|
ident = params[:parsed_frame].css('ident')
|
||||||
|
@ -202,4 +203,8 @@ class Epp::ContactsController < EppController
|
||||||
def address_given?
|
def address_given?
|
||||||
params[:parsed_frame].css('postalInfo addr').size != 0
|
params[:parsed_frame].css('postalInfo addr').size != 0
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def address_processing?
|
||||||
|
Contact.address_processing?
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -5,7 +5,7 @@ xml.epp_head do
|
||||||
end
|
end
|
||||||
|
|
||||||
xml.resData do
|
xml.resData do
|
||||||
xml.tag!('contact:infData', 'xmlns:contact' => 'https://epp.tld.ee/schema/contact-eis-1.0.xsd') do
|
xml.tag!('contact:infData', 'xmlns:contact' => 'https://epp.tld.ee/schema/contact-ee-1.1.xsd') do
|
||||||
xml.tag!('contact:id', @contact.code)
|
xml.tag!('contact:id', @contact.code)
|
||||||
xml.tag!('contact:roid', @contact.roid)
|
xml.tag!('contact:roid', @contact.roid)
|
||||||
|
|
||||||
|
@ -17,22 +17,30 @@ xml.epp_head do
|
||||||
xml.tag!('contact:name', @contact.name)
|
xml.tag!('contact:name', @contact.name)
|
||||||
if can? :view_full_info, @contact, @password
|
if can? :view_full_info, @contact, @password
|
||||||
xml.tag!('contact:org', @contact.org_name) if @contact.org_name.present?
|
xml.tag!('contact:org', @contact.org_name) if @contact.org_name.present?
|
||||||
xml.tag!('contact:addr') do
|
|
||||||
xml.tag!('contact:street', @contact.street)
|
if address_processing?
|
||||||
xml.tag!('contact:city', @contact.city)
|
xml.tag!('contact:addr') do
|
||||||
xml.tag!('contact:sp', @contact.state)
|
xml.tag!('contact:street', @contact.street)
|
||||||
xml.tag!('contact:pc', @contact.zip)
|
xml.tag!('contact:city', @contact.city)
|
||||||
xml.tag!('contact:cc', @contact.country_code)
|
xml.tag!('contact:sp', @contact.state)
|
||||||
|
xml.tag!('contact:pc', @contact.zip)
|
||||||
|
xml.tag!('contact:cc', @contact.country_code)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
else
|
else
|
||||||
xml.tag!('contact:org', 'No access')
|
xml.tag!('contact:org', 'No access')
|
||||||
xml.tag!('contact:addr') do
|
|
||||||
xml.tag!('contact:street', 'No access')
|
if address_processing?
|
||||||
xml.tag!('contact:city', 'No access')
|
xml.tag!('contact:addr') do
|
||||||
xml.tag!('contact:sp', 'No access')
|
xml.tag!('contact:street', 'No access')
|
||||||
xml.tag!('contact:pc', 'No access')
|
xml.tag!('contact:city', 'No access')
|
||||||
xml.tag!('contact:cc', 'No access')
|
xml.tag!('contact:sp', 'No access')
|
||||||
|
xml.tag!('contact:pc', 'No access')
|
||||||
|
xml.tag!('contact:cc', 'No access')
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
57
spec/requests/epp/contact/info_spec.rb
Normal file
57
spec/requests/epp/contact/info_spec.rb
Normal file
|
@ -0,0 +1,57 @@
|
||||||
|
require 'rails_helper'
|
||||||
|
|
||||||
|
RSpec.describe 'EPP contact:update' do
|
||||||
|
let(:request_xml) { '<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
|
<epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
|
||||||
|
<command>
|
||||||
|
<info>
|
||||||
|
<contact:info xmlns:contact="https://epp.tld.ee/schema/contact-ee-1.1.xsd">
|
||||||
|
<contact:id>test</contact:id>
|
||||||
|
</contact:info>
|
||||||
|
</info>
|
||||||
|
</command>
|
||||||
|
</epp>'
|
||||||
|
}
|
||||||
|
subject(:response_xml) { Nokogiri::XML(response.body) }
|
||||||
|
subject(:response_code) { response_xml.xpath('//xmlns:result').first['code'] }
|
||||||
|
subject(:address_count) { response_xml
|
||||||
|
.xpath('//contact:addr', contact: 'https://epp.tld.ee/schema/contact-ee-1.1.xsd')
|
||||||
|
.count }
|
||||||
|
|
||||||
|
before do
|
||||||
|
sign_in_to_epp_area
|
||||||
|
FactoryGirl.create(:contact, code: 'TEST')
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'when address processing is enabled' do
|
||||||
|
before do
|
||||||
|
allow(Contact).to receive(:address_processing?).and_return(true)
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'returns epp code of 1000' do
|
||||||
|
post '/epp/command/info', frame: request_xml
|
||||||
|
expect(response_code).to eq('1000')
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'returns address' do
|
||||||
|
post '/epp/command/info', frame: request_xml
|
||||||
|
expect(address_count).to_not be_zero
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'when address processing is disabled' do
|
||||||
|
before do
|
||||||
|
allow(Contact).to receive(:address_processing?).and_return(false)
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'returns epp code of 1000' do
|
||||||
|
post '/epp/command/info', frame: request_xml
|
||||||
|
expect(response_code).to eq('1000')
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'does not return address' do
|
||||||
|
post '/epp/command/info', frame: request_xml
|
||||||
|
expect(address_count).to be_zero
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
Loading…
Add table
Add a link
Reference in a new issue