Guest User

Untitled

a guest
Nov 9th, 2017
419
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.07 KB | None | 0 0
  1. ______________________________________________________ test_getting_list_of_oauth2_clients_by_authorized_user[auth_scopes0] ______________________________________________________
  2.  
  3. flask_app_client = <AutoAuthFlaskClient <Flask 'app'>>
  4. regular_user = <User(id=1, username="regular_user", email="regular_user@email.com", is_internal=False, is_admin=False, is_regular_user=True, is_active=True, )>
  5. regular_user_oauth2_client = <app.modules.auth.models.OAuth2Client object at 0x7ff93a0b7710>, auth_scopes = ['auth:read']
  6.  
  7. @pytest.mark.parametrize('auth_scopes', (
  8. ['auth:read'],
  9. ['auth:read', 'auth:write'],
  10. ))
  11. def test_getting_list_of_oauth2_clients_by_authorized_user(
  12. flask_app_client, regular_user, regular_user_oauth2_client, auth_scopes
  13. ):
  14. # pylint: disable=invalid-name
  15. with flask_app_client.login(regular_user, auth_scopes=auth_scopes):
  16. response = flask_app_client.get(
  17. '/api/v1/auth/oauth2_clients/',
  18. query_string={'user_id': regular_user.id}
  19. )
  20.  
  21. assert response.status_code == 200
  22. assert response.content_type == 'application/json'
  23. assert isinstance(response.json, list)
  24. assert set(response.json[0].keys()) >= {'client_id'}
  25. > assert response.json[0]['client_id'] == regular_user_oauth2_client.client_id
  26. E AssertionError: assert 'OAUTH2_regular_user' == 'regular_user_client'
  27. E - OAUTH2_regular_user
  28. E + regular_user_client
  29.  
  30. tests/modules/auth/resources/test_getting_oauth2clients_info.py:24: AssertionError
  31. ______________________________________________________ test_getting_list_of_oauth2_clients_by_authorized_user[auth_scopes1] ______________________________________________________
  32.  
  33. flask_app_client = <AutoAuthFlaskClient <Flask 'app'>>
  34. regular_user = <User(id=1, username="regular_user", email="regular_user@email.com", is_internal=False, is_admin=False, is_regular_user=True, is_active=True, )>
  35. regular_user_oauth2_client = <app.modules.auth.models.OAuth2Client object at 0x7ff93a0d7978>, auth_scopes = ['auth:read', 'auth:write']
  36.  
  37. @pytest.mark.parametrize('auth_scopes', (
  38. ['auth:read'],
  39. ['auth:read', 'auth:write'],
  40. ))
  41. def test_getting_list_of_oauth2_clients_by_authorized_user(
  42. flask_app_client, regular_user, regular_user_oauth2_client, auth_scopes
  43. ):
  44. # pylint: disable=invalid-name
  45. with flask_app_client.login(regular_user, auth_scopes=auth_scopes):
  46. response = flask_app_client.get(
  47. '/api/v1/auth/oauth2_clients/',
  48. query_string={'user_id': regular_user.id}
  49. )
  50.  
  51. assert response.status_code == 200
  52. assert response.content_type == 'application/json'
  53. assert isinstance(response.json, list)
  54. assert set(response.json[0].keys()) >= {'client_id'}
  55. > assert response.json[0]['client_id'] == regular_user_oauth2_client.client_id
  56. E AssertionError: assert 'OAUTH2_regular_user' == 'regular_user_client'
  57. E - OAUTH2_regular_user
  58. E + regular_user_client
  59.  
  60. tests/modules/auth/resources/test_getting_oauth2clients_info.py:24: AssertionError
  61. ____________________________________________________ test_teams_options_authorized[/api/v1/teams/1-expected_allowed_methods1] ____________________________________________________
  62.  
  63. path = '/api/v1/teams/1', expected_allowed_methods = {'DELETE', 'GET', 'OPTIONS', 'PATCH'}, flask_app_client = <AutoAuthFlaskClient <Flask 'app'>>
  64. regular_user = <User(id=1, username="regular_user", email="regular_user@email.com", is_internal=False, is_admin=False, is_regular_user=True, is_active=True, )>
  65. team_for_regular_user = <Team(id=25, title="Regular User's team")>, team_for_nobody = <Team(id=26, title="Admin User's team")>
  66.  
  67. @pytest.mark.parametrize('path,expected_allowed_methods', (
  68. ('/api/v1/teams/', {'GET', 'POST', 'OPTIONS'}),
  69. ('/api/v1/teams/1', {'GET', 'OPTIONS', 'PATCH', 'DELETE'}),
  70. ('/api/v1/teams/2', {'OPTIONS'}),
  71. ))
  72. def test_teams_options_authorized(
  73. path,
  74. expected_allowed_methods,
  75. flask_app_client,
  76. regular_user,
  77. team_for_regular_user,
  78. team_for_nobody
  79. ):
  80. with flask_app_client.login(regular_user, auth_scopes=('teams:write', 'teams:read')):
  81. response = flask_app_client.options(path)
  82.  
  83. > assert response.status_code == 204
  84. E assert 404 == 204
  85. E + where 404 = <JSONResponse streamed [404 NOT FOUND]>.status_code
  86.  
  87. tests/modules/teams/resources/test_options.py:30: AssertionError
  88. ____________________________________________________ test_teams_options_authorized[/api/v1/teams/2-expected_allowed_methods2] ____________________________________________________
  89.  
  90. path = '/api/v1/teams/2', expected_allowed_methods = {'OPTIONS'}, flask_app_client = <AutoAuthFlaskClient <Flask 'app'>>
  91. regular_user = <User(id=1, username="regular_user", email="regular_user@email.com", is_internal=False, is_admin=False, is_regular_user=True, is_active=True, )>
  92. team_for_regular_user = <Team(id=27, title="Regular User's team")>, team_for_nobody = <Team(id=28, title="Admin User's team")>
  93.  
  94. @pytest.mark.parametrize('path,expected_allowed_methods', (
  95. ('/api/v1/teams/', {'GET', 'POST', 'OPTIONS'}),
  96. ('/api/v1/teams/1', {'GET', 'OPTIONS', 'PATCH', 'DELETE'}),
  97. ('/api/v1/teams/2', {'OPTIONS'}),
  98. ))
  99. def test_teams_options_authorized(
  100. path,
  101. expected_allowed_methods,
  102. flask_app_client,
  103. regular_user,
  104. team_for_regular_user,
  105. team_for_nobody
  106. ):
  107. with flask_app_client.login(regular_user, auth_scopes=('teams:write', 'teams:read')):
  108. response = flask_app_client.options(path)
  109.  
  110. > assert response.status_code == 204
  111. E assert 404 == 204
  112. E + where 404 = <JSONResponse streamed [404 NOT FOUND]>.status_code
  113.  
  114. tests/modules/teams/resources/test_options.py:30: AssertionError
  115. ===================================================================== 4 failed, 177 passed in 12.61 seconds ======================================================================
Add Comment
Please, Sign In to add comment