Bug 2222554

Summary: The registration_commands api endpoint does not replace unicode with ASCII
Product: Red Hat Satellite Reporter: matt jia <mjia>
Component: RegistrationAssignee: satellite6-bugs <satellite6-bugs>
Status: NEW --- QA Contact: Satellite QE Team <sat-qe-bz-list>
Severity: medium Docs Contact:
Priority: medium    
Version: 6.13.3CC: ahumbe, lstejska, nalfassi, ofedoren
Target Milestone: UnspecifiedKeywords: Triaged
Target Release: Unused   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 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 matt jia 2023-07-13 05:09:05 UTC
Description of problem:

When calling the api/registration_commands endpoint to generate the host registration command like:

curl -X POST https://xxx.xxx.redhat.com/api/registration_commands \
--user "admin" \
-H 'Content-Type: application/json' \
-d '{ "registration_command": { "activation_keys": ["test-ak "], "location_id": 4, "organization_id": 1 }}'

below curl command is generated:

curl -sS  'https://xxx.xxx.com/register?activation_keys=test-ak+\u0026location_id=4\u0026organization_id=2' -H 'Authorization: Bearer eyJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjo0LCJpYXQiOjE2ODkyMjMxNjUsImp0aSI6ImYzMmU1OTg3OThjMzM4YzAwMTBiNDE2NmUxMzJhMjZjZTkzMDIzZjdmYjY0MGVlOTI0MTcyNzgyYjg5NGY1M2IiLCJleHAiOjE2ODkyMzc1NjUsInNjb3BlIjoicmVnaXN0cmF0aW9uI2dsb2JhbCByZWdpc3RyYXRpb24jaG9zdCJ9.0nKQrYqCKSW4O_nohmB4SsquNSuQzd4N4WNuwiJAFBc'

as you can see, \u0026 is there rather &.  The result of running the curl command is that location_id and organization_id are not passed to the global registration template:

~~~
#!/bin/sh

# Make sure, all command output can be parsed (e.g. from subscription-manager)
export LC_ALL=C LANG=C
....
register_host() {
  curl --silent --show-error --cacert $SSL_CA_CERT --request POST https://xx.xxx.redhat.com/register \
       -H 'Authorization: Bearer eyJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjo0LCJpYXQiOjE2ODkyMjM1NzEsImp0aSI6ImJjMGQyZWM1MGEwZjEwMDc3ZTAxMmQ3ZjgwY2JhOTJhNDE4MDAxMjcwNTA2YjNiYmM3ZGRjYTUwOGNmZGVkOTMiLCJleHAiOjE2ODkyMzc5NzEsInNjb3BlIjoicmVnaXN0cmF0aW9uI2dsb2JhbCByZWdpc3RyYXRpb24jaG9zdCJ9.4UvxwfsvpyTMqZiihLu0R6rLft1-3z1z_p1uQJLnQ8o' \
       --data "host[name]=$(hostname --fqdn)" \
       --data "host[build]=false" \
       --data "host[managed]=false" \
       --data 'host[organization_id]=1' \  <== should be 2 
       --data 'host[location_id]=2' \ <== should be 4

}
~~~

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

6.13

How reproducible:

Easy

Steps to Reproduce:

Generate the registration command with:

~~~
curl -X POST https://xxx.xxx.redhat.com/api/registration_commands \
--user "admin" \
-H 'Content-Type: application/json' \
-d '{ "registration_command": { "activation_keys": ["test-ak "], "location_id": 4, "organization_id": 1 }}'
~~~

Actual results:

unicode characters are not converted to ASCII


Expected results:

unicode characters should be converted to ASCII 

Additional info:

Comment 1 Brad Buckingham 2023-07-13 14:06:29 UTC
Is this a regression in Satellite 6.13?  Thanks!

Comment 2 matt jia 2023-07-13 23:36:06 UTC
Hi Brad,

(In reply to Brad Buckingham from comment #1)
> Is this a regression in Satellite 6.13?  Thanks!

Not really as I can reproduce it on 6.11 too.

Comment 3 nalfassi 2023-07-18 11:09:16 UTC
On which OS are you running your Satellite? We tested it on Fedora and it is working properly, also on RHEL 8 for Satellite 6.14 (latest snap). 
Can you share the output for the `locale` command?