mirror of
https://github.com/internetee/registry.git
synced 2025-05-19 02:39:37 +02:00
parent
06e080ed43
commit
ba53a3e323
3 changed files with 60 additions and 28 deletions
|
@ -148,7 +148,6 @@ class Epp::Contact < Contact
|
|||
}
|
||||
end
|
||||
|
||||
# rubocop:disable Metrics/AbcSize
|
||||
def update_attributes(frame, current_user)
|
||||
return super if frame.blank?
|
||||
at = {}.with_indifferent_access
|
||||
|
@ -158,9 +157,6 @@ class Epp::Contact < Contact
|
|||
at[:statuses] = statuses - statuses_attrs(frame.css('rem'), 'rem') + statuses_attrs(frame.css('add'), 'add')
|
||||
end
|
||||
|
||||
# legal_frame = frame.css('legalDocument').first
|
||||
# at[:legal_documents_attributes] = self.class.legal_document_attrs(legal_frame)
|
||||
|
||||
if doc = attach_legal_document(Epp::Domain.parse_legal_document_from_frame(frame))
|
||||
frame.css("legalDocument").first.content = doc.path if doc && doc.persisted?
|
||||
self.legal_document_id = doc.id
|
||||
|
@ -168,28 +164,31 @@ class Epp::Contact < Contact
|
|||
|
||||
self.deliver_emails = true # turn on email delivery for epp
|
||||
|
||||
|
||||
# allow to update ident code for legacy contacts
|
||||
# Allow ident data update for legacy contacts
|
||||
if frame.css('ident').first
|
||||
self.ident_updated_at ||= Time.zone.now
|
||||
ident_frame = frame.css('ident').first
|
||||
|
||||
if ident_frame.text.present?
|
||||
deny_ident_update
|
||||
end
|
||||
|
||||
if ident_frame && ident_attr_valid?(ident_frame)
|
||||
org_priv = %w(org priv).freeze
|
||||
if ident_country_code.blank? && org_priv.include?(ident_type) && org_priv.include?(ident_frame.attr('type'))
|
||||
|
||||
if ident_frame.text == ident
|
||||
if ident_type.present? && ident_country_code.present?
|
||||
at.merge!(ident_type: ident_frame.attr('type'))
|
||||
at.merge!(ident_country_code: ident_frame.attr('cc'))
|
||||
elsif ident_country_code.blank? && org_priv.include?(ident_type) && org_priv.include?(ident_frame.attr('type'))
|
||||
at.merge!(ident_country_code: ident_frame.attr('cc'), ident_type: ident_frame.attr('type'))
|
||||
elsif ident_type == "birthday" && !ident[/\A\d{4}-\d{2}-\d{2}\z/] && (Date.parse(ident) rescue false)
|
||||
elsif ident_type == 'birthday' && !ident[/\A\d{4}-\d{2}-\d{2}\z/] && (Date.parse(ident) rescue false)
|
||||
at.merge!(ident: ident_frame.text)
|
||||
at.merge!(ident_country_code: ident_frame.attr('cc')) if ident_frame.attr('cc').present?
|
||||
elsif ident_type == "birthday" && ident_country_code.blank?
|
||||
at.merge!(ident_country_code: ident_frame.attr('cc'))
|
||||
elsif ident_type == 'birthday' && ident_country_code.blank?
|
||||
at.merge!(ident_country_code: ident_frame.attr('cc'))
|
||||
elsif ident_type.blank? && ident_country_code.blank?
|
||||
at.merge!(ident_type: ident_frame.attr('type'))
|
||||
at.merge!(ident_country_code: ident_frame.attr('cc')) if ident_frame.attr('cc').present?
|
||||
at.merge!(ident_country_code: ident_frame.attr('cc'))
|
||||
else
|
||||
deny_ident_update
|
||||
end
|
||||
else
|
||||
deny_ident_update
|
||||
end
|
||||
|
@ -203,7 +202,6 @@ class Epp::Contact < Contact
|
|||
|
||||
super(at)
|
||||
end
|
||||
# rubocop:enable Metrics/AbcSize
|
||||
|
||||
def statuses_attrs(frame, action)
|
||||
status_list = status_list_from(frame)
|
||||
|
@ -266,6 +264,6 @@ class Epp::Contact < Contact
|
|||
private
|
||||
|
||||
def deny_ident_update
|
||||
throw :epp_error, { code: '2306', msg: I18n.t(:ident_update_error) }
|
||||
throw :epp_error, { code: '2308', msg: I18n.t(:ident_update_error) }
|
||||
end
|
||||
end
|
||||
|
|
|
@ -498,7 +498,9 @@ en:
|
|||
crt_revoked: 'CRT (revoked)'
|
||||
contact_org_error: 'Parameter value policy error. Org must be blank'
|
||||
contact_fax_error: 'Parameter value policy error. Fax must be blank'
|
||||
ident_update_error: 'Parameter value policy error. Update of ident data not allowed [ident]'
|
||||
ident_update_error: >-
|
||||
Data management policy violation:
|
||||
update of ident not allowed, please consider creating new contact object
|
||||
invoices: 'Invoices'
|
||||
no_such_user: 'No such user'
|
||||
phone_no: 'Phone number'
|
||||
|
|
|
@ -18,7 +18,7 @@ RSpec.describe 'EPP contact:update' do
|
|||
</update>
|
||||
<extension>
|
||||
<eis:extdata xmlns:eis="https://epp.tld.ee/schema/eis-1.0.xsd">
|
||||
<eis:ident cc="US" type="org">test</eis:ident>
|
||||
<eis:ident cc="GB" type="priv">test</eis:ident>
|
||||
</eis:extdata>
|
||||
</extension>
|
||||
</command>
|
||||
|
@ -30,13 +30,45 @@ RSpec.describe 'EPP contact:update' do
|
|||
sign_in_to_epp_area
|
||||
end
|
||||
|
||||
context 'when :ident tag is given and a contact has been imported from legacy software' do
|
||||
let(:contact) { build(:contact, code: 'TEST', ident: nil, ident_type: nil, ident_country_code: nil) }
|
||||
context 'when submitted ident matches current one' do
|
||||
let!(:contact) { create(:contact, code: 'TEST', ident: 'test', ident_type: 'org', ident_country_code: 'US') }
|
||||
|
||||
it 'updates :ident_type' do
|
||||
request
|
||||
contact.reload
|
||||
expect(contact.ident_type).to eq('priv')
|
||||
end
|
||||
|
||||
it 'updates :ident_country_code' do
|
||||
request
|
||||
contact.reload
|
||||
expect(contact.ident_country_code).to eq('GB')
|
||||
end
|
||||
|
||||
specify do
|
||||
contact.save(validate: false)
|
||||
request
|
||||
expect(response).to have_code_of(2306)
|
||||
expect(response).to have_code_of(1000)
|
||||
end
|
||||
end
|
||||
|
||||
context 'when submitted ident does not match current one' do
|
||||
let!(:contact) { create(:contact, code: 'TEST', ident: 'some-ident', ident_type: 'org', ident_country_code: 'US') }
|
||||
|
||||
it 'does not update :ident_type' do
|
||||
request
|
||||
contact.reload
|
||||
expect(contact.ident_type).to eq('org')
|
||||
end
|
||||
|
||||
it 'does not update :ident_country_code' do
|
||||
request
|
||||
contact.reload
|
||||
expect(contact.ident_country_code).to eq('US')
|
||||
end
|
||||
|
||||
specify do
|
||||
request
|
||||
expect(response).to have_code_of(2308)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue