Преглед на файлове

authentificationfailed is forbidden

Guénaël Muller преди 6 години
родител
ревизия
83c8bf3102

+ 4 - 4
tracim/tests/functional/test_session.py Целия файл

@@ -59,14 +59,14 @@ class TestLoginEndpoint(FunctionalTest):
59 59
         assert res.json_body['caldav_url'] is None
60 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 63
         params = {
64 64
             'email': 'admin@admin.admin',
65 65
             'password': 'bad_password',
66 66
         }
67 67
         res = self.testapp.post_json(
68 68
             '/api/v2/sessions/login',
69
-            status=400,
69
+            status=403,
70 70
             params=params,
71 71
         )
72 72
         assert isinstance(res.json, dict)
@@ -74,14 +74,14 @@ class TestLoginEndpoint(FunctionalTest):
74 74
         assert 'message' in res.json.keys()
75 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 78
         params = {
79 79
             'email': 'unknown_user@unknown.unknown',
80 80
             'password': 'bad_password',
81 81
         }
82 82
         res = self.testapp.post_json(
83 83
             '/api/v2/sessions/login',
84
-            status=400,
84
+            status=403,
85 85
             params=params,
86 86
         )
87 87
         assert isinstance(res.json, dict)

+ 3 - 3
tracim/views/contents_api/comment_controller.py Целия файл

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

+ 4 - 4
tracim/views/contents_api/html_document_controller.py Целия файл

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

+ 4 - 4
tracim/views/contents_api/threads_controller.py Целия файл

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

+ 1 - 1
tracim/views/core_api/session_controller.py Целия файл

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