From a38bb4aa0773751fad7ee17a5cf9b5d7db74aa1f Mon Sep 17 00:00:00 2001 From: Priit Tark Date: Mon, 1 Jun 2015 15:19:11 +0300 Subject: [PATCH 1/5] Registrar: contact honors now both legal and ident #2606 --- app/models/depp/contact.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/models/depp/contact.rb b/app/models/depp/contact.rb index 3c1a62974..ee0057a72 100644 --- a/app/models/depp/contact.rb +++ b/app/models/depp/contact.rb @@ -229,7 +229,12 @@ module Depp end def extension_xml - ident_xml.merge(legal_document_xml) + xml = {_anonymus: []} + ident = ident_xml[:_anonymus].try(:first) + legal = legal_document_xml[:_anonymus].try(:first) + xml[:_anonymus] << ident if ident.present? + xml[:_anonymus] << legal if legal.present? + xml end def ident_xml From f5feba05097dab63bcd78247cfd16e0e91be708c Mon Sep 17 00:00:00 2001 From: Priit Tark Date: Mon, 1 Jun 2015 16:46:21 +0300 Subject: [PATCH 2/5] Added new legal doc types #2607 --- app/models/legal_document.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/legal_document.rb b/app/models/legal_document.rb index f682e52f4..890abd3e0 100644 --- a/app/models/legal_document.rb +++ b/app/models/legal_document.rb @@ -2,7 +2,7 @@ class LegalDocument < ActiveRecord::Base include Versions # version/legal_document_version.rb belongs_to :documentable, polymorphic: true - TYPES = %w(pdf bdoc ddoc zip rar gz tar 7z) + TYPES = %w(pdf bdoc ddoc zip rar gz tar 7z odt doc docx) attr_accessor :body From 44482846808615902c5f14e3fe0129b0b02c060d Mon Sep 17 00:00:00 2001 From: Priit Tark Date: Mon, 1 Jun 2015 17:48:23 +0300 Subject: [PATCH 3/5] Added ident country code error #2590 --- app/models/contact.rb | 2 +- app/models/epp/contact.rb | 3 ++- config/locales/en.yml | 1 + spec/epp/contact_spec.rb | 19 +++++++++++++++++-- spec/models/contact_spec.rb | 4 +++- 5 files changed, 24 insertions(+), 5 deletions(-) diff --git a/app/models/contact.rb b/app/models/contact.rb index 34d3c53ae..5cbc6ac53 100644 --- a/app/models/contact.rb +++ b/app/models/contact.rb @@ -181,7 +181,7 @@ class Contact < ActiveRecord::Base if code self.ident_country_code = code.alpha2 else - errors.add(:ident_country_code, 'is not following ISO_3166-1 alpha 2 format') + errors.add(:ident, :invalid_country_code) end end end diff --git a/app/models/epp/contact.rb b/app/models/epp/contact.rb index f106a4247..b07bdc124 100644 --- a/app/models/epp/contact.rb +++ b/app/models/epp/contact.rb @@ -123,7 +123,8 @@ class Epp::Contact < Contact [:email, :invalid], [:ident, :invalid], [:ident, :invalid_EE_identity_format], - [:ident, :invalid_birthday_format] + [:ident, :invalid_birthday_format], + [:ident, :invalid_country_code] ], '2302' => [ # Object exists [:code, :epp_id_taken] diff --git a/config/locales/en.yml b/config/locales/en.yml index 4a4707f59..4e66c4283 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -48,6 +48,7 @@ en: blank: "Required parameter missing - ident" invalid_EE_identity_format: "Ident not in valid Estonian identity format." invalid_birthday_format: "Ident not in valid birthady format, should be YYYY-MM-DD" + invalid_country_code: "Ident country code is not valid, should be in ISO_3166-1 alpha 2 format" domains: exist: 'Object association prohibits operation' diff --git a/spec/epp/contact_spec.rb b/spec/epp/contact_spec.rb index 02540e109..12857d013 100644 --- a/spec/epp/contact_spec.rb +++ b/spec/epp/contact_spec.rb @@ -100,7 +100,7 @@ describe 'EPP Contact', epp: true do log.api_user_registrar.should == 'registrar1' end - it 'successfully saves ident type' do + it 'successfully saves ident type with legal document' do extension = { legalDocument: { value: 'JVBERi0xLjQKJcOkw7zDtsOfCjIgMCBvYmoKPDwvTGVuZ3RoIDMgMCBSL0Zp==', @@ -116,7 +116,9 @@ describe 'EPP Contact', epp: true do response[:msg].should == 'Command completed successfully' response[:result_code].should == '1000' - Contact.last.ident_type.should == 'birthday' + @contact = Contact.last + @contact.ident_type.should == 'birthday' + @contact.legal_documents.size.should == 1 end it 'successfully adds registrar' do @@ -164,6 +166,19 @@ describe 'EPP Contact', epp: true do response[:result_code].should == '2005' end + it 'should not saves ident type with wrong country code' do + extension = { + ident: { + value: '1990-22-12', + attrs: { type: 'birthday', cc: 'WRONG' } + } + } + response = create_request({}, extension) + response[:msg].should == + 'Ident country code is not valid, should be in ISO_3166-1 alpha 2 format [ident]' + response[:result_code].should == '2005' + end + it 'should add registrar prefix for code when legacy prefix present' do response = create_request({ id: { value: 'CID:FIRST0:abc:ABC:NEW:12345' } }) response[:msg].should == 'Command completed successfully' diff --git a/spec/models/contact_spec.rb b/spec/models/contact_spec.rb index 0b42f2812..107f72106 100644 --- a/spec/models/contact_spec.rb +++ b/spec/models/contact_spec.rb @@ -73,11 +73,13 @@ describe Contact do end it 'should require valid country code' do + @contact.ident = '123' @contact.ident_type = 'bic' @contact.ident_country_code = 'INVALID' @contact.valid? - @contact.errors[:ident_country_code].should == ['is not following ISO_3166-1 alpha 2 format'] + @contact.errors[:ident].should == + ['Ident country code is not valid, should be in ISO_3166-1 alpha 2 format'] end it 'should convert to alpha2 country code' do From 5c12362a7df53c352f0510d3be7e2c89491c29f4 Mon Sep 17 00:00:00 2001 From: Priit Tark Date: Tue, 2 Jun 2015 09:58:32 +0300 Subject: [PATCH 4/5] Syntax update --- app/models/depp/contact.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/depp/contact.rb b/app/models/depp/contact.rb index ee0057a72..5233525d8 100644 --- a/app/models/depp/contact.rb +++ b/app/models/depp/contact.rb @@ -229,7 +229,7 @@ module Depp end def extension_xml - xml = {_anonymus: []} + xml = { _anonymus: [] } ident = ident_xml[:_anonymus].try(:first) legal = legal_document_xml[:_anonymus].try(:first) xml[:_anonymus] << ident if ident.present? From 83e40b402ebfe0f1f96890c6ebf2764371c4b89a Mon Sep 17 00:00:00 2001 From: Priit Tark Date: Tue, 2 Jun 2015 11:50:41 +0300 Subject: [PATCH 5/5] Added possibility to overwrite legal document types #2607 --- CHANGELOG.md | 4 ++++ app/models/legal_document.rb | 6 +++++- config/application-example.yml | 3 +++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 04d4a0053..1e0e62e39 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +02.06.2015 + +* Added possibility to overwrite legal document types at application.yml level. + 01.06.2015 * Added separate data update, all data migration locate at db/data, more info 'rake -T data' diff --git a/app/models/legal_document.rb b/app/models/legal_document.rb index 890abd3e0..0972767f7 100644 --- a/app/models/legal_document.rb +++ b/app/models/legal_document.rb @@ -2,7 +2,11 @@ class LegalDocument < ActiveRecord::Base include Versions # version/legal_document_version.rb belongs_to :documentable, polymorphic: true - TYPES = %w(pdf bdoc ddoc zip rar gz tar 7z odt doc docx) + if ENV['legal_document_types'].present? + TYPES = ENV['legal_document_types'].split(',').map(&:strip) + else + TYPES = %w(pdf bdoc ddoc zip rar gz tar 7z odt doc docx) + end attr_accessor :body diff --git a/config/application-example.yml b/config/application-example.yml index 5296f9f9d..b506ec9ba 100644 --- a/config/application-example.yml +++ b/config/application-example.yml @@ -33,6 +33,9 @@ contact_org_enabled: 'false' # Enable iptables counter updater # iptables_counter_enabled: 'true' +# Custom legal document types +# legal_document_types: "pdf,bdoc,ddoc,zip,rar,gz,tar,7z,odt,doc,docx" + # DEPP server configuration (both for Registrar/Registrant servers) show_ds_data_fields: 'false' default_nameservers_count: '2'