Story: #104525314 - enable registrantChangeProhibited and enforce in Epp::Domain#update

This commit is contained in:
Matt Farnsworth 2015-10-28 19:19:51 +02:00
parent 8744f23928
commit 339885cd3d
4 changed files with 19 additions and 9 deletions

View file

@ -49,7 +49,7 @@ class Epp::DomainsController < EppController
def update
authorize! :update, @domain, @password
begin
if @domain.update(params[:parsed_frame], current_user)
if @domain.epp_pending_update.present?
render_epp_response '/epp/domains/success_pending'
@ -59,6 +59,9 @@ class Epp::DomainsController < EppController
else
handle_errors(@domain)
end
rescue
handle_errors(@domain)
end
end
def delete

View file

@ -16,6 +16,10 @@ class Domain < ActiveRecord::Base
has_many :tech_domain_contacts
accepts_nested_attributes_for :tech_domain_contacts, allow_destroy: !:tech_change_prohibited?, reject_if: :tech_change_prohibited?
def registrant_change_prohibited?
statuses.include? DomainStatus::SERVER_REGISTRANT_CHANGE_PROHIBITED
end
# NB! contacts, admin_contacts, tech_contacts are empty for a new record
has_many :domain_contacts, dependent: :destroy

View file

@ -127,7 +127,7 @@ class DomainStatus < ActiveRecord::Base
SERVER_MANUAL_INZONE,
SERVER_RENEW_PROHIBITED,
SERVER_TRANSFER_PROHIBITED,
# SERVER_REGISTRANT_CHANGE_PROHIBITED,
SERVER_REGISTRANT_CHANGE_PROHIBITED,
SERVER_ADMIN_CHANGE_PROHIBITED,
SERVER_TECH_CHANGE_PROHIBITED,
SERVER_UPDATE_PROHIBITED,
@ -143,7 +143,7 @@ class DomainStatus < ActiveRecord::Base
# [''],
['RenewProhibited', SERVER_RENEW_PROHIBITED],
['TransferProhibited', SERVER_TRANSFER_PROHIBITED],
# ['RegistrantChangeProhibited', SERVER_REGISTRANT_CHANGE_PROHIBITED],
['RegistrantChangeProhibited', SERVER_REGISTRANT_CHANGE_PROHIBITED],
['AdminChangeProhibited', SERVER_ADMIN_CHANGE_PROHIBITED],
['TechChangeProhibited', SERVER_TECH_CHANGE_PROHIBITED],
# [''],

View file

@ -149,6 +149,9 @@ class Epp::Domain < Domain
code = frame.css('registrant').first.try(:text)
if code.present?
if action == 'chg' && registrant_change_prohibited?
add_epp_error('2304', nil, DomainStatus::SERVER_REGISTRANT_CHANGE_PROHIBITED, I18n.t(:object_status_prohibits_operation))
end
regt = Registrant.find_by(code: code)
if regt
at[:registrant_id] = regt.id
@ -433,7 +436,7 @@ class Epp::Domain < Domain
def update(frame, current_user, verify = true)
return super if frame.blank?
at = {}.with_indifferent_access
at.deep_merge!(attrs_from(frame.css('chg'), current_user))
at.deep_merge!(attrs_from(frame.css('chg'), current_user, 'chg'))
at.deep_merge!(attrs_from(frame.css('rem'), current_user, 'rem'))
at_add = attrs_from(frame.css('add'), current_user)