-
Notifications
You must be signed in to change notification settings - Fork 297
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes #27485 - encrypt discovery password within task
(cherry picked from commit bc9fa13)
- Loading branch information
1 parent
91e3d29
commit 4eefa67
Showing
2 changed files
with
57 additions
and
12 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
require 'katello_test_helper' | ||
|
||
module EncryptionKey | ||
ENCRYPTION_KEY = nil | ||
end | ||
|
||
module Actions | ||
describe Katello::Repository::CloneToVersion do | ||
include Dynflow::Testing | ||
include Support::Actions::Fixtures | ||
include FactoryBot::Syntax::Methods | ||
|
||
let(:action_class) { ::Actions::Katello::Repository::Discover } | ||
|
||
def setup | ||
get_organization #ensure we have an org label | ||
end | ||
|
||
def test_discovers_without_encryption | ||
EncryptionKey.const_set(:ENCRYPTION_KEY, nil) | ||
|
||
mock_discovery = mock | ||
url = 'http://foo.com' | ||
::Katello::RepoDiscovery.expects(:new).with(url, 'yum', 'admin', 'secret', nil, {}, [], [], [url]).returns(mock_discovery) | ||
mock_discovery.expects(:run).with("http://foo.com").once | ||
|
||
task = ForemanTasks.sync_task(action_class, url, 'yum', 'admin', 'secret', nil) | ||
|
||
refute_empty task.input[:upstream_password] | ||
assert_equal task.input[:upstream_password], 'secret' | ||
end | ||
|
||
def test_discovers_with_hidden_password | ||
EncryptionKey.const_set(:ENCRYPTION_KEY, 'ebf26a286b3edec3d31ac10e8e97bd60') | ||
|
||
mock_discovery = mock | ||
url = 'http://foo.com' | ||
::Katello::RepoDiscovery.expects(:new).with(url, 'yum', 'admin', 'secret', nil, {}, [], [], [url]).returns(mock_discovery) | ||
mock_discovery.expects(:run).with("http://foo.com").once | ||
|
||
task = ForemanTasks.sync_task(action_class, url, 'yum', 'admin', 'secret', nil) | ||
|
||
refute_empty task.input[:upstream_password] | ||
refute_equal task.input[:upstream_password], 'secret' | ||
end | ||
end | ||
end |