From 0c1006b771630ff7d8cf9f8d8cc1c295cfd07d2c Mon Sep 17 00:00:00 2001 From: Nick Carboni Date: Tue, 13 Feb 2018 17:34:58 -0500 Subject: [PATCH] Merge pull request #16997 from yrudman/fix-replication-validation-before-pglogical-schema-created Fix replication validation for not saved subscriptions (cherry picked from commit e7b6dcec1f24075f9d60955daf13596471a218df) Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1552790 --- app/models/pglogical_subscription.rb | 2 +- spec/models/pglogical_subscription_spec.rb | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/app/models/pglogical_subscription.rb b/app/models/pglogical_subscription.rb index 1c5dd5e3628..f566e209e8d 100644 --- a/app/models/pglogical_subscription.rb +++ b/app/models/pglogical_subscription.rb @@ -91,7 +91,7 @@ def pglogical(refresh = false) end def validate(new_connection_params = {}) - find_password + find_password if new_connection_params['password'].blank? connection_hash = attributes.merge(new_connection_params.delete_blanks) MiqRegionRemote.validate_connection_settings(connection_hash['host'], connection_hash['port'], diff --git a/spec/models/pglogical_subscription_spec.rb b/spec/models/pglogical_subscription_spec.rb index b967868f2a6..3c7e16b94b0 100644 --- a/spec/models/pglogical_subscription_spec.rb +++ b/spec/models/pglogical_subscription_spec.rb @@ -406,6 +406,15 @@ .with("my.example.com", nil, "root", "thepassword", "vmdb_production") sub.validate end + + it "validates connection parameters without accessing database or initializing subscription parameters" do + sub = described_class.new + + expect(pglogical).not_to receive(:subscription_show_status) + expect(MiqRegionRemote).to receive(:validate_connection_settings) + .with("my.example.com", nil, "root", "mypass", "vmdb_production") + sub.validate('host' => "my.example.com", 'user' => "root", 'password' => "mypass", 'dbname' => "vmdb_production") + end end describe "#backlog" do