浏览代码

authentificationfailed is forbidden

Guénaël Muller 6 年前
父节点
当前提交
83c8bf3102

+ 4 - 4
tracim/tests/functional/test_session.py 查看文件

59
         assert res.json_body['caldav_url'] is None
59
         assert res.json_body['caldav_url'] is None
60
         assert res.json_body['avatar_url'] is None
60
         assert res.json_body['avatar_url'] is None
61
 
61
 
62
-    def test_api__try_login_enpoint__err_400__bad_password(self):
62
+    def test_api__try_login_enpoint__err_403__bad_password(self):
63
         params = {
63
         params = {
64
             'email': 'admin@admin.admin',
64
             'email': 'admin@admin.admin',
65
             'password': 'bad_password',
65
             'password': 'bad_password',
66
         }
66
         }
67
         res = self.testapp.post_json(
67
         res = self.testapp.post_json(
68
             '/api/v2/sessions/login',
68
             '/api/v2/sessions/login',
69
-            status=400,
69
+            status=403,
70
             params=params,
70
             params=params,
71
         )
71
         )
72
         assert isinstance(res.json, dict)
72
         assert isinstance(res.json, dict)
74
         assert 'message' in res.json.keys()
74
         assert 'message' in res.json.keys()
75
         assert 'details' in res.json.keys()
75
         assert 'details' in res.json.keys()
76
 
76
 
77
-    def test_api__try_login_enpoint__err_400__unregistered_user(self):
77
+    def test_api__try_login_enpoint__err_403__unregistered_user(self):
78
         params = {
78
         params = {
79
             'email': 'unknown_user@unknown.unknown',
79
             'email': 'unknown_user@unknown.unknown',
80
             'password': 'bad_password',
80
             'password': 'bad_password',
81
         }
81
         }
82
         res = self.testapp.post_json(
82
         res = self.testapp.post_json(
83
             '/api/v2/sessions/login',
83
             '/api/v2/sessions/login',
84
-            status=400,
84
+            status=403,
85
             params=params,
85
             params=params,
86
         )
86
         )
87
         assert isinstance(res.json, dict)
87
         assert isinstance(res.json, dict)

+ 3 - 3
tracim/views/contents_api/comment_controller.py 查看文件

36
     @hapic.handle_exception(NotAuthenticated, HTTPStatus.UNAUTHORIZED)
36
     @hapic.handle_exception(NotAuthenticated, HTTPStatus.UNAUTHORIZED)
37
     @hapic.handle_exception(InsufficientUserWorkspaceRole, HTTPStatus.FORBIDDEN)
37
     @hapic.handle_exception(InsufficientUserWorkspaceRole, HTTPStatus.FORBIDDEN)
38
     @hapic.handle_exception(WorkspaceNotFound, HTTPStatus.FORBIDDEN)
38
     @hapic.handle_exception(WorkspaceNotFound, HTTPStatus.FORBIDDEN)
39
-    @hapic.handle_exception(AuthenticationFailed, HTTPStatus.BAD_REQUEST)
39
+    @hapic.handle_exception(AuthenticationFailed, HTTPStatus.FORBIDDEN)
40
     @require_workspace_role(UserRoleInWorkspace.READER)
40
     @require_workspace_role(UserRoleInWorkspace.READER)
41
     @hapic.input_path(WorkspaceAndContentIdPathSchema())
41
     @hapic.input_path(WorkspaceAndContentIdPathSchema())
42
     @hapic.output_body(CommentSchema(many=True),)
42
     @hapic.output_body(CommentSchema(many=True),)
66
     @hapic.handle_exception(NotAuthenticated, HTTPStatus.UNAUTHORIZED)
66
     @hapic.handle_exception(NotAuthenticated, HTTPStatus.UNAUTHORIZED)
67
     @hapic.handle_exception(InsufficientUserWorkspaceRole, HTTPStatus.FORBIDDEN)
67
     @hapic.handle_exception(InsufficientUserWorkspaceRole, HTTPStatus.FORBIDDEN)
68
     @hapic.handle_exception(WorkspaceNotFound, HTTPStatus.FORBIDDEN)
68
     @hapic.handle_exception(WorkspaceNotFound, HTTPStatus.FORBIDDEN)
69
-    @hapic.handle_exception(AuthenticationFailed, HTTPStatus.BAD_REQUEST)
69
+    @hapic.handle_exception(AuthenticationFailed, HTTPStatus.FORBIDDEN)
70
     @require_workspace_role(UserRoleInWorkspace.CONTRIBUTOR)
