Bug 720493

Summary: candlepin API call for pools fails to acknowledge TimeZone in the activeon parameter
Product: [Community] Candlepin Reporter: John Sefler <jsefler>
Component: candlepinAssignee: Bryan Kearney <bkearney>
Status: CLOSED CURRENTRELEASE QA Contact: John Sefler <jsefler>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 0.5CC: spandey
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Solaris   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2012-05-30 13:15:36 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 John Sefler 2011-07-11 19:55:15 UTC
Description of problem:
When trying to query the pools for an owner, I am allowed to set an activeon parameter so that I can get the pools on a particular date/time.  However, the API seems to fail to recognize the ISO 8601 format when a time zone is included.

Version-Release number of selected component (if applicable):
[root@jsefler-onprem-62candlepin proxy]# git branch
  0.3
* master
[root@jsefler-onprem-62candlepin proxy]# git show-ref | grep master
1be84d3971b32d03aea4d4ab363902e3ef4f377a refs/heads/master
1be84d3971b32d03aea4d4ab363902e3ef4f377a refs/remotes/origin/master


How reproducible:


Steps to Reproduce:
deploy a candlepin server with TESTDATA=1

# curl -k -u admin:admin --request GET https://jsefler-onprem-62candlepin.usersys.redhat.com:8443/candlepin/owners/admin/pools?activeon=2011-06-10T00%3A00%3A00.000%2B0000 | python -mjson.tool
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0    59    0    59    0     0    319      0 --:--:-- --:--:-- --:--:--  1966
{
    "displayMessage": "Invalid date, must use ISO 8601 format"
}

^^^^
I did not expect this invalid date error

Note... I am properly URL encoding the ISO 8601 date format...
URLEncode("2011-06-10T00:00:00.000+0000","UTF-8") gives me:
2011-06-10T00%3A00%3A00.000%2B0000 
                           ^^^^^^^
                           This is the encoded time zone corresponding to +0000

Now watch when I make the same curl call with the time zone stripped off...

# curl -k -u admin:admin --request GET https://jsefler-onprem-62candlepin.usersys.redhat.com:8443/candlepin/owners/admin/pools?activeon=2011-06-10T00%3A00%3A00.000 | python -mjson.tool | grep startDate
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  4524  100  4524    0     0  25326      0 --:--:-- --:--:-- --:--:-- 39339
        "startDate": "2011-06-10T04:00:00.000+0000", 
        "startDate": "2011-06-10T04:00:00.000+0000", 
        "startDate": "2011-06-10T04:00:00.000+0000", 
        "startDate": "2011-06-10T04:00:00.000+0000", 
^^^^ When the time zone is excluded from the activeon parameter, candlepin returns pools.


Actual results:
/candlepin/owners/$owner/pools?activeon=2011-06-10T00%3A00%3A00.000        PASS
/candlepin/owners/$owner/pools?activeon=2011-06-10T00%3A00%3A00.000%2B0000 FAILS
/candlepin/owners/$owner/pools?activeon=2011-06-10T00%3A00%3A00.000%2B0400 FAILS


So the problem is that I can't accurately query the pools for a precise and valid ISO 8601 date if I can't supply a time zone.


Additional info:

Comment 1 John Sefler 2011-07-11 21:00:42 UTC
/candlepin/owners/$owner/pools?activeon=2011-06-10T00%3A00%3A00.000-0400 FAILS

Comment 2 Bryan Kearney 2011-07-18 18:43:21 UTC
It is currently accepting xsd:date format. Lemme ask around.

http://books.xmlschemata.org/relaxng/ch19-77049.html

Comment 3 Bryan Kearney 2011-07-21 18:45:14 UTC
Looking a bit more, ISO 8601 requires a : in the timezone:

curl -k -u admin:admin  https://localhost:8443/candlepin/owners/admin/pools?activeon=2011-06-10T00%3A00%3A00.000%2B00:00

Comment 4 John Sefler 2011-07-25 20:49:45 UTC
Thank you Bryan for figuring this out.

Yes - as indicated in http://books.xmlschemata.org/relaxng/ch19-77049.html a colon appears to be required in the date format.

The following url encoded calls are working against candlepin with and without a url encoding for the colon in the timezone...

with the timezone colon urlencoded(":")=%3A ...
[root@jsefler-onprem-62server tmp]# curl -k -u admin:admin https://jsefler-onprem-62candlepin.usersys.redhat.com:8443/candlepin/owners/admin/pools?activeon=2012-12-31T00%3A00%3A00.000%2B00%3A00 | python -mjson.tool | grep startDate
        "startDate": "2012-07-13T00:00:00.000+0000", 
        "startDate": "2012-07-13T00:00:00.000+0000", 
        "startDate": "2012-07-13T00:00:00.000+0000", 

without the timezone colon urlencoded ...
[root@jsefler-onprem-62server tmp]# curl -k -u admin:admin https://jsefler-onprem-62candlepin.usersys.redhat.com:8443/candlepin/owners/admin/pools?activeon=2012-12-31T00%3A00%3A00.000%2B00:00 | python -mjson.tool | grep startDate
        "startDate": "2012-07-13T00:00:00.000+0000", 
        "startDate": "2012-07-13T00:00:00.000+0000", 
        "startDate": "2012-07-13T00:00:00.000+0000", 

Additional Note:
Existing automated ExpirationTests have been updated to include a urlencoding of the colon in the activeon parameter when querying for pools on a specific date.