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
|
class Admin::ContactsController < ApplicationController
|
||||||
before_action :set_contact, only: [:show]
|
before_action :set_contact, only: [:show]
|
||||||
|
|
||||||
|
def new
|
||||||
|
@contact = Contact.new
|
||||||
|
end
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@q = Contact.search(params[:q])
|
@q = Contact.search(params[:q])
|
||||||
@contacts = @q.result.page(params[:page])
|
@contacts = @q.result.page(params[:page])
|
||||||
|
|
|
@ -136,7 +136,13 @@ module Epp::DomainsHelper
|
||||||
## TRANSFER
|
## TRANSFER
|
||||||
def validate_domain_transfer_request
|
def validate_domain_transfer_request
|
||||||
@ph = params_hash['epp']['command']['transfer']['transfer']
|
@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
|
end
|
||||||
|
|
||||||
## DELETE
|
## DELETE
|
||||||
|
|
|
@ -10,4 +10,9 @@ class DomainTransfer < ActiveRecord::Base
|
||||||
CLIENT_REJECTED = 'clientRejected'
|
CLIENT_REJECTED = 'clientRejected'
|
||||||
SERVER_APPROVED = 'serverApproved'
|
SERVER_APPROVED = 'serverApproved'
|
||||||
SERVER_CANCELLED = 'serverCancelled'
|
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
|
end
|
||||||
|
|
|
@ -8,6 +8,9 @@ class Epp::EppDomain < Domain
|
||||||
domain_validation_sg = SettingGroup.domain_validation
|
domain_validation_sg = SettingGroup.domain_validation
|
||||||
|
|
||||||
{
|
{
|
||||||
|
'2002' => [
|
||||||
|
[:base, :domain_already_belongs_to_the_querying_registrar]
|
||||||
|
],
|
||||||
'2302' => [ # Object exists
|
'2302' => [ # Object exists
|
||||||
[:name_dirty, :taken, { value: { obj: 'name', val: name_dirty } }],
|
[:name_dirty, :taken, { value: { obj: 'name', val: name_dirty } }],
|
||||||
[:name_dirty, :reserved, { 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])
|
return approve_pending_transfer(params[:current_user])
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if !pt && params[:action] == 'query'
|
||||||
|
return false unless can_be_transferred_to?(params[:current_user].registrar)
|
||||||
|
end
|
||||||
|
|
||||||
return true if pt
|
return true if pt
|
||||||
|
|
||||||
wait_time = SettingGroup.domain_general.setting(:transfer_wait_time).value.to_i
|
wait_time = SettingGroup.domain_general.setting(:transfer_wait_time).value.to_i
|
||||||
|
@ -252,6 +259,14 @@ class Epp::EppDomain < Domain
|
||||||
true
|
true
|
||||||
end
|
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
|
## SHARED
|
||||||
|
|
||||||
# For domain transfer
|
# 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
|
%tbody
|
||||||
- @domain.nameservers.each do |x|
|
- @domain.nameservers.each do |x|
|
||||||
%tr
|
%tr
|
||||||
%td= link_to(x, root_path)
|
%td= x
|
||||||
%td= x.ipv4
|
%td= x.ipv4
|
||||||
%td= x.ipv6
|
%td= x.ipv6
|
||||||
%td
|
%td
|
||||||
|
|
|
@ -12,7 +12,7 @@ xml.epp_head do
|
||||||
xml.tag!('domain:reID', ldt.transfer_to.reg_no)
|
xml.tag!('domain:reID', ldt.transfer_to.reg_no)
|
||||||
xml.tag!('domain:reDate', ldt.transfer_requested_at)
|
xml.tag!('domain:reDate', ldt.transfer_requested_at)
|
||||||
xml.tag!('domain:acID', ldt.transfer_from.reg_no)
|
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)
|
xml.tag!('domain:exDate', @domain.valid_to)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -73,6 +73,7 @@ en:
|
||||||
attributes:
|
attributes:
|
||||||
base:
|
base:
|
||||||
domain_status_prohibits_operation: 'Domain status prohibits operation'
|
domain_status_prohibits_operation: 'Domain status prohibits operation'
|
||||||
|
domain_already_belongs_to_the_querying_registrar: 'Domain already belongs to the querying registrar'
|
||||||
name_dirty:
|
name_dirty:
|
||||||
invalid: 'Domain name is invalid'
|
invalid: 'Domain name is invalid'
|
||||||
reserved: 'Domain name is reserved or restricted'
|
reserved: 'Domain name is reserved or restricted'
|
||||||
|
@ -160,6 +161,7 @@ en:
|
||||||
invalid_type: 'PostalInfo type is invalid'
|
invalid_type: 'PostalInfo type is invalid'
|
||||||
unimplemented_command: 'Unimplemented command'
|
unimplemented_command: 'Unimplemented command'
|
||||||
domain_exists_but_belongs_to_other_registrar: 'Domain exists but belongs to other registrar'
|
domain_exists_but_belongs_to_other_registrar: 'Domain exists but belongs to other registrar'
|
||||||
|
attribute_op_is_invalid: 'Attribute op is invalid'
|
||||||
|
|
||||||
setting_groups:
|
setting_groups:
|
||||||
codes:
|
codes:
|
||||||
|
@ -256,3 +258,4 @@ en:
|
||||||
org_name: 'Organisation name'
|
org_name: 'Organisation name'
|
||||||
failed_to_add_domain: 'Failed to add domain!'
|
failed_to_add_domain: 'Failed to add domain!'
|
||||||
domain_added: 'Domain added!'
|
domain_added: 'Domain added!'
|
||||||
|
new_contact: 'New contact'
|
||||||
|
|
|
@ -108,7 +108,7 @@ describe 'EPP Domain', epp: true do
|
||||||
expect(domain.registrar).to eq(elkdata)
|
expect(domain.registrar).to eq(elkdata)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'prohibits wrong registrar from approving tranfer' do
|
it 'prohibits wrong registrar from approving transfer' do
|
||||||
domain.domain_transfers.create({
|
domain.domain_transfers.create({
|
||||||
status: DomainTransfer::PENDING,
|
status: DomainTransfer::PENDING,
|
||||||
transfer_requested_at: Time.zone.now,
|
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')
|
xml = domain_transfer_xml(pw: domain.auth_info, op: 'approve')
|
||||||
response = epp_request(xml, :xml, :zone)
|
response = epp_request(xml, :xml, :zone)
|
||||||
|
|
||||||
domain.reload
|
domain.reload
|
||||||
dtl = domain.domain_transfers.last
|
dtl = domain.domain_transfers.last
|
||||||
|
|
||||||
|
@ -152,6 +151,21 @@ describe 'EPP Domain', epp: true do
|
||||||
expect(response[:msg]).to eq('Authentication error')
|
expect(response[:msg]).to eq('Authentication error')
|
||||||
end
|
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
|
it 'creates new pw after successful transfer' do
|
||||||
pw = domain.auth_info
|
pw = domain.auth_info
|
||||||
xml = domain_transfer_xml(pw: pw)
|
xml = domain_transfer_xml(pw: pw)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue