time not properly parsed in auth_token middleware throws exception

Bug #918535 reported by Nicholas Mistry
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Identity (keystone)
Fix Released
High
Ziad Sawalha

Bug Description

on debian squeeze the time format returned is %Y-%m-%dT%H:%M:%S.%f-%z and the extra time zone offset information causes get_datetime to throw an exception, in the file keystone/middleware/auth_token.py. specifically the line ms = int(microseconds.ljust(6, '0')[:6])

def get_datetime(time_string):
    """ Gets datetime object with microsecond accuracy from input string.
    Handle strings which don't include microseconds

    :param: time_string: datetime in %Y-%m-%dT%H:%M:%S.%f format (.%f optional)
    """
    result = time_string.split(".", 1)
    datetime_string = result[0]
    microseconds = result[1] if len(result) > 1 else "0"
    d1 = datetime.strptime(datetime_string, "%Y-%m-%dT%H:%M:%S")
    ms = int(microseconds.ljust(6, '0')[:6])
    return d1.replace(microsecond=ms)

Changed in keystone:
assignee: nobody → Ziad Sawalha (ziad-sawalha)
milestone: none → essex-3
importance: Undecided → High
status: New → Confirmed
status: Confirmed → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to keystone (master)

Reviewed: https://review.openstack.org/3185
Committed: http://github.com/openstack/keystone/commit/8c98285ad0c1b24efe35a3ea777da58fb0d67054
Submitter: Jenkins
Branch: master

commit 8c98285ad0c1b24efe35a3ea777da58fb0d67054
Author: Ziad Sawalha <email address hidden>
Date: Thu Jan 19 11:19:13 2012 -0600

    Fixes 918535: time not properly parsed in auth_token middleware

    - replaced get_datetime() with expanded _convert_datetime()
      function that uses datutil parser to handle any date
      string.
    - added tests
    - fixes bug 918535
    - also addresses bug 911197

    Change-Id: I7f4e3c01b1b7466fd5f30889c7b28deae9fc9367

Changed in keystone:
status: In Progress → Fix Committed
Thierry Carrez (ttx)
Changed in keystone:
status: Fix Committed → Fix Released
Thierry Carrez (ttx)
Changed in keystone:
milestone: essex-3 → 2012.1
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.