70
     @require_workspace_role(UserRoleInWorkspace.CONTRIBUTOR)
71
     @hapic.input_path(WorkspaceAndContentIdPathSchema())
71
     @hapic.input_path(WorkspaceAndContentIdPathSchema())
72
     @hapic.input_body(SetCommentSchema())
72
     @hapic.input_body(SetCommentSchema())
98
     @hapic.handle_exception(NotAuthenticated, HTTPStatus.UNAUTHORIZED)
98
     @hapic.handle_exception(NotAuthenticated, HTTPStatus.UNAUTHORIZED)
99
     @hapic.handle_exception(InsufficientUserWorkspaceRole, HTTPStatus.FORBIDDEN)
99
     @hapic.handle_exception(InsufficientUserWorkspaceRole, HTTPStatus.FORBIDDEN)
100
     @hapic.handle_exception(WorkspaceNotFound, HTTPStatus.FORBIDDEN)
100
     @hapic.handle_exception(WorkspaceNotFound, HTTPStatus.FORBIDDEN)
101
-    @hapic.handle_exception(AuthenticationFailed, HTTPStatus.BAD_REQUEST)
101
+    @hapic.handle_exception(AuthenticationFailed, HTTPStatus.FORBIDDEN)
102
     @require_comment_ownership_or_role(
102
     @require_comment_ownership_or_role(
103
         minimal_required_role_for_anyone=UserRoleInWorkspace.WORKSPACE_MANAGER,
103
         minimal_required_role_for_anyone=UserRoleInWorkspace.WORKSPACE_MANAGER,
104
         minimal_required_role_for_owner=UserRoleInWorkspace.CONTRIBUTOR,
104
         minimal_required_role_for_owner=UserRoleInWorkspace.CONTRIBUTOR,

+ 4 - 4
tracim/views/contents_api/html_document_controller.py 查看文件

38
     @hapic.handle_exception(NotAuthenticated, HTTPStatus.UNAUTHORIZED)
38
     @hapic.handle_exception(NotAuthenticated, HTTPStatus.UNAUTHORIZED)
39
     @hapic.handle_exception(InsufficientUserWorkspaceRole, HTTPStatus.FORBIDDEN)
39
     @hapic.handle_exception(InsufficientUserWorkspaceRole, HTTPStatus.FORBIDDEN)
40
     @hapic.handle_exception(WorkspaceNotFound, HTTPStatus.FORBIDDEN)
40
     @hapic.handle_exception(WorkspaceNotFound, HTTPStatus.FORBIDDEN)
41
-    @hapic.handle_exception(AuthenticationFailed, HTTPStatus.BAD_REQUEST)
41
+    @hapic.handle_exception(AuthenticationFailed, HTTPStatus.FORBIDDEN)
42
     @hapic.handle_exception(ContentTypeNotAllowed, HTTPStatus.BAD_REQUEST)
42
     @hapic.handle_exception(ContentTypeNotAllowed, HTTPStatus.BAD_REQUEST)
43
     @require_workspace_role(UserRoleInWorkspace.READER)
43
     @require_workspace_role(UserRoleInWorkspace.READER)
44
     @require_content_types([html_documents_type])
44
     @require_content_types([html_documents_type])
64
     @hapic.handle_exception(NotAuthenticated, HTTPStatus.UNAUTHORIZED)
64
     @hapic.handle_exception(NotAuthenticated, HTTPStatus.UNAUTHORIZED)
65
     @hapic.handle_exception(InsufficientUserWorkspaceRole, HTTPStatus.FORBIDDEN)
65
     @hapic.handle_exception(InsufficientUserWorkspaceRole, HTTPStatus.FORBIDDEN)
66
     @hapic.handle_exception(WorkspaceNotFound, HTTPStatus.FORBIDDEN)
66
     @hapic.handle_exception(WorkspaceNotFound, HTTPStatus.FORBIDDEN)
67
-    @hapic.handle_exception(AuthenticationFailed, HTTPStatus.BAD_REQUEST)
67
+    @hapic.handle_exception(AuthenticationFailed, HTTPStatus.FORBIDDEN)
68
     @require_workspace_role(UserRoleInWorkspace.CONTRIBUTOR)
68
     @require_workspace_role(UserRoleInWorkspace.CONTRIBUTOR)
69
     @require_content_types([html_documents_type])
69
     @require_content_types([html_documents_type])
70
     @hapic.input_path(WorkspaceAndContentIdPathSchema())
70
     @hapic.input_path(WorkspaceAndContentIdPathSchema())
102
     @hapic.handle_exception(NotAuthenticated, HTTPStatus.UNAUTHORIZED)
102
     @hapic.handle_exception(NotAuthenticated, HTTPStatus.UNAUTHORIZED)
103
     @hapic.handle_exception(InsufficientUserWorkspaceRole, HTTPStatus.FORBIDDEN)
103
     @hapic.handle_exception(InsufficientUserWorkspaceRole, HTTPStatus.FORBIDDEN)
104
     @hapic.handle_exception(WorkspaceNotFound, HTTPStatus.FORBIDDEN)
104
     @hapic.handle_exception(WorkspaceNotFound, HTTPStatus.FORBIDDEN)
105
-    @hapic.handle_exception(AuthenticationFailed, HTTPStatus.BAD_REQUEST)
105
+    @hapic.handle_exception(AuthenticationFailed, HTTPStatus.FORBIDDEN)
106
     @require_workspace_role(UserRoleInWorkspace.READER)
106
     @require_workspace_role(UserRoleInWorkspace.READER)
107
     @require_content_types([html_documents_type])
107
     @require_content_types([html_documents_type])
108
     @hapic.input_path(WorkspaceAndContentIdPathSchema())
108
     @hapic.input_path(WorkspaceAndContentIdPathSchema())
131
     @hapic.handle_exception(NotAuthenticated, HTTPStatus.UNAUTHORIZED)
131
     @hapic.handle_exception(NotAuthenticated, HTTPStatus.UNAUTHORIZED)
132
     @hapic.handle_exception(InsufficientUserWorkspaceRole, HTTPStatus.FORBIDDEN)
132
     @hapic.handle_exception(InsufficientUserWorkspaceRole, HTTPStatus.FORBIDDEN)
133
     @hapic.handle_exception(WorkspaceNotFound, HTTPStatus.FORBIDDEN)
133
     @hapic.handle_exception(WorkspaceNotFound, HTTPStatus.FORBIDDEN)
134
-    @hapic.handle_exception(AuthenticationFailed, HTTPStatus.BAD_REQUEST)
134
+    @hapic.handle_exception(AuthenticationFailed, HTTPStatus.FORBIDDEN)
135
     @require_workspace_role(UserRoleInWorkspace.CONTRIBUTOR)
135
     @require_workspace_role(UserRoleInWorkspace.CONTRIBUTOR)
136
     @require_content_types([html_documents_type])
136
     @require_content_types([html_documents_type])
137
     @hapic.input_path(WorkspaceAndContentIdPathSchema())
137
     @hapic.input_path(WorkspaceAndContentIdPathSchema())

+ 4 - 4
tracim/views/contents_api/threads_controller.py 查看文件

38
     @hapic.handle_exception(NotAuthenticated, HTTPStatus.UNAUTHORIZED)
38
     @hapic.handle_exception(NotAuthenticated, HTTPStatus.UNAUTHORIZED)
39
     @hapic.handle_exception(InsufficientUserWorkspaceRole, HTTPStatus.FORBIDDEN)
39
     @hapic.handle_exception(InsufficientUserWorkspaceRole, HTTPStatus.FORBIDDEN)
40
     @hapic.handle_exception(WorkspaceNotFound, HTTPStatus.FORBIDDEN)
40
     @hapic.handle_exception(WorkspaceNotFound, HTTPStatus.FORBIDDEN)
41
-    @hapic.handle_exception(AuthenticationFailed, HTTPStatus.BAD_REQUEST)
41
+    @hapic.handle_exception(AuthenticationFailed, HTTPStatus.FORBIDDEN)
42
     @hapic.handle_exception(ContentTypeNotAllowed, HTTPStatus.BAD_REQUEST)
42
     @hapic.handle_exception(ContentTypeNotAllowed, HTTPStatus.BAD_REQUEST)
43
     @require_workspace_role(UserRoleInWorkspace.READER)
43
     @require_workspace_role(UserRoleInWorkspace.READER)
44
     @require_content_types([thread_type])
44
     @require_content_types([thread_type])
64
     @hapic.handle_exception(NotAuthenticated, HTTPStatus.UNAUTHORIZED)
64
     @hapic.handle_exception(NotAuthenticated, HTTPStatus.UNAUTHORIZED)
65
     @hapic.handle_exception(InsufficientUserWorkspaceRole, HTTPStatus.FORBIDDEN)
65
     @hapic.handle_exception(InsufficientUserWorkspaceRole, HTTPStatus.FORBIDDEN)
66
     @hapic.handle_exception(WorkspaceNotFound, HTTPStatus.FORBIDDEN)
66
     @hapic.handle_exception(WorkspaceNotFound, HTTPStatus.FORBIDDEN)
67
-    @hapic.handle_exception(AuthenticationFailed, HTTPStatus.BAD_REQUEST)
67
+    @hapic.handle_exception(AuthenticationFailed, HTTPStatus.FORBIDDEN)
68
     @require_workspace_role(UserRoleInWorkspace.CONTRIBUTOR)
68
     @require_workspace_role(UserRoleInWorkspace.CONTRIBUTOR)
69
     @require_content_types([thread_type])
69
     @require_content_types([thread_type])
70
     @hapic.input_path(WorkspaceAndContentIdPathSchema())
70
     @hapic.input_path(WorkspaceAndContentIdPathSchema())
102
     @hapic.handle_exception(NotAuthenticated, HTTPStatus.UNAUTHORIZED)
102
     @hapic.handle_exception(NotAuthenticated, HTTPStatus.UNAUTHORIZED)
103
     @hapic.handle_exception(InsufficientUserWorkspaceRole, HTTPStatus.FORBIDDEN)
103
     @hapic.handle_exception(InsufficientUserWorkspaceRole, HTTPStatus.FORBIDDEN)
104
     @hapic.handle_exception(WorkspaceNotFound, HTTPStatus.FORBIDDEN)
104
     @hapic.handle_exception(WorkspaceNotFound, HTTPStatus.FORBIDDEN)
105
-    @hapic.handle_exception(AuthenticationFailed, HTTPStatus.BAD_REQUEST)
105
+    @hapic.handle_exception(AuthenticationFailed, HTTPStatus.FORBIDDEN)
106
     @require_workspace_role(UserRoleInWorkspace.READER)
106
     @require_workspace_role(UserRoleInWorkspace.READER)
107
     @require_content_types([thread_type])
107
     @require_content_types([thread_type])
108
     @hapic.input_path(WorkspaceAndContentIdPathSchema())
108
     @hapic.input_path(WorkspaceAndContentIdPathSchema())
131
     @hapic.handle_exception(NotAuthenticated, HTTPStatus.UNAUTHORIZED)
131
     @hapic.handle_exception(NotAuthenticated, HTTPStatus.UNAUTHORIZED)
132
     @hapic.handle_exception(InsufficientUserWorkspaceRole, HTTPStatus.FORBIDDEN)
132
     @hapic.handle_exception(InsufficientUserWorkspaceRole, HTTPStatus.FORBIDDEN)
133
     @hapic.handle_exception(WorkspaceNotFound, HTTPStatus.FORBIDDEN)
133
     @hapic.handle_exception(WorkspaceNotFound, HTTPStatus.FORBIDDEN)
134
-    @hapic.handle_exception(AuthenticationFailed, HTTPStatus.BAD_REQUEST)
134
+    @hapic.handle_exception(AuthenticationFailed, HTTPStatus.FORBIDDEN)
135
     @require_workspace_role(UserRoleInWorkspace.CONTRIBUTOR)
135
     @require_workspace_role(UserRoleInWorkspace.CONTRIBUTOR)
136
     @require_content_types([thread_type])
136
     @require_content_types([thread_type])
137
     @hapic.input_path(WorkspaceAndContentIdPathSchema())
137
     @hapic.input_path(WorkspaceAndContentIdPathSchema())

+ 1 - 1
tracim/views/core_api/session_controller.py 查看文件

24
     @hapic.with_api_doc(tags=[SESSION_ENDPOINTS_TAG])
24
     @hapic.with_api_doc(tags=[SESSION_ENDPOINTS_TAG])
25
     @hapic.input_headers(LoginOutputHeaders())
25
     @hapic.input_headers(LoginOutputHeaders())
26
     @hapic.input_body(BasicAuthSchema())
26
     @hapic.input_body(BasicAuthSchema())
27
-    @hapic.handle_exception(AuthenticationFailed, HTTPStatus.BAD_REQUEST)
27
+    @hapic.handle_exception(AuthenticationFailed, HTTPStatus.FORBIDDEN)
28
     # TODO - G.M - 17-04-2018 - fix output header ?
28
     # TODO - G.M - 17-04-2018 - fix output header ?
29
     # @hapic.output_headers()
29
     # @hapic.output_headers()
30
     @hapic.output_body(UserSchema(),)
30
     @hapic.output_body(UserSchema(),)