From 165fd17216b3d864a3dc26d883c3c923f00e326e Mon Sep 17 00:00:00 2001 From: Priit Tark Date: Tue, 9 Jun 2015 13:16:28 +0300 Subject: [PATCH] Ident not allowed to update #2639 --- app/controllers/epp/contacts_controller.rb | 3 +++ app/models/epp/contact.rb | 1 - config/locales/en.yml | 1 + spec/epp/contact_spec.rb | 17 ++++++++++++----- 4 files changed, 16 insertions(+), 6 deletions(-) diff --git a/app/controllers/epp/contacts_controller.rb b/app/controllers/epp/contacts_controller.rb index ef5f81986..6685ed708 100644 --- a/app/controllers/epp/contacts_controller.rb +++ b/app/controllers/epp/contacts_controller.rb @@ -118,6 +118,9 @@ class Epp::ContactsController < EppController contact_org_disabled fax_disabled status_editing_disabled + if params[:parsed_frame].css('ident').present? + epp_errors << { code: '2306', msg: "#{I18n.t(:ident_update_error)} [ident]" } + end requires 'id' @prefix = nil end diff --git a/app/models/epp/contact.rb b/app/models/epp/contact.rb index b07bdc124..d9ba0a48a 100644 --- a/app/models/epp/contact.rb +++ b/app/models/epp/contact.rb @@ -143,7 +143,6 @@ class Epp::Contact < Contact at.deep_merge!(self.class.attrs_from(frame.css('rem'), 'rem')) at.deep_merge!(self.class.attrs_from(frame.css('add'))) at.deep_merge!(self.class.attrs_from(frame.css('chg'))) - at.merge!(self.class.ident_attrs(frame.css('ident').first)) legal_frame = frame.css('legalDocument').first at[:legal_documents_attributes] = self.class.legal_document_attrs(legal_frame) self.deliver_emails = true # turn on email delivery for epp diff --git a/config/locales/en.yml b/config/locales/en.yml index 2d4f14d66..b999eb9c2 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -505,6 +505,7 @@ 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' invoices: 'Invoices' no_such_user: 'No such user' log_in: 'Log in' diff --git a/spec/epp/contact_spec.rb b/spec/epp/contact_spec.rb index ebe0d646d..08e06b1c1 100644 --- a/spec/epp/contact_spec.rb +++ b/spec/epp/contact_spec.rb @@ -24,6 +24,12 @@ describe 'EPP Contact', epp: true do attrs: { type: 'priv', cc: 'EE' } } } + @update_extension = { + legalDocument: { + value: 'dGVzdCBmYWlsCg==', + attrs: { type: 'pdf' } + } + } end context 'with valid user' do @@ -272,7 +278,7 @@ describe 'EPP Contact', epp: true do end def update_request(overwrites = {}, extension = {}, options = {}) - extension = @extension if extension.blank? + extension = @update_extension if extension.blank? defaults = { id: { value: 'asd123123er' }, @@ -394,7 +400,7 @@ describe 'EPP Contact', epp: true do @contact.reload.code.should == 'FIRST0:SH8013' end - it 'should update ident' do + it 'should not be able to update ident' do extension = { legalDocument: { value: 'dGVzdCBmYWlsCg==', @@ -406,10 +412,11 @@ describe 'EPP Contact', epp: true do } } response = update_request({ id: { value: 'FIRST0:SH8013' } }, extension) - response[:msg].should == 'Command completed successfully' - response[:result_code].should == '1000' + response[:msg].should == + 'Parameter value policy error. Update of ident data not allowed [ident]' + response[:result_code].should == '2306' - Contact.find_by(code: 'FIRST0:SH8013').ident_type.should == 'birthday' + Contact.find_by(code: 'FIRST0:SH8013').ident_type.should == 'priv' end it 'should return parameter value policy errror for org update' do