Bug 720493 - candlepin API call for pools fails to acknowledge TimeZone in the activeon parameter
candlepin API call for pools fails to acknowledge TimeZone in the activeon pa...
Product: Candlepin
Classification: Community
Component: candlepin (Show other bugs)
Unspecified Solaris
unspecified Severity unspecified
: ---
: ---
Assigned To: Bryan Kearney
John Sefler
Depends On:
Blocks: rhsm-rhel62
  Show dependency treegraph
Reported: 2011-07-11 15:55 EDT by John Sefler
Modified: 2015-05-14 11:22 EDT (History)
1 user (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2012-05-30 09:15:36 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)

  None (edit)
Description John Sefler 2011-07-11 15:55:15 EDT
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
* 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:
                           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 17:00:42 EDT
/candlepin/owners/$owner/pools?activeon=2011-06-10T00%3A00%3A00.000-0400 FAILS
Comment 2 Bryan Kearney 2011-07-18 14:43:21 EDT
It is currently accepting xsd:date format. Lemme ask around.

Comment 3 Bryan Kearney 2011-07-21 14:45:14 EDT
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 16:49:45 EDT
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.

Note You need to log in before you can comment on or make changes to this bug.