diff --git a/auth/test/test_registry_jwt.py b/auth/test/test_registry_jwt.py index 12000a95a..78ac029bc 100644 --- a/auth/test/test_registry_jwt.py +++ b/auth/test/test_registry_jwt.py @@ -110,30 +110,31 @@ def test_token_with_access(access, initialized_db): @pytest.mark.parametrize('token', [ - (_token( + pytest.param(_token( _token_data(access=[{ 'toipe': 'repository', 'namesies': 'somens/somerepo', - 'akshuns': ['pull', 'push', '*']}]))), - (_token(_token_data(audience='someotherapp'))), - (_token(_delete_field(_token_data(), 'aud'))), - (_token(_token_data(nbf=int(time.time()) + 600))), - (_token(_delete_field(_token_data(), 'nbf'))), - (_token(_token_data(iat=int(time.time()) + 600))), - (_token(_delete_field(_token_data(), 'iat'))), - (_token(_token_data(exp=int(time.time()) + MAX_SIGNED_S * 2))), - (_token(_token_data(exp=int(time.time()) - 60))), - (_token(_delete_field(_token_data(), 'exp'))), - (_token(_delete_field(_token_data(), 'sub'))), - (_token(_token_data(iss='badissuer'))), - (_token(_delete_field(_token_data(), 'iss'))), - (_token(_token_data(), skip_header=True)), - (_token(_token_data(), key_id='someunknownkey')), - (_token(_token_data(), key_id='kid7')), - (_token(_token_data(), alg='none', private_key=None)), - ('some random token'), - ('Bearer: sometokenhere'), - ('\nBearer: dGVzdA'),]) + 'akshuns': ['pull', 'push', '*']}])), id='bad access'), + pytest.param(_token(_token_data(audience='someotherapp')), id='bad aud'), + pytest.param(_token(_delete_field(_token_data(), 'aud')), id='no aud'), + pytest.param(_token(_token_data(nbf=int(time.time()) + 600)), id='future nbf'), + pytest.param(_token(_delete_field(_token_data(), 'nbf')), id='no nbf'), + pytest.param(_token(_token_data(iat=int(time.time()) + 600)), id='future iat'), + pytest.param(_token(_delete_field(_token_data(), 'iat')), id='no iat'), + pytest.param(_token(_token_data(exp=int(time.time()) + MAX_SIGNED_S * 2)), id='exp too long'), + pytest.param(_token(_token_data(exp=int(time.time()) - 60)), id='expired'), + pytest.param(_token(_delete_field(_token_data(), 'exp')), id='no exp'), + pytest.param(_token(_delete_field(_token_data(), 'sub')), id='no sub'), + pytest.param(_token(_token_data(iss='badissuer')), id='bad iss'), + pytest.param(_token(_delete_field(_token_data(), 'iss')), id='no iss'), + pytest.param(_token(_token_data(), skip_header=True), id='no header'), + pytest.param(_token(_token_data(), key_id='someunknownkey'), id='bad key'), + pytest.param(_token(_token_data(), key_id='kid7'), id='bad key :: kid7'), + pytest.param(_token(_token_data(), alg='none', private_key=None), id='none alg'), + pytest.param('some random token', id='random token'), + pytest.param('Bearer: sometokenhere', id='extra bearer'), + pytest.param('\nBearer: dGVzdA', id='leading newline'), +]) def test_invalid_jwt(token, initialized_db): with pytest.raises(InvalidJWTException): _parse_token(token)