Bug 720487

Summary: Refresh Pools w/ Auto-Create Owner Fails
Product: [Community] Candlepin Reporter: Devan Goodwin <dgoodwin>
Component: candlepinAssignee: Bryan Kearney <bkearney>
Status: CLOSED CURRENTRELEASE QA Contact: John Sefler <jsefler>
Severity: high Docs Contact:
Priority: unspecified    
Version: 0.5   
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2012-05-30 13:15:20 UTC Type: ---
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:    
Bug Blocks: 682238    

Description Devan Goodwin 2011-07-11 19:30:23 UTC
Description of problem:

Cannot call refresh pools with auto-create=true for an owner that does not yet exist.

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

0.4

Steps to Reproduce:

Needs to be investigated, and covered in unit tests, as nothing caught this when the changes were made. Basically you need to hit the refreshPools with auto-create set to true.
  
Actual results:

Permission denied.

Expected results:

Allow super admin to make the  request, and auto-create the owner as before.

Additional info:

Basically the call in OwnerResource.refreshPools has an @Verify annotation, which will try to lookup the owner and then when it isn't found, rejects the request.

Removing the @Verify may be sufficient, the call will be super-admin only (this is correct isn't it for refresh pools?)

Most importantly we need this covered in the spec tests.

Comment 1 Bryan Kearney 2011-08-02 21:04:21 UTC
fixed in master at a60db720886625c98301dc6f97f5097c2381dddb.

Comment 2 Devan Goodwin 2011-10-04 12:05:37 UTC
To reproduce: curl -k -u admin:admin --request PUT "https://localhost:8443/candlepin/owners/new_owner/subscriptions?auto_create_owner=true"

Should return JSON indicating that a refresh job for new_owner has been created:

{
  "id" : "refresh_pools_69f8d1f5-1f9d-44f9-9d2e-57593ff71e02",
  "state" : "CREATED",
  "result" : null,
  "targetType" : "owner",
  "startTime" : null,
  "group" : "async group",
  "principalName" : "admin",
  "targetId" : "new_owner",
  "finishTime" : null,
  "statusPath" : "/jobs/refresh_pools_69f8d1f5-1f9d-44f9-9d2e-57593ff71e02",
  "updated" : "2011-10-04T12:04:51.202+0000",
  "created" : "2011-10-04T12:04:51.202+0000"
}%

Comment 3 John Sefler 2011-10-04 18:19:08 UTC
Verifying Version...

[root@jsefler-onprem-62candlepin candlepin]# git branch
  0.3
* master
[root@jsefler-onprem-62candlepin candlepin]# git show-ref | grep master
5340dfd5b25440d227ee22940da712516a4989bb refs/heads/master
5340dfd5b25440d227ee22940da712516a4989bb refs/remotes/origin/master


HERE'S THE TEST..

1. ASSERT THAT "NEWOWNER" DOES NOT ALREADY EXIST...
[root@jsefler-onprem-62server ~]# curl -k -u admin:admin --request GET  https://jsefler-onprem-62candlepin.usersys.redhat.com:8443/candlepin/owners/NEWOWNER | python -mjson.tool  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0    62    0    62    0     0    302      0 --:--:-- --:--:-- --:--:--  1878
{
    "displayMessage": "Owner with id NEWOWNER could not be found"
}

2. REFRESH POOLS WITH auto_create_owner=true FOR A NEWOWNER...
[root@jsefler-onprem-62server ~]# curl -k -u admin:admin --request PUT  https://jsefler-onprem-62candlepin.usersys.redhat.com:8443/candlepin/owners/NEWOWNER/subscriptions?auto_create_owner=true | python -mjson.tool
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
123   369  123   369    0     0   1975      0 --:--:-- --:--:-- --:--:--  3653
{
    "created": "2011-10-04T18:11:25.887+0000", 
    "finishTime": null, 
    "group": "async group", 
    "id": "refresh_pools_ef4dbd2f-6e6a-4171-951b-b14e5061ee87", 
    "principalName": "admin", 
    "result": null, 
    "startTime": null, 
    "state": "CREATED", 
    "statusPath": "/jobs/refresh_pools_ef4dbd2f-6e6a-4171-951b-b14e5061ee87", 
    "targetId": "NEWOWNER", 
    "targetType": "owner", 
    "updated": "2011-10-04T18:11:25.887+0000"
}

3. ASSERT THAT "NEWOWNER" NOW EXISTS...
[root@jsefler-onprem-62server ~]# curl -k -u admin:admin --request GET  https://jsefler-onprem-62candlepin.usersys.redhat.com:8443/candlepin/owners/NEWOWNER | python -mjson.tool  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
125   251  125   251    0     0   1906      0 --:--:-- --:--:-- --:--:--  5976
{
    "contentPrefix": null, 
    "created": "2011-10-04T18:11:25.861+0000", 
    "displayName": "NEWOWNER", 
    "href": "/owners/NEWOWNER", 
    "id": "8a90f8c632d015890132d02210250756", 
    "key": "NEWOWNER", 
    "parentOwner": null, 
    "updated": "2011-10-04T18:11:25.861+0000", 
    "upstreamUuid": null
}

4. ATTEMPT REFRESH POOLS WITH auto_create_owner=false FOR ANOTHERNEWOWNER...
[root@jsefler-onprem-62server ~]# curl -k -u admin:admin --request PUT  https://jsefler-onprem-62candlepin.usersys.redhat.com:8443/candlepin/owners/ANOTHERNEWOWNER/subscriptions?auto_create_owner=false | python -mjson.tool
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0    67    0    67    0     0    292      0 --:--:-- --:--:-- --:--:--  2310
{
    "displayMessage": "owner with key: ANOTHERNEWOWNER was not found."
}


moving to VERIFIED