forked from ManageIQ/manageiq
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
FixAuth for ConfigurationScript#credentials
- Loading branch information
Showing
4 changed files
with
65 additions
and
2 deletions.
There are no files selected for viewing
38 changes: 38 additions & 0 deletions
38
spec/tools/fix_auth/models/fix_configuration_script_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
$LOAD_PATH << Rails.root.join("tools").to_s | ||
|
||
require "fix_auth" | ||
|
||
RSpec.describe FixAuth::FixConfigurationScript do | ||
let!(:configuration_script) { FactoryBot.create(:configuration_script, :credentials => credentials) } | ||
let(:legacy_key) { ManageIQ::Password::Key.new } | ||
let(:pass) { "password" } | ||
let(:enc_old) { ManageIQ::Password.encrypt(pass, legacy_key) } | ||
let(:options) { {:legacy_key => legacy_key, :silent => true} } | ||
|
||
context "with nil credentials" do | ||
let(:credentials) { nil } | ||
|
||
it "does nothing" do | ||
FixAuth::FixConfigurationScript.run(options) | ||
expect(configuration_script.credentials).to be_nil | ||
end | ||
end | ||
|
||
context "with no v2 encrypted passwords in credentials" do | ||
let(:credentials) { {} } | ||
|
||
it "does nothing" do | ||
FixAuth::FixConfigurationScript.run(options) | ||
expect(configuration_script.credentials).to eq({}) | ||
end | ||
end | ||
|
||
context "with v2 encrypted passwords in credentials" do | ||
let(:credentials) { {"foo" => enc_old} } | ||
|
||
it "re-encrypts the passwords" do | ||
FixAuth::FixConfigurationScript.run(options) | ||
expect(configuration_script.reload.credentials["foo"]).to be_encrypted(pass) | ||
end | ||
end | ||
end |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters