Bug 2225148

Summary: Can set download policy to background from command line.
Product: Red Hat Satellite Reporter: Mohit Kushwah <mkushwah>
Component: RepositoriesAssignee: satellite6-bugs <satellite6-bugs>
Status: CLOSED NOTABUG QA Contact: Satellite QE Team <sat-qe-bz-list>
Severity: medium Docs Contact:
Priority: low    
Version: 6.14.0CC: iballou, rlavi
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: 2023-07-31 16:03:47 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:
Attachments:
Description Flags
Download policy shows blank option from Web UI. none

Description Mohit Kushwah 2023-07-24 12:13:56 UTC
Created attachment 1977286 [details]
Download policy shows blank option from Web UI.

Description of problem:

While setting the download policy for any repository from the command line, the command should show some error.

Still, Can set the deprecated 'background' download policy for repositories from the command line and it shows a blank option on Web UI.



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

Red Hat Satellite 6.14


How reproducible:

Always


Steps to Reproduce:


1. Install a new Red Hat Satellite 6.14

2. Enable and Sync repositories before making any changes.

3. Change the download policy from the command line as below:

~~~
# echo "update katello_root_repositories set download_policy = 'background' where download_policy = 'on_demand'" |su - postgres -c 'psql foreman'
~~~

4. From Web UI, we can see (Refer to attachment) the download policy is showing a blank option.

5. And while syncing the repository we can see the below error:

~~~
Error message: the server returns an error
HTTP status code: 400
Response headers: {"Date"=>"Mon, 24 Jul 2023 11:42:40 GMT", "Server"=>"gunicorn", "Content-Type"=>"application/json", "Vary"=>"Accept,Cookie", "Allow"=>"GET, PUT, PATCH, DELETE, HEAD, OPTIONS", "X-Frame-Options"=>"DENY", "Content-Length"=>"52", "X-Content-Type-Options"=>"nosniff", "Referrer-Policy"=>"same-origin", "Correlation-ID"=>"1021c2af-483c-4f6e-8a9d-bdefdcdba79c", "Access-Control-Expose-Headers"=>"Correlation-ID", "Via"=>"1.1 satellite.example.com", "Connection"=>"close"}
Response body: {"policy":["\"background\" is not a valid choice."]}
~~~




Actual results:

- Can set the download policy for any repository to 'background' from the command line.


Expected results:

While setting the download policy to 'background' from the command it should show some errors as the option is deprecated.







Additional info:


- If again we try to set the download policy to the blank option from the same page in the attachment, can observe the below error, which seems correct error message:

~~~
An error occurred saving the Repository: Validation failed: Download policy must be one of the following: immediate, on_demand
~~~

Comment 4 Ian Ballou 2023-07-31 16:03:47 UTC
# echo "update katello_root_repositories set download_policy = 'background' where download_policy = 'on_demand'" |su - postgres -c 'psql foreman'

This command circumvents all validations that we have in Rails. If you tried in the API, which is the "lowest level" sort of interfacing that we support, background shouldn't be allowed.

Since we cannot offer validations for users doing direct database edits, I'm closing this as NOTABUG.