Bug 2037902

Summary: Needs consistent error message in syspurpose modules(role/usage/addon) when an invalid org is used
Product: Red Hat Enterprise Linux 8 Reporter: Chris Snyder <csnyder>
Component: subscription-managerAssignee: candlepin-bugs
Status: CLOSED DUPLICATE QA Contact: Red Hat subscription-manager QE Team <rhsm-qe>
Severity: medium Docs Contact:
Priority: medium    
Version: 8.6CC: arpandey, candlepin-bugs, jsefler, ptoscano, redakkan, rhsm-qe
Target Milestone: rcKeywords: Triaged
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: subscription-manager-1.28.25-1.el8 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: 2026286 Environment:
Last Closed: 2022-01-07 14:43:08 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:
Bug Depends On: 2026013, 2026286    
Bug Blocks:    

Description Chris Snyder 2022-01-06 19:34:10 UTC
+++ This bug was initially created as a clone of Bug #2026286 +++

+++ This bug was initially created as a clone of Bug #2026013 +++

Description of problem:
When a user belong to single org tries to list syspurpose values on role/usage/addon with invalid org is succeeds while the old service-level module continues to fail 

Version-Release number of selected component (if applicable):
subscription management server: 3.2.21-1
subscription management rules: 5.41
subscription-manager: 1.28.24-1.el8

How reproducible:
always 

Steps to Reproduce:
1.On a unregistered system try to list syspurpose values with invalid org

# subscription-manager usage --list --username=rhsm_nonsca_1 --password=**** --org=foo
+-------------------------------------------+
               Available usage
+-------------------------------------------+
 - Production

# echo $?
0

# subscription-manager role --list --username=rhsm_nonsca_1 --password=**** --org=foo
+-------------------------------------------+
               Available role
+-------------------------------------------+
 - Red Hat Enterprise Linux Server

# echo $?
0


# subscription-manager addons --list --username=rhsm_nonsca_1 --password=**** --org=foo
There are no available values for the system purpose "addons" from the available subscriptions in this organization.

# echo $?
0

Notice the service-level module fails in this scenario 
# subscription-manager service-level --list --username=rhsm_nonsca_1 --password=**** --org=foo
Organization with id foo could not be found. (HTTP error code 404: Not Found)

# echo $?
65
Actual results:
only service-level module fails in this scenario

Expected results:
all the other syspurpose module should also fail similar to service-level

Additional info:
We should make sure to be consistent with  similar scenarios in subscription-manager

--- Additional comment from Archana Pandey on 2021-12-27 08:08:10 UTC ---

Preverification on jenkins build:

reproducing issue on : subscription-manager: 1.29.21-1.el9

[root@kvm-03-guest19 ~]# subscription-manager version
server type: This system is currently not registered.
subscription management server: 3.2.21-1
subscription management rules: 5.41
subscription-manager: 1.29.21-1.el9
[root@kvm-03-guest19 ~]# 
[root@kvm-03-guest19 ~]# subscription-manager service-level --list --username rhel9GA --password ****** --org=foo
Organization with id foo could not be found. (HTTP error code 404: Not Found)
[root@kvm-03-guest19 ~]# 
[root@kvm-03-guest19 ~]# subscription-manager role --list --username rhel9GA --password ****** --org=foo
+-------------------------------------------+ 
               Available role                           <<<<<<<<< org name ignored, should have thrown error
+-------------------------------------------+
 - Red Hat Enterprise Linux Server
[root@kvm-03-guest19 ~]# 
[root@kvm-03-guest19 ~]# subscription-manager usage --list --username rhel9GA --password ****** --org=foo
+-------------------------------------------+
               Available usage                          <<<<<<<<< org name ignored, should have thrown error
+-------------------------------------------+
 - Production               
[root@kvm-03-guest19 ~]# subscription-manager addons --list --username rhel9GA --password ****** --org=foo
There are no available values for the system purpose "addons" from the available subscriptions in this organization.       <<<<<<<<< org name ignored, should have thrown error
[root@hpe-dl380pgen8-02-vm-6 ~]#  
[root@hpe-dl380pgen8-02-vm-6 ~]# 
[root@hpe-dl380pgen8-02-vm-6 ~]# 


lets install latest build from jenkins and verify-

[root@kvm-03-guest19 ~]# subscription-manager version
server type: This system is currently not registered.
subscription management server: 3.2.21-1
subscription management rules: 5.41
subscription-manager: 1.29.21-1.git.71.2c658b9.el9
[root@kvm-03-guest19 ~]# 
[root@kvm-03-guest19 ~]# subscription-manager service-level --list --username rhel9GA --password ****** --org=foo
Organization with id foo could not be found. (HTTP error code 404: Not Found)                                    <<<<<<<<<<<< expected error message
[root@kvm-03-guest19 ~]# 
[root@kvm-03-guest19 ~]# subscription-manager role --list --username rhel9GA --password ****** --org=foo
Organization with id foo could not be found. (HTTP error code 404: Not Found)                                    <<<<<<<<<<<< expected error message
[root@kvm-03-guest19 ~]# 
[root@kvm-03-guest19 ~]# subscription-manager usage --list --username rhel9GA --password ****** --org=foo
Organization with id foo could not be found. (HTTP error code 404: Not Found)                                    <<<<<<<<<<<< expected error message
[root@kvm-03-guest19 ~]# 
[root@kvm-03-guest19 ~]# subscription-manager addons --list --username rhel9GA --password ****** --org=foo
Organization with id foo could not be found. (HTTP error code 404: Not Found)                                    <<<<<<<<<<<< expected error message
[root@kvm-03-guest19 ~]# 

verification for sub-man syspurpose sub-modules-

[root@kvm-03-guest19 ~]# subscription-manager syspurpose service-level --list --username rhel9GA --password ****** --org=foo
Organization with id foo could not be found. (HTTP error code 404: Not Found)                                     <<<<<<<<<<<< expected error message
[root@kvm-03-guest19 ~]# subscription-manager syspurpose role --list --username rhel9GA --password ****** --org=foo
Organization with id foo could not be found. (HTTP error code 404: Not Found)                                     <<<<<<<<<<<< expected error message
[root@kvm-03-guest19 ~]# subscription-manager syspurpose usage --list --username rhel9GA --password ****** --org=foo
Organization with id foo could not be found. (HTTP error code 404: Not Found)                                     <<<<<<<<<<<< expected error message
[root@kvm-03-guest19 ~]# 
[root@kvm-03-guest19 ~]# subscription-manager syspurpose addons --list --username rhel9GA --password ****** --org=foo
Organization with id foo could not be found. (HTTP error code 404: Not Found)                                     <<<<<<<<<<<< expected error message
[root@kvm-03-guest19 ~]# 


Verification result:PASSED - All the syspurpose modules(role/usage/service-level/addons) failing with consistent error message for incorrect org value

Comment 6 Chris Snyder 2022-01-07 14:43:08 UTC

*** This bug has been marked as a duplicate of bug 2026013 ***