Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions src/subscription_manager/cli_command/register.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,8 +188,7 @@ def _upload_profile(self, consumer: dict) -> None:
# of DNF profile by rhsmcertd. We try to "outsource" this activity to rhsmcertd
# server to not block registration process.
# Note: rhsmcertd tries to upload profile using Python script and this script
# is always triggered with --force-upload CLI option. We ignore report_package_config
# configure option here due to BZ: 767265
# is always triggered with --force-upload CLI option.
log.debug("Sending SIGUSR1 signal to rhsmcertd process")
try:
os.kill(rhsmcertd_pid, signal.SIGUSR1)
Expand Down Expand Up @@ -346,7 +345,10 @@ def _do_command(self):
# FIXME: aside from the overhead, should this be cert_action_client.update?
self.entcertlib.update()

self._upload_profile(consumer)
if conf["rhsm"].get_int("report_package_profile") == 1:
self._upload_profile(consumer)
else:
log.info("Skipping package profile upload due to report_package_profile config setting.")

self._request_validity_check()

Expand Down
39 changes: 39 additions & 0 deletions test/test_registration.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

from .stubs import StubUEP

from subscription_manager.cli_command import register
from subscription_manager.cli_command.register import RegisterCommand
from subscription_manager import injection as inj
from subscription_manager import cache
Expand Down Expand Up @@ -322,6 +323,44 @@ def env_list(*args, **kwargs):
with self.assertRaises(SystemExit):
rc._process_environments(mock_uep, "owner")

def test_registration_with_package_profile_disabled(self):
rhsm_conf_original_value = register.conf["rhsm"].get_int

def get_package_profile_disabled(key):
return 0 if key == "report_package_profile" else rhsm_conf_original_value(key)

with patch("rhsm.connection.UEPConnection", new_callable=StubUEP) as mock_uep:
self.stub_cp_provider.basic_auth_cp = mock_uep
cmd = RegisterCommand()
cmd._upload_profile = Mock()

with patch.object(register.conf["rhsm"], "get_int", side_effect=get_package_profile_disabled):
with Capture() as cap:
cmd.main(["--force", "--username", "admin", "--password", "admin", "--org", "admin"])
output = cap.out
self.assertTrue("The system has been registered with ID" in output)
self.assertTrue("The registered system name is:" in output)
cmd._upload_profile.assert_not_called()

def test_registration_with_package_profile_enabled(self):
rhsm_conf_original_value = register.conf["rhsm"].get_int("report_package_profile")

def get_package_profile_enabled(key):
return 1 if key == "report_package_profile" else rhsm_conf_original_value(key)

with patch("rhsm.connection.UEPConnection", new_callable=StubUEP) as mock_uep:
self.stub_cp_provider.basic_auth_cp = mock_uep
cmd = RegisterCommand()
cmd._upload_profile = Mock()

with patch.object(register.conf["rhsm"], "get_int", side_effect=get_package_profile_enabled):
with Capture() as cap:
cmd.main(["--force", "--username", "admin", "--password", "admin", "--org", "admin"])
output = cap.out
self.assertTrue("The system has been registered with ID" in output)
self.assertTrue("The registered system name is:" in output)
cmd._upload_profile.assert_called_once()

def test_registration_with_failed_profile_upload(self):
with patch("rhsm.connection.UEPConnection", new_callable=StubUEP) as mock_uep:
profile_mgr = inj.require(inj.PROFILE_MANAGER)
Expand Down
Loading