From 65a749edc8214f995d89117d86cb42e0a10b0a4e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karl=20Erik=20=C3=95unapuu?= Date: Mon, 27 Jul 2020 11:47:49 +0300 Subject: [PATCH 01/12] Reference LHV branch without keystores gem --- Gemfile | 2 +- Gemfile.lock | 6 ++---- test/fixtures/files/keystore.jks | Bin 2242 -> 0 bytes test/fixtures/files/keystore.p12 | Bin 0 -> 2579 bytes 4 files changed, 3 insertions(+), 5 deletions(-) delete mode 100644 test/fixtures/files/keystore.jks create mode 100644 test/fixtures/files/keystore.p12 diff --git a/Gemfile b/Gemfile index 99091f556..b78d2edbd 100644 --- a/Gemfile +++ b/Gemfile @@ -66,7 +66,7 @@ gem 'airbrake' gem 'company_register', github: 'internetee/company_register', branch: :master gem 'e_invoice', github: 'internetee/e_invoice', branch: :master -gem 'lhv', github: 'internetee/lhv', branch: :master +gem 'lhv', github: 'internetee/lhv', branch: 'remove-keystores-gem' gem 'domain_name' gem 'haml', '~> 5.0' gem 'wkhtmltopdf-binary', '~> 0.12.5.1' diff --git a/Gemfile.lock b/Gemfile.lock index e4ad26396..8d303b602 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -45,11 +45,10 @@ GIT GIT remote: https://github.com/internetee/lhv.git - revision: c53dd82393f8a81f6e9da793ae0474294ef88762 - branch: master + revision: af0d3127bed6606ac50c44696bd56b09c096ac39 + branch: remove-keystores-gem specs: lhv (0.1.0) - keystores logger nokogiri @@ -266,7 +265,6 @@ GEM activerecord kaminari-core (= 1.2.1) kaminari-core (1.2.1) - keystores (0.4.0) libxml-ruby (3.2.0) listen (3.2.1) rb-fsevent (~> 0.10, >= 0.10.3) diff --git a/test/fixtures/files/keystore.jks b/test/fixtures/files/keystore.jks deleted file mode 100644 index 7ce34f308d5df462a90842275cecdb54f6fef5ac..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2242 zcmchYS5VW58pZQZLP(@ZS%UNuFrY|6LRG4iD1wq0dJ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zVb9M-4#zpJ8Vt>jf?S#-QX|O;3$3c_Dgo&P?W>!NK4XM+j*FLhFcByWm9spjPK?JZ Q*B=|e+h($ diff --git a/test/fixtures/files/keystore.p12 b/test/fixtures/files/keystore.p12 new file mode 100644 index 0000000000000000000000000000000000000000..962ddede2ae754b1ca56a2967b800799ba2d0194 GIT binary patch literal 2579 zcmY+Ec{CJ`7RMQ58Ai4-!p|6cjbz52vP8<3q^3w&nru_ZzK!KKw)!!)W>Uh)7G)X6 zJ|af4CHqcxLd3`<+w;zQ@Ao_J+;h)8=kvYy{`o=Tx%mLBY)Cw)jRS;;F^*yKvU0L! z;X$=PJgD**mm%@&PX8CN-vZ*ONJ(O}!@qZPL7@w63`^X-Vp9)OL7ZVAK#+dN1+$eH-Rv?tShC3VObC0_#wK)6oG z05xa);Y?08NEEvILIU&f!(h{?14S>ofTCWPXzPu4eBek%KA83 zA)gq(M(bv)%ElA;`@NInjKI3ri;djWHtDJi!AdMNGPy=ftG7B*)xu4y7*7 zxl2$?ee3S5$9Ih`npw-GB&ZF(5T{&f zg(J@Sot7DTpK)X6OTT3^BdkYyx2S6J`sOWXSQ#XABDsA;HQMp_H|tT8E%Ih=)Uxr0 zw3^La&-RSPqQ`#eMM2w?C<#{@xh~hXmfQ$+eHV>dy%c#6E)rZ=6^_CZd#EnqB*`gP zqSX$G#5D2g69B=V-RnJlizCP8t7cj^x^vw@CT#=VMO=Vc7_aS3;zz68ySEH*{qr5lFDv$#Us;`D*u1)*ffa_Qo zTo%u69Bms61C5Qhuw7m9ja2LVnw|0B7^@xU*mUD>v?s5g8a|ZY|4r(rGTG_n+_c?io-G&Lvp9o z^{X~!9jYwE_{T5?W_w*-7=cJwb6;08Cdcc>Qf0M`W&aJmg>>h6w>8zgz37;2qV><~ zYmD{wmlipfeJ>Xj7^gVil(!Yj1_+J_I;KRPedF)>?;+;R4pMah^=%b8z`C zR>fQMr?SQbv4dLR3EHnAgr|_w13DL;f%uF4159#ALEYL09fPoJL9VAA_kR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xk4m|J#3x9U9 zjKbUzw`6Cfu@a$vS0iv2((SHgPS`uTzD*46_UZWewvIeEY)PCcObm;NFW1o~4*#$Y zmbBQfs!sT^Jk4nii*yS7FtPDuX3=oUw7Z+DH&sxHyiyh+cdtZZ?m#l6xMEw>B?Q0V zDTYn&nU=hb#(|by0$Oft$X__`oKfJ=8)e&i+UE28sW8C6^Rfo{OUS-K-3RBTqtvJg zpVlPA&KEGcDi#q176u_L>B`~3I~?!pZx&@Oc=xG@9~zxr65m?QDbkh2o+VZ+T^P_y zt2vv%gFHCg>}DniPte_Be}h|>4Y6B^PBzX?qrxc*LQ&vnBbF0k9x2}gvaY0vD|tjm zZfO-yPO}GXaUEidedQ24uU!ZueMnBn0s6@x<)9OZ1As-0qi#<>bv_~^(0^VfIHsj( zQm1V3`I5UC{RIrm%bGCo@!jyjTtFg9x-8oR_<>empPer9e^b%hIi` z(KzJ Date: Mon, 27 Jul 2020 11:48:51 +0300 Subject: [PATCH 02/12] Replace LHV JKS store with P12 --- config/application.yml.sample | 6 ++---- .../create_bank_transactions.rake | 11 ++++------- lib/tasks/invoices/process_payments.rake | 11 ++++------- test/tasks/invoices/process_payments_test.rb | 6 ++++++ 4 files changed, 16 insertions(+), 18 deletions(-) diff --git a/config/application.yml.sample b/config/application.yml.sample index 691740b2a..7fd92d092 100644 --- a/config/application.yml.sample +++ b/config/application.yml.sample @@ -148,9 +148,8 @@ action_mailer_default_port: # default: no port (80) action_mailer_default_from: # no-reply@example.com action_mailer_force_delete_from: # `From` header for `DomainDeleteMailer#forced` email -lhv_keystore: +lhv_p12_keystore: lhv_keystore_password: -lhv_keystore_alias: lhv_ca_file: # Needed only in dev mode lhv_dev_mode: 'false' @@ -163,9 +162,8 @@ test: action_mailer_default_host: 'registry.test' action_mailer_default_from: 'no-reply@registry.test' action_mailer_force_delete_from: 'legal@registry.test' - lhv_keystore: 'test/fixtures/files/keystore.jks' + lhv_p12_keystore: 'test/fixtures/files/keystore.p12' lhv_keystore_password: 'testtest' - lhv_keystore_alias: 'testtest' # Airbrake // Errbit: airbrake_host: "https://your-errbit-host.ee" diff --git a/lib/tasks/dev/create_bank_transactions/create_bank_transactions.rake b/lib/tasks/dev/create_bank_transactions/create_bank_transactions.rake index 33614d049..17b7586e2 100644 --- a/lib/tasks/dev/create_bank_transactions/create_bank_transactions.rake +++ b/lib/tasks/dev/create_bank_transactions/create_bank_transactions.rake @@ -3,12 +3,9 @@ namespace :dev do remitter_iban = ENV['remitter_iban'] beneficiary_iban = Setting.registry_iban - keystore_password = ENV['lhv_keystore_password'] - keystore_alias = ENV['lhv_keystore_alias'] - keystore = Keystores::JavaKeystore.new - keystore.load(ENV['lhv_keystore'], keystore_password) - cert = keystore.get_certificate(keystore_alias) - key = keystore.get_key(keystore_alias, keystore_password) + keystore = OpenSSL::PKCS12.new(File.read(ENV['lhv_p12_keystore']), ENV['lhv_keystore_password']) + key = keystore.key + cert = keystore.certificate api_base_uri = URI.parse('https://testconnect.lhv.eu/connect-prelive') request_headers = { 'content-type' => 'application/xml' } @@ -38,4 +35,4 @@ namespace :dev do end end end -end \ No newline at end of file +end diff --git a/lib/tasks/invoices/process_payments.rake b/lib/tasks/invoices/process_payments.rake index 6e4c57213..340aba187 100644 --- a/lib/tasks/invoices/process_payments.rake +++ b/lib/tasks/invoices/process_payments.rake @@ -2,12 +2,9 @@ namespace :invoices do task process_payments: :environment do registry_bank_account_iban = Setting.registry_iban - keystore_password = ENV['lhv_keystore_password'] - keystore_alias = ENV['lhv_keystore_alias'] - keystore = Keystores::JavaKeystore.new - keystore.load(ENV['lhv_keystore'], keystore_password) - cert = keystore.get_certificate(keystore_alias) - key = keystore.get_key(keystore_alias, keystore_password) + keystore = OpenSSL::PKCS12.new(File.read(ENV['lhv_p12_keystore']), ENV['lhv_keystore_password']) + key = keystore.key + cert = keystore.certificate api = Lhv::ConnectApi.new api.cert = cert @@ -46,4 +43,4 @@ namespace :invoices do puts "Transactions processed: #{incoming_transactions.size}" end -end \ No newline at end of file +end diff --git a/test/tasks/invoices/process_payments_test.rb b/test/tasks/invoices/process_payments_test.rb index 02855e9fa..bd447be29 100644 --- a/test/tasks/invoices/process_payments_test.rb +++ b/test/tasks/invoices/process_payments_test.rb @@ -88,6 +88,12 @@ class ProcessPaymentsTaskTest < ActiveSupport::TestCase end end + def test_parses_keystore_properly + assert_nothing_raised do + run_task + end + end + private def run_task From 3b53e122845c395d87a57847644068982c67d881 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karl=20Erik=20=C3=95unapuu?= Date: Mon, 10 Aug 2020 12:47:02 +0300 Subject: [PATCH 03/12] Clear contact address fields if address processing turned off --- app/models/contact.rb | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/app/models/contact.rb b/app/models/contact.rb index ac64b059f..e91dab3b5 100644 --- a/app/models/contact.rb +++ b/app/models/contact.rb @@ -62,6 +62,7 @@ class Contact < ApplicationRecord mapping: [%w[ident code], %w[ident_type type], %w[ident_country_code country_code]] after_save :update_related_whois_records + before_save :clear_address_modifications, if: -> { !self.class.address_processing? } self.ignored_columns = %w[legacy_id legacy_history_id] @@ -507,6 +508,21 @@ class Contact < ApplicationRecord ]).present? end + def clear_address_modifications + return unless modifies_address? + + addr_fields = %i[city street zip state country_code] + addr_fields.each { |field| self[field] = nil } + end + + def modifies_address? + addr_fields = %i[city street zip state country_code] + modified = false + addr_fields.each { |field| modified = true if changes.key?(field) } + + modified + end + def update_related_whois_records # not doing anything if no real changes ignored_columns = %w[updated_at created_at statuses status_notes] From 1bc0ec07d38b39c86875780473775fa1f80d353e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karl=20Erik=20=C3=95unapuu?= Date: Mon, 10 Aug 2020 13:59:50 +0300 Subject: [PATCH 04/12] Fix registrant API test --- test/integration/api/v1/registrant/contacts/update_test.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/integration/api/v1/registrant/contacts/update_test.rb b/test/integration/api/v1/registrant/contacts/update_test.rb index 6e0c0eea3..e2e9abe9a 100644 --- a/test/integration/api/v1/registrant/contacts/update_test.rb +++ b/test/integration/api/v1/registrant/contacts/update_test.rb @@ -91,8 +91,8 @@ class RegistrantApiV1ContactUpdateTest < ActionDispatch::IntegrationTest end def test_address_is_optional_when_enabled - @contact.update!(street: 'any', zip: 'any', city: 'any', state: 'any', country_code: 'US') Setting.address_processing = true + @contact.update!(street: 'any', zip: 'any', city: 'any', state: 'any', country_code: 'US') patch api_v1_registrant_contact_path(@contact.uuid), params: { name: 'any' }, as: :json, From 55ae0dc0b785e1a3fd3c514e215dd353039ab59a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karl=20Erik=20=C3=95unapuu?= Date: Mon, 10 Aug 2020 14:05:22 +0300 Subject: [PATCH 05/12] Remove redundant functions --- app/models/contact.rb | 6 ++---- test/models/contact_test.rb | 2 ++ 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/models/contact.rb b/app/models/contact.rb index e91dab3b5..a2057f229 100644 --- a/app/models/contact.rb +++ b/app/models/contact.rb @@ -511,14 +511,12 @@ class Contact < ApplicationRecord def clear_address_modifications return unless modifies_address? - addr_fields = %i[city street zip state country_code] - addr_fields.each { |field| self[field] = nil } + remove_address end def modifies_address? - addr_fields = %i[city street zip state country_code] modified = false - addr_fields.each { |field| modified = true if changes.key?(field) } + self.class.address_attribute_names.each { |field| modified = true if changes.key?(field) } modified end diff --git a/test/models/contact_test.rb b/test/models/contact_test.rb index f833011c6..48b98a0d2 100644 --- a/test/models/contact_test.rb +++ b/test/models/contact_test.rb @@ -152,6 +152,8 @@ class ContactTest < ActiveSupport::TestCase end def test_address + Setting.address_processing = true + address = Contact::Address.new('new street', '83746', 'new city', 'new state', 'EE') @contact.address = address @contact.save! From 625bd459de045ae7f923acefc47b81e57a10164b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karl=20Erik=20=C3=95unapuu?= Date: Mon, 10 Aug 2020 14:27:05 +0300 Subject: [PATCH 06/12] Explicitly set address_processing to false in tests --- test/test_helper.rb | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/test/test_helper.rb b/test/test_helper.rb index bee6fdcf9..1b70baf49 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -47,6 +47,7 @@ class ActiveSupport::TestCase teardown do travel_back + Setting.address_processing = false end end @@ -60,9 +61,14 @@ class ApplicationIntegrationTest < ActionDispatch::IntegrationTest WebMock.reset! Capybara.reset_sessions! Capybara.use_default_driver + Setting.address_processing = false end end class EppTestCase < ActionDispatch::IntegrationTest include Assertions::EppAssertions + + teardown do + Setting.address_processing = false + end end From 8f8b246e493779503dd7c19e6c13d9ff51d093d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karl=20Erik=20=C3=95unapuu?= Date: Mon, 10 Aug 2020 16:04:02 +0300 Subject: [PATCH 07/12] Query address mandatoryness via Contact.address_processing? --- app/models/actions/contact_update.rb | 2 +- app/models/contact.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/models/actions/contact_update.rb b/app/models/actions/contact_update.rb index 5b94cf918..f8b39ecb4 100644 --- a/app/models/actions/contact_update.rb +++ b/app/models/actions/contact_update.rb @@ -23,7 +23,7 @@ module Actions end def maybe_remove_address - return if Setting.address_processing? + return if Contact.address_processing? new_attributes.delete(:city) new_attributes.delete(:zip) diff --git a/app/models/contact.rb b/app/models/contact.rb index a2057f229..4199e6dc7 100644 --- a/app/models/contact.rb +++ b/app/models/contact.rb @@ -62,7 +62,7 @@ class Contact < ApplicationRecord mapping: [%w[ident code], %w[ident_type type], %w[ident_country_code country_code]] after_save :update_related_whois_records - before_save :clear_address_modifications, if: -> { !self.class.address_processing? } + before_validation :clear_address_modifications, if: -> { !self.class.address_processing? } self.ignored_columns = %w[legacy_id legacy_history_id] From e40353042e7d509c9b1196db1f7d9a9b75296ea5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karl=20Erik=20=C3=95unapuu?= Date: Mon, 10 Aug 2020 16:04:52 +0300 Subject: [PATCH 08/12] Include tests for EPP contact create/update actions regarding to addressing --- app/models/epp/response/result/code.rb | 1 + .../epp/contact/create/base_test.rb | 111 ++++++++++++++++++ .../epp/contact/update/base_test.rb | 93 +++++++++++++++ 3 files changed, 205 insertions(+) diff --git a/app/models/epp/response/result/code.rb b/app/models/epp/response/result/code.rb index 2a65f6747..e2af0823d 100644 --- a/app/models/epp/response/result/code.rb +++ b/app/models/epp/response/result/code.rb @@ -7,6 +7,7 @@ module Epp KEY_TO_VALUE = { completed_successfully: 1000, completed_successfully_action_pending: 1001, + completed_without_address: 1100, completed_successfully_no_messages: 1300, completed_successfully_ack_to_dequeue: 1301, completed_successfully_ending_session: 1500, diff --git a/test/integration/epp/contact/create/base_test.rb b/test/integration/epp/contact/create/base_test.rb index e9a59b8d2..262487a1e 100644 --- a/test/integration/epp/contact/create/base_test.rb +++ b/test/integration/epp/contact/create/base_test.rb @@ -140,4 +140,115 @@ class EppContactCreateBaseTest < EppTestCase end assert_epp_response :required_parameter_missing end + + def test_does_not_save_address_when_address_processing_turned_off + name = 'new' + email = 'new@registrar.test' + phone = '+1.2' + + request_xml = <<-XML + + + + + + + #{name} + + 123 Example + Tallinn + FFF + 123456 + EE + + + #{phone} + #{email} + + + + + 123 + + + + + XML + + assert_difference 'Contact.count' do + post epp_create_path, params: { frame: request_xml }, + headers: { 'HTTP_COOKIE' => 'session=api_bestnames' } + end + + assert_epp_response :completed_without_address + contact = Contact.find_by(name: name) + assert_equal name, contact.name + assert_equal email, contact.email + assert_equal phone, contact.phone + assert_not_empty contact.code + assert_nil contact.city + assert_nil contact.street + assert_nil contact.zip + assert_nil contact.country_code + assert_nil contact.state + end + + def test_saves_address_when_address_processing_turned_on + Setting.address_processing = true + + name = 'new' + email = 'new@registrar.test' + phone = '+1.2' + street = '123 Example' + city = 'Tallinn' + state = 'Harjumaa' + zip = '123456' + country_code = 'EE' + + request_xml = <<-XML + + + + + + + #{name} + + #{street} + #{city} + #{state} + #{zip} + #{country_code} + + + #{phone} + #{email} + + + + + 123 + + + + + XML + + assert_difference 'Contact.count' do + post epp_create_path, params: { frame: request_xml }, + headers: { 'HTTP_COOKIE' => 'session=api_bestnames' } + end + + assert_epp_response :completed_successfully + contact = Contact.find_by(name: name) + assert_equal name, contact.name + assert_equal email, contact.email + assert_equal phone, contact.phone + assert_not_empty contact.code + assert_equal city, contact.city + assert_equal street, contact.street + assert_equal zip, contact.zip + assert_equal country_code, contact.country_code + assert_equal state, contact.state + end end diff --git a/test/integration/epp/contact/update/base_test.rb b/test/integration/epp/contact/update/base_test.rb index 3d332711f..98c0e4462 100644 --- a/test/integration/epp/contact/update/base_test.rb +++ b/test/integration/epp/contact/update/base_test.rb @@ -232,6 +232,99 @@ class EppContactUpdateBaseTest < EppTestCase assert_epp_response :completed_successfully end + def test_updates_address_when_address_processing_turned_on + @contact.update_columns(code: @contact.code.upcase) + Setting.address_processing = true + + street = '123 Example' + city = 'Tallinn' + state = 'Harjumaa' + zip = '123456' + country_code = 'EE' + + request_xml = <<-XML + + + + + + #{@contact.code} + + + + #{street} + #{city} + #{state} + #{zip} + #{country_code} + + + + + + + + XML + + post epp_update_path, params: { frame: request_xml }, + headers: { 'HTTP_COOKIE' => 'session=api_bestnames' } + + assert_epp_response :completed_successfully + @contact.reload + + assert_equal city, @contact.city + assert_equal street, @contact.street + assert_equal zip, @contact.zip + assert_equal country_code, @contact.country_code + assert_equal state, @contact.state + end + + def test_does_not_update_address_when_address_processing_turned_off + @contact.update_columns(code: @contact.code.upcase) + + street = '123 Example' + city = 'Tallinn' + state = 'Harjumaa' + zip = '123456' + country_code = 'EE' + + request_xml = <<-XML + + + + + + #{@contact.code} + + + + #{street} + #{city} + #{state} + #{zip} + #{country_code} + + + + + + + + XML + + post epp_update_path, params: { frame: request_xml }, + headers: { 'HTTP_COOKIE' => 'session=api_bestnames' } + + assert_epp_response :completed_without_address + @contact.reload + + assert_nil @contact.city + assert_nil @contact.street + assert_nil @contact.zip + assert_nil @contact.country_code + assert_nil @contact.state + end + private def make_contact_free_of_domains_where_it_acts_as_a_registrant(contact) From 414519d17fa76363b1077cdaaa8dfa65f10056a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karl=20Erik=20=C3=95unapuu?= Date: Mon, 10 Aug 2020 16:13:35 +0300 Subject: [PATCH 09/12] Improve addressing tests --- app/models/epp/response/result/code.rb | 1 + test/models/contact_test.rb | 1 + test/models/epp/response/result/code_test.rb | 2 ++ 3 files changed, 4 insertions(+) diff --git a/app/models/epp/response/result/code.rb b/app/models/epp/response/result/code.rb index e2af0823d..1be4a3f7c 100644 --- a/app/models/epp/response/result/code.rb +++ b/app/models/epp/response/result/code.rb @@ -36,6 +36,7 @@ module Epp DEFAULT_DESCRIPTIONS = { 1000 => 'Command completed successfully', 1001 => 'Command completed successfully; action pending', + 1100 => 'Command completed successfully; Postal address data discarded', 1300 => 'Command completed successfully; no messages', 1301 => 'Command completed successfully; ack to dequeue', 1500 => 'Command completed successfully; ending session', diff --git a/test/models/contact_test.rb b/test/models/contact_test.rb index 48b98a0d2..000333d57 100644 --- a/test/models/contact_test.rb +++ b/test/models/contact_test.rb @@ -240,6 +240,7 @@ class ContactTest < ActiveSupport::TestCase end def test_normalizes_country_code + Setting.address_processing = true contact = Contact.new(country_code: 'us') contact.validate assert_equal 'US', contact.country_code diff --git a/test/models/epp/response/result/code_test.rb b/test/models/epp/response/result/code_test.rb index 3c75303f1..f16013180 100644 --- a/test/models/epp/response/result/code_test.rb +++ b/test/models/epp/response/result/code_test.rb @@ -28,6 +28,7 @@ class EppResponseResultCodeTest < ActiveSupport::TestCase codes = { completed_successfully: 1000, completed_successfully_action_pending: 1001, + completed_without_address: 1100, completed_successfully_no_messages: 1300, completed_successfully_ack_to_dequeue: 1301, completed_successfully_ending_session: 1500, @@ -58,6 +59,7 @@ class EppResponseResultCodeTest < ActiveSupport::TestCase descriptions = { 1000 => 'Command completed successfully', 1001 => 'Command completed successfully; action pending', + 1100 => 'Command completed successfully; Postal address data discarded', 1300 => 'Command completed successfully; no messages', 1301 => 'Command completed successfully; ack to dequeue', 1500 => 'Command completed successfully; ending session', From 075b4900a05f75a84660a374361d6764c64ff505 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timo=20V=C3=B5hmar?= Date: Tue, 11 Aug 2020 13:37:30 +0300 Subject: [PATCH 10/12] Update CHANGELOG.md --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index f6a9ff66a..3ba471dc7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +11.08.2020 +* FIxed postal address saving bug with disabled address processing [#1650](https://github.com/internetee/registry/issues/1650) + 07.08.2020 * Restored creator and updator strings to contacts and related object records [#1636](https://github.com/internetee/registry/issues/1636) * Security gem updates: sdoc to 1.1 and json to 2.3.1 [#1657](https://github.com/internetee/registry/pull/1657) From ca1f3a9a48dbf928bc7f83a5c8e7242f2e4f8448 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karl=20Erik=20=C3=95unapuu?= Date: Thu, 13 Aug 2020 13:14:03 +0300 Subject: [PATCH 11/12] Reference newer version of LHV gem --- Gemfile | 2 +- Gemfile.lock | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Gemfile b/Gemfile index c20e18f26..7ad72f5fa 100644 --- a/Gemfile +++ b/Gemfile @@ -66,7 +66,7 @@ gem 'airbrake' gem 'company_register', github: 'internetee/company_register', branch: :master gem 'e_invoice', github: 'internetee/e_invoice', branch: :master -gem 'lhv', github: 'internetee/lhv', branch: 'remove-keystores-gem' +gem 'lhv', github: 'internetee/lhv', branch: 'master' gem 'domain_name' gem 'haml', '~> 5.0' gem 'wkhtmltopdf-binary', '~> 0.12.5.1' diff --git a/Gemfile.lock b/Gemfile.lock index 698d8ca1d..7b18612e0 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -45,8 +45,8 @@ GIT GIT remote: https://github.com/internetee/lhv.git - revision: af0d3127bed6606ac50c44696bd56b09c096ac39 - branch: remove-keystores-gem + revision: 1825240b3bf8b262418cc6c8ef7ed1aba386dd7d + branch: master specs: lhv (0.1.0) logger From fec622f9748ba60d14440f75fcf244ff133d83f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timo=20V=C3=B5hmar?= Date: Thu, 13 Aug 2020 14:40:40 +0300 Subject: [PATCH 12/12] Update CHANGELOG.md --- CHANGELOG.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3ba471dc7..9bf7358d7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ +13.08.2020 +* Removed keystore gem and replaced LHV JKS with PKCS12 [#1645](https://github.com/internetee/registry/issues/1645) + 11.08.2020 -* FIxed postal address saving bug with disabled address processing [#1650](https://github.com/internetee/registry/issues/1650) +* Fixed postal address saving bug with disabled address processing [#1650](https://github.com/internetee/registry/issues/1650) 07.08.2020 * Restored creator and updator strings to contacts and related object records [#1636](https://github.com/internetee/registry/issues/1636)