Bug 2180568

Summary: Represent 'unlimited' as 0 for `hammer host-registration generate-command`
Product: Red Hat Satellite Reporter: Pablo Mendez Hernandez <pmendezh>
Component: RegistrationAssignee: Girija Soni <gisoni>
Status: CLOSED ERRATA QA Contact: Shweta Singh <shwsingh>
Severity: medium Docs Contact: Zuzana Lena Ansorgova <zuansorg>
Priority: medium    
Version: 6.13.0CC: ahumbe, bangelic, gisoni, jhutar, lstejska, msunil, rlavi, saydas, s.heijmans, shwsingh, zhunting, zuansorg
Target Milestone: 6.15.0Keywords: Triaged, WorkAround
Target Release: UnusedFlags: gisoni: needinfo+
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: foreman-3.9.1.3-1 Doc Type: Bug Fix
Doc Text:
.Generate host registration commands by using 0 as unlimited for JWT expiration Previously, it was not clear what value Hammer and API accept for generation of the host registration command with an unlimited authorization token. The accepted values are as follows: * 0 means unlimited * A value between 0 and 999999 is expiration in hours, 4 hours by default * Other values are not accepted. With this release, the unlimited value has been clarified in the Hammer help and API reference.
Story Points: ---
Clone Of: Environment:
Last Closed: 2024-04-23 17:13:57 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Pablo Mendez Hernandez 2023-03-21 19:37:51 UTC
Description of problem:

When trying to create a host-registration script with an unlimited life time using hammer, it complains about the parameter not being numeric (it's possible to set that generate that same script with unlimited life time through the web UI):

```
# hammer host-registration generate-command --organization-id 1 --activation-key $AK --jwt-expiration unlimited --insecure true --force true
Failed to generate registration command:
  Error: Option '--jwt-expiration': Numeric value is required..
  
  See: 'hammer host-registration generate-command --help'.
```

Version-Release number of selected component (if applicable):

Satellite 6.13 Snap 15


How reproducible:

Always.


Steps to Reproduce:
1.
2.
3.


Actual results:

Host registration command is not generated.


Expected results:

Host registration command should be generated with an unlimited JWT life time.


Additional info:

Comment 1 Ron Lavi 2023-04-04 08:27:29 UTC
I made this an RFE, to propose the support of `unlimited` token expiration option also in Hammer and also API

Comment 3 Leos Stejskal 2023-08-02 08:10:51 UTC
*** Bug 2228192 has been marked as a duplicate of this bug. ***

Comment 4 Sayan Das 2023-08-02 08:41:53 UTC
An important point to add ( mentioned in dup BZ# 2228192 )  is that when we use the API, it accepts "unlimited" as a valid value ( same as UI ). But it seems it's just the hammer with some validation in place which would not accept anything except a numerical value.

Comment 6 Leos Stejskal 2023-09-11 10:50:02 UTC
I will prioritize with my team, but looking at the description I believe this should
be a bug, not an RFE, It works in UI, but not in API.

Comment 7 Sayan Das 2023-11-13 14:09:43 UTC
Removing the FutureFeature keyword based on comment 6. Please consider it as a bug for hammer.

Comment 8 Girija Soni 2023-12-11 07:51:27 UTC
Created redmine issue https://projects.theforeman.org/issues/36972 from this bug

Comment 14 Shweta Singh 2024-01-23 11:04:08 UTC
FailedQA

Version Tested: 
1. Generate the curl command with "--jwt-expiration" option, set it to 0 for unlimited.

Observation:
When x < 0, it does not raises any error.

Comment 15 Pablo Mendez Hernandez 2024-01-23 12:14:21 UTC
```
# hammer -u admin -p $PASSWORD host-registration generate-command --organization "Default Organization" --activation-key $AK --location $LOCATION --jwt-expiration unlimited
Failed to generate registration command:
  Error: Option '--jwt-expiration': Numeric value is required..
```

Comment 16 Pablo Mendez Hernandez 2024-01-23 12:17:26 UTC
This was even in stream:

```
# rpm -q foreman
foreman-3.10.0-0.4.develop.20240116220126git0b40a64.el8sat.noarch
```

Comment 20 Shweta Singh 2024-02-05 07:40:48 UTC
Verified.

Version Tested: Satellite 6.15.0 Snap 8.0

Verification Steps:
1. Generate the curl command with "--jwt-expiration" option. Set it to different options as below and see if it works.
x = 0 Unlimited token
x < 0 raises an error, invalid value
x > 999999 raises an error, invalid value
x > 0 expiration in hours.
x = 4 default hours.

Result: Token life time values are working as expected.

Comment 33 errata-xmlrpc 2024-04-23 17:13:57 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (Important: Satellite 6.15.0 release), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHSA-2024:2010