fix validation empty pass and fix cache logic
Skeleton contracts / contracts (pull_request) Canceled after 0s
Skeleton contracts / contracts (pull_request) Canceled after 0s
This commit is contained in:
+20
-2
@@ -86,6 +86,13 @@ def main():
|
||||
|
||||
actor = client.user('operational')
|
||||
password = actor['registration']['password']
|
||||
client.call(
|
||||
'POST', '/api/v1/users', 400,
|
||||
body={
|
||||
'username': 'blank_password_' + uuid.uuid4().hex[:12],
|
||||
'display_name': 'Blank password probe',
|
||||
'password': ' ',
|
||||
})
|
||||
client.call(
|
||||
'POST', '/api/v1/auth/sessions', 401,
|
||||
headers=basic(actor['registration']['username'], password + '-wrong'))
|
||||
@@ -94,6 +101,17 @@ def main():
|
||||
cache_key = 'messenger:user:' + actor['id']
|
||||
ttl = compose('exec', '-T', 'redis', 'redis-cli', 'TTL', cache_key, capture=True)
|
||||
check(ttl.isdigit() and 0 < int(ttl) <= 300, 'Redis cache key has no bounded TTL')
|
||||
compose('exec', '-T', 'redis', 'redis-cli', 'SET', cache_key, 'null')
|
||||
client.call('GET', '/api/v1/users/me', actor=actor, schema='User')
|
||||
cached_user = compose(
|
||||
'exec', '-T', 'redis', 'redis-cli', '--raw', 'GET', cache_key, capture=True)
|
||||
try:
|
||||
cached_payload = json.loads(cached_user)
|
||||
except json.JSONDecodeError as error:
|
||||
raise Failure('JSON null cache entry was not replaced with valid JSON') from error
|
||||
check(
|
||||
isinstance(cached_payload, dict) and cached_payload.get('id') == actor['id'],
|
||||
'JSON null cache entry was not replaced from PostgreSQL')
|
||||
appendonly = compose(
|
||||
'exec', '-T', 'redis', 'redis-cli', '--raw', 'CONFIG', 'GET', 'appendonly',
|
||||
capture=True)
|
||||
@@ -160,8 +178,8 @@ def main():
|
||||
capture=True)
|
||||
check(count == '0', 'failed composite chat operation was not rolled back')
|
||||
|
||||
print('PASS: expiry, logout, wrong password, Redis fallback, DB failure, '
|
||||
'username race, and chat rollback verified.')
|
||||
print('PASS: blank password, JSON null cache recovery, expiry, logout, wrong password, '
|
||||
'Redis fallback, DB failure, username race, and chat rollback verified.')
|
||||
finally:
|
||||
compose('up', '-d', '--wait', 'postgres', 'redis')
|
||||
if trigger_installed:
|
||||
|
||||
Reference in New Issue
Block a user