Bug 1680458

Summary: Locked Report Templates are getting removed.
Product: Red Hat Satellite Reporter: hprakash
Component: ReportingAssignee: satellite6-bugs <satellite6-bugs>
Status: CLOSED ERRATA QA Contact: Lukáš Hellebrandt <lhellebr>
Severity: medium Docs Contact:
Priority: high    
Version: 6.5.0CC: egolov, inecas, mhulan, oprazak, wpinheir
Target Milestone: 6.8.0Keywords: Triaged, UserExperience
Target Release: Unused   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: foreman-2.1.0-0 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2020-10-27 12:58:15 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 hprakash 2019-02-25 05:50:02 UTC
Description of problem:
Locked template are getting deleted through API request

Version-Release number of selected component (if applicable):
satellite-6.5.0-6.beta.el7sat.noarch
Red Hat Enterprise Linux Server release 7.5 (Maipo)

How reproducible:
Always

Steps to Reproduce:
1. Sat webUI>Monitor>Report Templates>Either pick any of the default template or clone and existing template(later is preferred)>Lock it
2. From the console, fire the below DELETE request-
$ curl -u admin:<pwd> -k -X DELETE  https://<satellite-fqdn>/api/report_templates/<teplate-id>  -H 'content-type: application/json'

3. API response returns the below error-
{"errors":{"base":["This template is locked and may not be removed."]}}

Actual results:
API returns the error that suggests- the template is locked and may not be removed. However, it actually removes the template.

Expected results:
There is no option to remove the locked template from the webUI so, API should also not delete the locked template OR it should prompt to unlock the template before deleting. It will avoid the accidental deletion of locked template through the API.

Additional info:

Comment 3 hprakash 2019-03-01 11:47:27 UTC
When deleting LOCKED template from the hammer command, it says-

Could not delete the report template

but actually it deletes it.

[root@vm253-201 ~]# hammer report-template info --id 159
Id:              159
Name:            test-report-template
Default:         no
Created at:      2019/03/01 11:27:17
Updated at:      2019/03/01 11:37:48
Template inputs:
[root@vm253-201 ~]# hammer report-template delete --id 159
Could not delete the report template
[root@vm253-201 ~]# hammer report-template info --id 159
Resource report_template not found by id '159'

Comment 4 Ondřej Pražák 2019-03-04 07:52:24 UTC
Created redmine issue http://projects.theforeman.org/issues/26210 from this bug

Comment 5 Bryan Kearney 2020-03-04 14:08:27 UTC
The Satellite Team is attempting to provide an accurate backlog of bugzilla requests which we feel will be resolved in the next few releases. We do not believe this bugzilla will meet that criteria, and have plans to close it out in 1 month. This is not a reflection on the validity of the request, but a reflection of the many priorities for the product. If you have any concerns about this, feel free to contact Red Hat Technical Support or your account team. If we do not hear from you, we will close this bug out. Thank you.

Comment 6 Bryan Kearney 2020-04-07 16:02:36 UTC
Moving this bug to POST for triage into Satellite 6 since the upstream issue https://projects.theforeman.org/issues/26210 has been resolved.

Comment 7 Lukáš Hellebrandt 2020-06-10 14:56:11 UTC
Verified with Sat 6.8 snap 3.0.

Used reproducer from OP. Got:
```
{
  "error": {"id":<id>,"errors":{"base":["This template is locked and may not be removed."]},"full_messages":["This template is locked and may not be removed."]}
}
```

Using Hammer, I got:
```
Could not delete the report template:
  This template is locked and may not be removed.
```

Deleting unlocked template works.

Comment 10 errata-xmlrpc 2020-10-27 12:58:15 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.8 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-2020:4366