Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
S
swh-web
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
David Douard
swh-web
Commits
b4762ee7
Commit
b4762ee7
authored
3 months ago
by
Renaud Boyer
Browse files
Options
Downloads
Patches
Plain Diff
inbound_email: GET is not allowed
parent
ae62b7d3
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
swh/web/inbound_email/tests/test_views.py
+11
-2
11 additions, 2 deletions
swh/web/inbound_email/tests/test_views.py
swh/web/inbound_email/views.py
+1
-0
1 addition, 0 deletions
swh/web/inbound_email/views.py
with
12 additions
and
2 deletions
swh/web/inbound_email/tests/test_views.py
+
11
−
2
View file @
b4762ee7
...
...
@@ -3,13 +3,14 @@
# License: GNU Affero General Public License version 3, or any later version
# See top-level LICENSE file for more information
from
http
import
HTTPStatus
from
io
import
BytesIO
import
pytest
from
django.test.client
import
MULTIPART_CONTENT
from
swh.web.tests.helpers
import
check_http_post_response
from
swh.web.tests.helpers
import
check_http_get_response
,
check_http_post_response
from
swh.web.utils
import
reverse
from
.common_tests
import
*
# noqa
...
...
@@ -22,7 +23,7 @@ def receive_inbound_message(client, inbound_message):
check_http_post_response
(
client
,
url
,
status_code
=
400
if
expect_failure
else
200
,
status_code
=
HTTPStatus
.
BAD_REQUEST
if
expect_failure
else
HTTPStatus
.
OK
,
request_content_type
=
MULTIPART_CONTENT
,
data
=
{
"
shared_key
"
:
shared_key
,
"
email
"
:
BytesIO
(
inbound_message
)},
)
...
...
@@ -42,3 +43,11 @@ def test_empty_email(receive_inbound_message):
def
test_invalid_shared_key
(
receive_inbound_message
):
with
pytest
.
raises
(
AssertionError
,
match
=
"
Invalid shared key!
"
):
receive_inbound_message
(
shared_key
=
"
invalid
"
)
def
test_get_is_not_allowed
(
client
):
check_http_get_response
(
client
,
reverse
(
"
process-inbound-email
"
),
status_code
=
HTTPStatus
.
METHOD_NOT_ALLOWED
,
)
This diff is collapsed.
Click to expand it.
swh/web/inbound_email/views.py
+
1
−
0
View file @
b4762ee7
...
...
@@ -33,6 +33,7 @@ class InboundEmailForm(forms.Form):
class
InboundEmailView
(
FormMixin
,
ProcessFormView
):
form_class
=
InboundEmailForm
success_url
=
"
/
"
http_method_names
=
[
"
post
"
,
"
put
"
]
# no blank (get) InboundEmailForm view
def
form_invalid
(
self
,
form
):
return
HttpResponseBadRequest
(
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment