Merge "Use freezegun to increment the clock in test_v3_filters"

This commit is contained in:
Jenkins 2016-07-19 18:25:47 +00:00 committed by Gerrit Code Review
commit 18a1f1a554
2 changed files with 22 additions and 8 deletions

View File

@ -13,6 +13,9 @@
# License for the specific language governing permissions and limitations
# under the License.
import datetime
import freezegun
from oslo_serialization import jsonutils
from six.moves import range
@ -208,11 +211,21 @@ class IdentityTestFilteredCase(filtering.FilterTests,
- Ensure we can filter on it
"""
# NOTE(lbragstad): Since Fernet tokens do not support sub-second
# precision we must freeze the clock and ensure we increment the time
# by a full second after a recovation event has occured. Otherwise the
# token will be considered revoked even though it is actually a valid
# token.
time = datetime.datetime.utcnow()
with freezegun.freeze_time(time) as frozen_datetime:
self._set_policy({"identity:list_users": []})
user = self.user1
user['name'] = '%my%name%'
self.identity_api.update_user(user['id'], user)
frozen_datetime.tick(delta=datetime.timedelta(seconds=1))
url_by_name = '/users?name=%my%name%'
r = self.get(url_by_name, auth=self.auth)

View File

@ -7,6 +7,7 @@ pep257==0.7.0 # MIT License
flake8-docstrings==0.2.1.post1 # MIT
bashate>=0.2 # Apache-2.0
os-testr>=0.7.0 # Apache-2.0
freezegun # Apache-2.0
# Include drivers for opportunistic testing.
oslo.db[fixtures,mysql,postgresql]>=4.1.0 # Apache-2.0