mirror of
https://github.com/internetee/registry.git
synced 2025-05-17 17:59:47 +02:00
Refactor domain transfer controller
This commit is contained in:
parent
b91f9b1a8e
commit
d056d370be
3 changed files with 42 additions and 25 deletions
|
@ -58,32 +58,13 @@ class Epp::DomainsController < EppController
|
||||||
authorize! :transfer, @domain, @password
|
authorize! :transfer, @domain, @password
|
||||||
action = params[:parsed_frame].css('transfer').first[:op]
|
action = params[:parsed_frame].css('transfer').first[:op]
|
||||||
|
|
||||||
if action == 'query'
|
@domain_transfer = @domain.transfer(params[:parsed_frame], action, current_user)
|
||||||
if @domain.pending_transfer
|
|
||||||
@domain_transfer = @domain.pending_transfer
|
|
||||||
else
|
|
||||||
@domain_transfer = @domain.query_transfer(params[:parsed_frame], current_user)
|
|
||||||
handle_errors(@domain) and return unless @domain_transfer
|
|
||||||
end
|
|
||||||
elsif action == 'approve'
|
|
||||||
if @domain.pending_transfer
|
|
||||||
@domain_transfer = @domain.approve_transfer(params[:parsed_frame], current_user)
|
|
||||||
handle_errors(@domain) and return unless @domain_transfer
|
|
||||||
else
|
|
||||||
epp_errors << { code: '2303', msg: I18n.t('pending_transfer_was_not_found') }
|
|
||||||
handle_errors(@domain) and return
|
|
||||||
end
|
|
||||||
elsif action == 'reject'
|
|
||||||
if @domain.pending_transfer
|
|
||||||
@domain_transfer = @domain.reject_transfer(params[:parsed_frame], current_user)
|
|
||||||
handle_errors(@domain) and return unless @domain_transfer
|
|
||||||
else
|
|
||||||
epp_errors << { code: '2303', msg: I18n.t('pending_transfer_was_not_found') }
|
|
||||||
handle_errors(@domain) and return
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
render_epp_response '/epp/domains/transfer'
|
if @domain.errors.empty? && @domain_transfer
|
||||||
|
render_epp_response '/epp/domains/transfer'
|
||||||
|
else
|
||||||
|
handle_errors(@domain)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# rubocop: enable Metrics/MethodLength
|
# rubocop: enable Metrics/MethodLength
|
||||||
|
|
|
@ -385,6 +385,23 @@ class Epp::Domain < Domain
|
||||||
|
|
||||||
### TRANSFER ###
|
### TRANSFER ###
|
||||||
|
|
||||||
|
# rubocop: disable Metrics/PerceivedComplexity
|
||||||
|
# rubocop: disable Metrics/CyclomaticComplexity
|
||||||
|
def transfer(frame, action, current_user)
|
||||||
|
case action
|
||||||
|
when 'query'
|
||||||
|
return pending_transfer if pending_transfer
|
||||||
|
return query_transfer(frame, current_user)
|
||||||
|
when 'approve'
|
||||||
|
return approve_transfer(frame, current_user) if pending_transfer
|
||||||
|
when 'reject'
|
||||||
|
return reject_transfer(frame, current_user) if pending_transfer
|
||||||
|
end
|
||||||
|
add_epp_error('2303', nil, nil, I18n.t('pending_transfer_was_not_found'))
|
||||||
|
end
|
||||||
|
# rubocop: enable Metrics/PerceivedComplexity
|
||||||
|
# rubocop: enable Metrics/CyclomaticComplexity
|
||||||
|
|
||||||
# rubocop: disable Metrics/MethodLength
|
# rubocop: disable Metrics/MethodLength
|
||||||
def query_transfer(frame, current_user)
|
def query_transfer(frame, current_user)
|
||||||
return false unless can_be_transferred_to?(current_user.registrar)
|
return false unless can_be_transferred_to?(current_user.registrar)
|
||||||
|
|
|
@ -1046,6 +1046,25 @@ describe 'EPP Domain', epp: true do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'should get an error when there is no pending transfer ' do
|
||||||
|
pw = domain.auth_info
|
||||||
|
xml = domain_transfer_xml({
|
||||||
|
name: { value: domain.name },
|
||||||
|
authInfo: { pw: { value: pw } }
|
||||||
|
}, 'approve', {
|
||||||
|
_anonymus: [
|
||||||
|
legalDocument: {
|
||||||
|
value: 'JVBERi0xLjQKJcOkw7zDtsOfCjIgMCBvYmoKPDwvTGVuZ3RoIDMgMCBSL0Zp==',
|
||||||
|
attrs: { type: 'pdf' }
|
||||||
|
}
|
||||||
|
]
|
||||||
|
})
|
||||||
|
|
||||||
|
response = epp_plain_request(xml, :xml)
|
||||||
|
response[:msg].should == 'Pending transfer was not found'
|
||||||
|
response[:result_code].should == '2303'
|
||||||
|
end
|
||||||
|
|
||||||
### UPDATE ###
|
### UPDATE ###
|
||||||
it 'updates a domain' do
|
it 'updates a domain' do
|
||||||
existing_pw = Domain.last.auth_info
|
existing_pw = Domain.last.auth_info
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue