'Token expiration should be maintained after re-auth & validation.'

@mock.patch.object(timeutils, 'utcnow')
def _maintain_token_expiration(self, mock_utcnow):

    now = datetime.datetime.utcnow()
    mock_utcnow.return_value = now
    r = self.controller.authenticate(self.make_request(), auth={'passwordCredentials': {'username': self.user_foo['name'], 'password': self.user_foo['password']}})
    unscoped_token_id = r['access']['token']['id']
    original_expiration = r['access']['token']['expires']
    mock_utcnow.return_value = (now + datetime.timedelta(seconds=1))
    r = self.controller.validate_token(self.make_request(is_admin=True), token_id=unscoped_token_id)
    self.assertEqual(timeutils.parse_isotime(original_expiration), timeutils.parse_isotime(r['access']['token']['expires']))
    mock_utcnow.return_value = (now + datetime.timedelta(seconds=2))
    r = self.controller.authenticate(self.make_request(), auth={'token': {'id': unscoped_token_id}, 'tenantId': self.tenant_bar['id']})
    scoped_token_id = r['access']['token']['id']
    self.assertEqual(original_expiration, r['access']['token']['expires'])
    mock_utcnow.return_value = (now + datetime.timedelta(seconds=3))
    r = self.controller.validate_token(self.make_request(is_admin=True), token_id=scoped_token_id)
    self.assertEqual(timeutils.parse_isotime(original_expiration), timeutils.parse_isotime(r['access']['token']['expires']))
