Created
November 7, 2017 16:23
-
-
Save askz/33f2d0d8bb6f1d953c7c1ef6f16b4fef to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
______________________________________________________ test_getting_list_of_oauth2_clients_by_authorized_user[auth_scopes0] ______________________________________________________ | |
flask_app_client = <AutoAuthFlaskClient <Flask 'app'>> | |
regular_user = <User(id=1, username="regular_user", email="[email protected]", is_internal=False, is_admin=False, is_regular_user=True, is_active=True, )> | |
regular_user_oauth2_client = <app.modules.auth.models.OAuth2Client object at 0x7ff93a0b7710>, auth_scopes = ['auth:read'] | |
@pytest.mark.parametrize('auth_scopes', ( | |
['auth:read'], | |
['auth:read', 'auth:write'], | |
)) | |
def test_getting_list_of_oauth2_clients_by_authorized_user( | |
flask_app_client, regular_user, regular_user_oauth2_client, auth_scopes | |
): | |
# pylint: disable=invalid-name | |
with flask_app_client.login(regular_user, auth_scopes=auth_scopes): | |
response = flask_app_client.get( | |
'/api/v1/auth/oauth2_clients/', | |
query_string={'user_id': regular_user.id} | |
) | |
assert response.status_code == 200 | |
assert response.content_type == 'application/json' | |
assert isinstance(response.json, list) | |
assert set(response.json[0].keys()) >= {'client_id'} | |
> assert response.json[0]['client_id'] == regular_user_oauth2_client.client_id | |
E AssertionError: assert 'OAUTH2_regular_user' == 'regular_user_client' | |
E - OAUTH2_regular_user | |
E + regular_user_client | |
tests/modules/auth/resources/test_getting_oauth2clients_info.py:24: AssertionError | |
______________________________________________________ test_getting_list_of_oauth2_clients_by_authorized_user[auth_scopes1] ______________________________________________________ | |
flask_app_client = <AutoAuthFlaskClient <Flask 'app'>> | |
regular_user = <User(id=1, username="regular_user", email="[email protected]", is_internal=False, is_admin=False, is_regular_user=True, is_active=True, )> | |
regular_user_oauth2_client = <app.modules.auth.models.OAuth2Client object at 0x7ff93a0d7978>, auth_scopes = ['auth:read', 'auth:write'] | |
@pytest.mark.parametrize('auth_scopes', ( | |
['auth:read'], | |
['auth:read', 'auth:write'], | |
)) | |
def test_getting_list_of_oauth2_clients_by_authorized_user( | |
flask_app_client, regular_user, regular_user_oauth2_client, auth_scopes | |
): | |
# pylint: disable=invalid-name | |
with flask_app_client.login(regular_user, auth_scopes=auth_scopes): | |
response = flask_app_client.get( | |
'/api/v1/auth/oauth2_clients/', | |
query_string={'user_id': regular_user.id} | |
) | |
assert response.status_code == 200 | |
assert response.content_type == 'application/json' | |
assert isinstance(response.json, list) | |
assert set(response.json[0].keys()) >= {'client_id'} | |
> assert response.json[0]['client_id'] == regular_user_oauth2_client.client_id | |
E AssertionError: assert 'OAUTH2_regular_user' == 'regular_user_client' | |
E - OAUTH2_regular_user | |
E + regular_user_client | |
tests/modules/auth/resources/test_getting_oauth2clients_info.py:24: AssertionError | |
____________________________________________________ test_teams_options_authorized[/api/v1/teams/1-expected_allowed_methods1] ____________________________________________________ | |
path = '/api/v1/teams/1', expected_allowed_methods = {'DELETE', 'GET', 'OPTIONS', 'PATCH'}, flask_app_client = <AutoAuthFlaskClient <Flask 'app'>> | |
regular_user = <User(id=1, username="regular_user", email="[email protected]", is_internal=False, is_admin=False, is_regular_user=True, is_active=True, )> | |
team_for_regular_user = <Team(id=25, title="Regular User's team")>, team_for_nobody = <Team(id=26, title="Admin User's team")> | |
@pytest.mark.parametrize('path,expected_allowed_methods', ( | |
('/api/v1/teams/', {'GET', 'POST', 'OPTIONS'}), | |
('/api/v1/teams/1', {'GET', 'OPTIONS', 'PATCH', 'DELETE'}), | |
('/api/v1/teams/2', {'OPTIONS'}), | |
)) | |
def test_teams_options_authorized( | |
path, | |
expected_allowed_methods, | |
flask_app_client, | |
regular_user, | |
team_for_regular_user, | |
team_for_nobody | |
): | |
with flask_app_client.login(regular_user, auth_scopes=('teams:write', 'teams:read')): | |
response = flask_app_client.options(path) | |
> assert response.status_code == 204 | |
E assert 404 == 204 | |
E + where 404 = <JSONResponse streamed [404 NOT FOUND]>.status_code | |
tests/modules/teams/resources/test_options.py:30: AssertionError | |
____________________________________________________ test_teams_options_authorized[/api/v1/teams/2-expected_allowed_methods2] ____________________________________________________ | |
path = '/api/v1/teams/2', expected_allowed_methods = {'OPTIONS'}, flask_app_client = <AutoAuthFlaskClient <Flask 'app'>> | |
regular_user = <User(id=1, username="regular_user", email="[email protected]", is_internal=False, is_admin=False, is_regular_user=True, is_active=True, )> | |
team_for_regular_user = <Team(id=27, title="Regular User's team")>, team_for_nobody = <Team(id=28, title="Admin User's team")> | |
@pytest.mark.parametrize('path,expected_allowed_methods', ( | |
('/api/v1/teams/', {'GET', 'POST', 'OPTIONS'}), | |
('/api/v1/teams/1', {'GET', 'OPTIONS', 'PATCH', 'DELETE'}), | |
('/api/v1/teams/2', {'OPTIONS'}), | |
)) | |
def test_teams_options_authorized( | |
path, | |
expected_allowed_methods, | |
flask_app_client, | |
regular_user, | |
team_for_regular_user, | |
team_for_nobody | |
): | |
with flask_app_client.login(regular_user, auth_scopes=('teams:write', 'teams:read')): | |
response = flask_app_client.options(path) | |
> assert response.status_code == 204 | |
E assert 404 == 204 | |
E + where 404 = <JSONResponse streamed [404 NOT FOUND]>.status_code | |
tests/modules/teams/resources/test_options.py:30: AssertionError | |
===================================================================== 4 failed, 177 passed in 12.61 seconds ====================================================================== |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment