Skip to content

Commit

Permalink
Merge pull request #34 from carbonin/encryption_key_validation
Browse files Browse the repository at this point in the history
Validate the encryption key when configuring the database
  • Loading branch information
bdunne authored May 7, 2018
2 parents 71e79cd + 61922c4 commit 3f49d2d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/manageiq/appliance_console/database_configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ def activate
begin
save
success = create_or_join_region
validate_encryption_key!
rescue
success = false
ensure
Expand Down Expand Up @@ -266,6 +267,10 @@ def self.load_current
YAML.load_file(DB_YML)
end

def validate_encryption_key!
raise "Encryption key invalid" unless ManageIQ::ApplianceConsole::Utilities.rake("evm:validate_encryption_key", {})
end

def do_save(settings)
require 'yaml'
File.write(DB_YML, YAML.dump(settings))
Expand Down
6 changes: 6 additions & 0 deletions spec/database_configuration_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,7 @@ def say(*_args)
it "normal case" do
allow(@config).to receive_messages(:validated => true)
expect(@config).to receive(:create_or_join_region).and_return(true)
expect(@config).to receive(:validate_encryption_key!).and_return(true)

allow(@config).to receive_messages(:merged_settings => @settings)
expect(@config).to receive(:do_save).with(@settings)
Expand Down Expand Up @@ -377,6 +378,11 @@ def say(*_args)
allow(@config).to receive(:create_or_join_region).and_raise
expect(@config.activate).to be_falsey
end

it "where the encryption key is invalid" do
allow(ManageIQ::ApplianceConsole::Utilities).to receive(:rake).with("evm:validate_encryption_key", {}).and_return(false)
expect(@config.activate).to be_falsey
end
end
end

Expand Down

0 comments on commit 3f49d2d

Please sign in to comment.