revocation_list only call isotime on datetime objects

If expires is a str then isinstance six.text_type is false then the following
exception is raised:
AttributeError: 'str' object has no attribute 'strftime'

This change explicitly checks for a datetime object, which is what
timeutils.isotime expects.

Change-Id: I8012f96498fffe5f54e7f1ca08b7beb6fa168f9c
Closes-Bug: #1285871
This commit is contained in:
Steve Baker 2014-02-28 10:29:12 +13:00
parent e2ce639517
commit a6840be9ac
1 changed files with 2 additions and 1 deletions

View File

@ -12,6 +12,7 @@
# License for the specific language governing permissions and limitations
# under the License.
import datetime
import json
from keystoneclient.common import cms
@ -419,7 +420,7 @@ class Auth(controller.V2Controller):
for t in tokens:
expires = t['expires']
if not (expires and isinstance(expires, six.text_type)):
if expires and isinstance(expires, datetime.datetime):
t['expires'] = timeutils.isotime(expires)
data = {'revoked': tokens}
json_data = json.dumps(data)