Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
mentors.debian.net
debexpo
Commits
99b05dca
Verified
Commit
99b05dca
authored
Aug 29, 2022
by
Baptiste Beauplat
Browse files
Make sure that we are using the text/plain part of the multipart email for changes extraction
parent
0444ee25
Changes
3
Show whitespace changes
Inline
Side-by-side
debexpo/packages/tasks.py
View file @
99b05dca
...
@@ -225,11 +225,19 @@ def mark_packages_as_uploaded(packages, debian=False):
...
@@ -225,11 +225,19 @@ def mark_packages_as_uploaded(packages, debian=False):
def
convert_mail_to_changes
(
mail
):
def
convert_mail_to_changes
(
mail
):
changes
=
None
if
not
mail
:
if
not
mail
:
return
return
if
mail
.
is_multipart
():
if
mail
.
is_multipart
():
changes
=
mail
.
get_payload
()[
0
].
get_payload
(
decode
=
True
)
for
part
in
mail
.
get_payload
():
if
part
.
get_content_type
()
==
'text/plain'
:
changes
=
part
.
get_payload
(
decode
=
True
)
break
if
not
changes
:
raise
Exception
(
'Could not find a text/plain multipart'
)
else
:
else
:
changes
=
mail
.
get_payload
(
decode
=
True
)
changes
=
mail
.
get_payload
(
decode
=
True
)
...
...
tests/functional/packages/templates/test-upload-accepted-multipart.html
View file @
99b05dca
...
@@ -35,7 +35,7 @@ Date: Fri, 19 Jul 2019 08:49:25 +0000
...
@@ -35,7 +35,7 @@ Date: Fri, 19 Jul 2019 08:49:25 +0000
Received-SPF: none client-ip=2001:41b8:202:deb:6564:a62:52c3:4b72; envelope-from=envelope@ftp-master.debian.org; helo=mailly.debian.org
Received-SPF: none client-ip=2001:41b8:202:deb:6564:a62:52c3:4b72; envelope-from=envelope@ftp-master.debian.org; helo=mailly.debian.org
--===============8966746602356696880==
--===============8966746602356696880==
Content-Type:
text/plain
; charset="utf-8"
Content-Type:
{{ args.content_type }}
; charset="utf-8"
Content-Transfer-Encoding: quoted-printable
Content-Transfer-Encoding: quoted-printable
-----BEGIN PGP SIGNED MESSAGE-----
-----BEGIN PGP SIGNED MESSAGE-----
...
...
tests/functional/packages/test_removeolduploads.py
View file @
99b05dca
...
@@ -139,7 +139,8 @@ class TestCronjobRemoveOldUploads(TestController):
...
@@ -139,7 +139,8 @@ class TestCronjobRemoveOldUploads(TestController):
def
remove_upload_accepted
(
self
,
uploaded
,
down
=
False
,
garbage
=
False
,
def
remove_upload_accepted
(
self
,
uploaded
,
down
=
False
,
garbage
=
False
,
handler
=
None
,
handler
=
None
,
template
=
'test-upload-accepted.html'
):
template
=
'test-upload-accepted.html'
,
content_type
=
'text/plain'
):
removed_packages
=
(
removed_packages
=
(
(
'tmux'
,
'1.0.0'
,
'unstable'
),
(
'tmux'
,
'1.0.0'
,
'unstable'
),
(
'tmux'
,
'1.0.0'
,
'UNRELEASED'
),
(
'tmux'
,
'1.0.0'
,
'UNRELEASED'
),
...
@@ -154,7 +155,8 @@ class TestCronjobRemoveOldUploads(TestController):
...
@@ -154,7 +155,8 @@ class TestCronjobRemoveOldUploads(TestController):
FTP_MASTER_NEW_PACKAGES_URL
=
'http://localhost:'
FTP_MASTER_NEW_PACKAGES_URL
=
'http://localhost:'
f
'
{
httpd
.
port
}
'
):
f
'
{
httpd
.
port
}
'
):
remove_uploaded_packages
(
FakeNNTPClient
(
uploaded
,
down
,
remove_uploaded_packages
(
FakeNNTPClient
(
uploaded
,
down
,
garbage
,
template
))
garbage
,
template
,
content_type
))
def
test_package_in_new_server_error
(
self
):
def
test_package_in_new_server_error
(
self
):
self
.
_setup_packages
()
self
.
_setup_packages
()
...
@@ -193,6 +195,15 @@ class TestCronjobRemoveOldUploads(TestController):
...
@@ -193,6 +195,15 @@ class TestCronjobRemoveOldUploads(TestController):
self
.
_expect_package_removal
(
removed_packages
)
self
.
_expect_package_removal
(
removed_packages
)
self
.
_assert_cronjob_success
()
self
.
_assert_cronjob_success
()
def
test_remove_uploads_multipart_no_plain
(
self
):
self
.
_setup_packages
()
self
.
remove_upload_accepted
(
[(
'zsh'
,
'1.0.0'
,
'unstable'
)],
template
=
'test-upload-accepted-multipart.html'
,
content_type
=
'text/html'
)
self
.
_assert_cronjob_success
()
def
test_remove_uploads_server_down
(
self
):
def
test_remove_uploads_server_down
(
self
):
self
.
_setup_packages
()
self
.
_setup_packages
()
self
.
remove_upload_accepted
([],
True
)
self
.
remove_upload_accepted
([],
True
)
...
@@ -277,12 +288,14 @@ class FTPMasterPackageInNewErrorHTTPHandler(BaseHTTPRequestHandler):
...
@@ -277,12 +288,14 @@ class FTPMasterPackageInNewErrorHTTPHandler(BaseHTTPRequestHandler):
class
FakeNNTPClient
():
class
FakeNNTPClient
():
def
__init__
(
self
,
uploads
,
down
=
False
,
garbage
=
False
,
def
__init__
(
self
,
uploads
,
down
=
False
,
garbage
=
False
,
template
=
'test-upload-accepted.html'
):
template
=
'test-upload-accepted.html'
,
content_type
=
'text/plain'
):
self
.
uploads
=
uploads
self
.
uploads
=
uploads
self
.
iter
=
0
self
.
iter
=
0
self
.
down
=
down
self
.
down
=
down
self
.
garbage
=
garbage
self
.
garbage
=
garbage
self
.
template
=
template
self
.
template
=
template
self
.
content_type
=
content_type
def
connect_to_server
(
self
):
def
connect_to_server
(
self
):
return
not
self
.
down
return
not
self
.
down
...
@@ -308,6 +321,7 @@ class FakeNNTPClient():
...
@@ -308,6 +321,7 @@ class FakeNNTPClient():
'name'
:
upload
[
0
],
'name'
:
upload
[
0
],
'version'
:
upload
[
1
],
'version'
:
upload
[
1
],
'distrib'
:
upload
[
2
],
'distrib'
:
upload
[
2
],
'content_type'
:
self
.
content_type
,
}))
}))
body
[
'X-Debexpo-Message-Number'
]
=
42
body
[
'X-Debexpo-Message-Number'
]
=
42
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment