mirror of
https://github.com/internetee/registry.git
synced 2025-07-05 18:53:26 +02:00
EPP transfer request improvements
This commit is contained in:
parent
2d2a12b7d0
commit
d5954239da
10 changed files with 56 additions and 5 deletions
|
@ -1,6 +1,10 @@
|
|||
class Admin::ContactsController < ApplicationController
|
||||
before_action :set_contact, only: [:show]
|
||||
|
||||
def new
|
||||
@contact = Contact.new
|
||||
end
|
||||
|
||||
def index
|
||||
@q = Contact.search(params[:q])
|
||||
@contacts = @q.result.page(params[:page])
|
||||
|
|
|
@ -136,7 +136,13 @@ module Epp::DomainsHelper
|
|||
## TRANSFER
|
||||
def validate_domain_transfer_request
|
||||
@ph = params_hash['epp']['command']['transfer']['transfer']
|
||||
xml_attrs_present?(@ph, [['name']])
|
||||
attrs_present = xml_attrs_present?(@ph, [['name']])
|
||||
return false unless attrs_present
|
||||
|
||||
op = parsed_frame.css('transfer').first[:op]
|
||||
return true if %w(approve query).include?(op)
|
||||
epp_errors << { code: '2306', msg: I18n.t('errors.messages.attribute_op_is_invalid') }
|
||||
false
|
||||
end
|
||||
|
||||
## DELETE
|
||||
|
|
|
@ -10,4 +10,9 @@ class DomainTransfer < ActiveRecord::Base
|
|||
CLIENT_REJECTED = 'clientRejected'
|
||||
SERVER_APPROVED = 'serverApproved'
|
||||
SERVER_CANCELLED = 'serverCancelled'
|
||||
|
||||
def transfer_confirm_time
|
||||
wait_time = SettingGroup.domain_general.setting(:transfer_wait_time).value.to_i
|
||||
transfer_requested_at + wait_time.hours
|
||||
end
|
||||
end
|
||||
|
|
|
@ -8,6 +8,9 @@ class Epp::EppDomain < Domain
|
|||
domain_validation_sg = SettingGroup.domain_validation
|
||||
|
||||
{
|
||||
'2002' => [
|
||||
[:base, :domain_already_belongs_to_the_querying_registrar]
|
||||
],
|
||||
'2302' => [ # Object exists
|
||||
[:name_dirty, :taken, { value: { obj: 'name', val: name_dirty } }],
|
||||
[:name_dirty, :reserved, { value: { obj: 'name', val: name_dirty } }]
|
||||
|
@ -188,6 +191,10 @@ class Epp::EppDomain < Domain
|
|||
return approve_pending_transfer(params[:current_user])
|
||||
end
|
||||
|
||||
if !pt && params[:action] == 'query'
|
||||
return false unless can_be_transferred_to?(params[:current_user].registrar)
|
||||
end
|
||||
|
||||
return true if pt
|
||||
|
||||
wait_time = SettingGroup.domain_general.setting(:transfer_wait_time).value.to_i
|
||||
|
@ -252,6 +259,14 @@ class Epp::EppDomain < Domain
|
|||
true
|
||||
end
|
||||
|
||||
def can_be_transferred_to?(new_registrar)
|
||||
if new_registrar == registrar
|
||||
errors.add(:base, :domain_already_belongs_to_the_querying_registrar)
|
||||
return false
|
||||
end
|
||||
true
|
||||
end
|
||||
|
||||
## SHARED
|
||||
|
||||
# For domain transfer
|
||||
|
|
1
app/views/admin/contacts/_form.haml
Normal file
1
app/views/admin/contacts/_form.haml
Normal file
|
@ -0,0 +1 @@
|
|||
to be done
|
3
app/views/admin/contacts/new.haml
Normal file
3
app/views/admin/contacts/new.haml
Normal file
|
@ -0,0 +1,3 @@
|
|||
%h2= t('shared.new_contact')
|
||||
%hr
|
||||
= render 'form'
|
|
@ -16,7 +16,7 @@
|
|||
%tbody
|
||||
- @domain.nameservers.each do |x|
|
||||
%tr
|
||||
%td= link_to(x, root_path)
|
||||
%td= x
|
||||
%td= x.ipv4
|
||||
%td= x.ipv6
|
||||
%td
|
||||
|
|
|
@ -12,7 +12,7 @@ xml.epp_head do
|
|||
xml.tag!('domain:reID', ldt.transfer_to.reg_no)
|
||||
xml.tag!('domain:reDate', ldt.transfer_requested_at)
|
||||
xml.tag!('domain:acID', ldt.transfer_from.reg_no)
|
||||
xml.tag!('domain:acDate', ldt.transferred_at) if ldt.transferred_at
|
||||
xml.tag!('domain:acDate', ldt.transferred_at || ldt.transfer_confirm_time)
|
||||
xml.tag!('domain:exDate', @domain.valid_to)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -73,6 +73,7 @@ en:
|
|||
attributes:
|
||||
base:
|
||||
domain_status_prohibits_operation: 'Domain status prohibits operation'
|
||||
domain_already_belongs_to_the_querying_registrar: 'Domain already belongs to the querying registrar'
|
||||
name_dirty:
|
||||
invalid: 'Domain name is invalid'
|
||||
reserved: 'Domain name is reserved or restricted'
|
||||
|
@ -160,6 +161,7 @@ en:
|
|||
invalid_type: 'PostalInfo type is invalid'
|
||||
unimplemented_command: 'Unimplemented command'
|
||||
domain_exists_but_belongs_to_other_registrar: 'Domain exists but belongs to other registrar'
|
||||
attribute_op_is_invalid: 'Attribute op is invalid'
|
||||
|
||||
setting_groups:
|
||||
codes:
|
||||
|
@ -256,3 +258,4 @@ en:
|
|||
org_name: 'Organisation name'
|
||||
failed_to_add_domain: 'Failed to add domain!'
|
||||
domain_added: 'Domain added!'
|
||||
new_contact: 'New contact'
|
||||
|
|
|
@ -108,7 +108,7 @@ describe 'EPP Domain', epp: true do
|
|||
expect(domain.registrar).to eq(elkdata)
|
||||
end
|
||||
|
||||
it 'prohibits wrong registrar from approving tranfer' do
|
||||
it 'prohibits wrong registrar from approving transfer' do
|
||||
domain.domain_transfers.create({
|
||||
status: DomainTransfer::PENDING,
|
||||
transfer_requested_at: Time.zone.now,
|
||||
|
@ -132,7 +132,6 @@ describe 'EPP Domain', epp: true do
|
|||
|
||||
xml = domain_transfer_xml(pw: domain.auth_info, op: 'approve')
|
||||
response = epp_request(xml, :xml, :zone)
|
||||
|
||||
domain.reload
|
||||
dtl = domain.domain_transfers.last
|
||||
|
||||
|
@ -152,6 +151,21 @@ describe 'EPP Domain', epp: true do
|
|||
expect(response[:msg]).to eq('Authentication error')
|
||||
end
|
||||
|
||||
it 'ignores transfer when owner registrar requests transfer' do
|
||||
pw = domain.auth_info
|
||||
xml = domain_transfer_xml(pw: pw)
|
||||
response = epp_request(xml, :xml, :zone)
|
||||
|
||||
expect(response[:result_code]).to eq('2002')
|
||||
expect(response[:msg]).to eq('Domain already belongs to the querying registrar')
|
||||
end
|
||||
|
||||
it 'returns an error for incorrect op attribute' do
|
||||
response = epp_request(domain_transfer_xml(op: 'bla'), :xml, :zone)
|
||||
expect(response[:result_code]).to eq('2306')
|
||||
expect(response[:msg]).to eq('Attribute op is invalid')
|
||||
end
|
||||
|
||||
it 'creates new pw after successful transfer' do
|
||||
pw = domain.auth_info
|
||||
xml = domain_transfer_xml(pw: pw)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue