Skip to content

Commit

Permalink
feat: support registering specifying environments with activation keys
Browse files Browse the repository at this point in the history
* Card-ID: CCT-762
* Removes validation to prevent specifying environment during
  registration with activation key
  • Loading branch information
rverdile committed Sep 25, 2024
1 parent c763cc0 commit 629418e
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 15 deletions.
4 changes: 0 additions & 4 deletions src/rhsmlib/services/register.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,10 +239,6 @@ def validate_options(self, options: dict) -> None:
raise exceptions.ValidationError(
_("Error: Activation keys can not be used with previously" " registered IDs.")
)
elif options["environments"]:
raise exceptions.ValidationError(
_("Error: Activation keys do not allow environments to be" " specified.")
)
elif options.get("jwt_token") is not None:
# TODO: add more checks here
pass
Expand Down
2 changes: 0 additions & 2 deletions src/subscription_manager/cli_command/register.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,6 @@ def _validate_options(self):
system_exit(
os.EX_USAGE, _("Error: Activation keys can not be used with previously registered IDs.")
)
elif self.options.environments and self.options.activation_keys:
system_exit(os.EX_USAGE, _("Error: Activation keys do not allow environments to be specified."))
# 746259: Don't allow the user to pass in an empty string as an activation key
elif self.options.activation_keys and "" in self.options.activation_keys:
system_exit(os.EX_USAGE, _("Error: Must specify an activation key"))
Expand Down
9 changes: 0 additions & 9 deletions test/rhsmlib/services/test_register.py
Original file line number Diff line number Diff line change
Expand Up @@ -508,15 +508,6 @@ def test_does_not_allow_basic_auth_with_activation_keys(self):
with self.assertRaisesRegex(exceptions.ValidationError, r".*do not require user credentials.*"):
register.RegisterService(self.mock_cp).validate_options(options)

def test_does_not_allow_environment_with_activation_keys(self):
self.mock_cp.username = None
self.mock_cp.password = None

self.mock_identity.is_valid.return_value = False
options = self._build_options(activation_keys=[1], environments="environment")
with self.assertRaisesRegex(exceptions.ValidationError, r".*do not allow environments.*"):
register.RegisterService(self.mock_cp).validate_options(options)

def test_does_not_allow_environment_with_consumerid(self):
self.mock_cp.username = None
self.mock_cp.password = None
Expand Down

0 comments on commit 629418e

Please sign in to comment.