Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
python-poetry
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
open
python-poetry
Commits
3e42be10
Unverified
Commit
3e42be10
authored
Oct 14, 2020
by
ObserverOfTime
Committed by
GitHub
Oct 14, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
publish: raise an error on redirects
Resolves: #3069
parent
d1905045
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
1 deletions
+24
-1
poetry/publishing/uploader.py
+12
-1
tests/publishing/test_uploader.py
+12
-0
No files found.
poetry/publishing/uploader.py
View file @
3e42be10
...
@@ -265,13 +265,24 @@ class Uploader:
...
@@ -265,13 +265,24 @@ class Uploader:
allow_redirects
=
False
,
allow_redirects
=
False
,
headers
=
{
"Content-Type"
:
monitor
.
content_type
},
headers
=
{
"Content-Type"
:
monitor
.
content_type
},
)
)
if
dry_run
or
resp
.
ok
:
if
dry_run
or
200
<=
resp
.
status_code
<
300
:
bar
.
set_format
(
bar
.
set_format
(
" - Uploading <c1>{0}</c1> <fg=green>
%
percent
%%
</>"
.
format
(
" - Uploading <c1>{0}</c1> <fg=green>
%
percent
%%
</>"
.
format
(
file
.
name
file
.
name
)
)
)
)
bar
.
finish
()
bar
.
finish
()
elif
resp
.
status_code
==
301
:
if
self
.
_io
.
output
.
supports_ansi
():
self
.
_io
.
overwrite
(
" - Uploading <c1>{0}</c1> <error>{1}</>"
.
format
(
file
.
name
,
"FAILED"
)
)
raise
UploadError
(
"Redirects are not supported. "
"Is the URL missing a trailing slash?"
)
except
(
requests
.
ConnectionError
,
requests
.
HTTPError
)
as
e
:
except
(
requests
.
ConnectionError
,
requests
.
HTTPError
)
as
e
:
if
self
.
_io
.
output
.
supports_ansi
():
if
self
.
_io
.
output
.
supports_ansi
():
self
.
_io
.
overwrite
(
self
.
_io
.
overwrite
(
...
...
tests/publishing/test_uploader.py
View file @
3e42be10
...
@@ -34,6 +34,18 @@ def test_uploader_properly_handles_403_errors(http):
...
@@ -34,6 +34,18 @@ def test_uploader_properly_handles_403_errors(http):
assert
"HTTP Error 403: Forbidden"
==
str
(
e
.
value
)
assert
"HTTP Error 403: Forbidden"
==
str
(
e
.
value
)
def
test_uploader_properly_handles_301_redirects
(
http
):
http
.
register_uri
(
http
.
POST
,
"https://foo.com"
,
status
=
301
,
body
=
"Redirect"
)
uploader
=
Uploader
(
Factory
()
.
create_poetry
(
project
(
"simple_project"
)),
NullIO
())
with
pytest
.
raises
(
UploadError
)
as
e
:
uploader
.
upload
(
"https://foo.com"
)
assert
"Redirects are not supported. Is the URL missing a trailing slash?"
==
str
(
e
.
value
)
def
test_uploader_registers_for_appropriate_400_errors
(
mocker
,
http
):
def
test_uploader_registers_for_appropriate_400_errors
(
mocker
,
http
):
register
=
mocker
.
patch
(
"poetry.publishing.uploader.Uploader._register"
)
register
=
mocker
.
patch
(
"poetry.publishing.uploader.Uploader._register"
)
http
.
register_uri
(
http
.
register_uri
(
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a 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