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
68d6939f
Unverified
Commit
68d6939f
authored
Oct 19, 2020
by
Etty
Committed by
GitHub
Oct 19, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
export: use --trusted-host for non HTTPS index
Resolves: #1894
parent
a66033bd
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
50 additions
and
0 deletions
+50
-0
poetry/utils/exporter.py
+4
-0
tests/utils/test_exporter.py
+46
-0
No files found.
poetry/utils/exporter.py
View file @
68d6939f
...
...
@@ -7,6 +7,7 @@ from clikit.api.io import IO
from
poetry.poetry
import
Poetry
from
poetry.utils._compat
import
Path
from
poetry.utils._compat
import
decode
from
poetry.utils._compat
import
urlparse
class
Exporter
(
object
):
...
...
@@ -139,6 +140,9 @@ class Exporter(object):
url
=
(
repository
.
authenticated_url
if
with_credentials
else
repository
.
url
)
parsed_url
=
urlparse
.
urlsplit
(
url
)
if
parsed_url
.
scheme
==
"http"
:
indexes_header
+=
"--trusted-host {}
\n
"
.
format
(
parsed_url
.
netloc
)
indexes_header
+=
"--extra-index-url {}
\n
"
.
format
(
url
)
content
=
indexes_header
+
"
\n
"
+
content
...
...
tests/utils/test_exporter.py
View file @
68d6939f
...
...
@@ -972,6 +972,52 @@ foo==1.2.3 \\
assert
expected
==
content
def
test_exporter_exports_requirements_txt_with_legacy_packages_trusted_host
(
tmp_dir
,
poetry
):
poetry
.
pool
.
add_repository
(
LegacyRepository
(
"custom"
,
"http://example.com/simple"
,))
poetry
.
locker
.
mock_lock_data
(
{
"package"
:
[
{
"name"
:
"bar"
,
"version"
:
"4.5.6"
,
"category"
:
"dev"
,
"optional"
:
False
,
"python-versions"
:
"*"
,
"source"
:
{
"type"
:
"legacy"
,
"url"
:
"http://example.com/simple"
,
"reference"
:
""
,
},
},
],
"metadata"
:
{
"python-versions"
:
"*"
,
"content-hash"
:
"123456789"
,
"hashes"
:
{
"bar"
:
[
"67890"
]},
},
}
)
set_package_requires
(
poetry
)
exporter
=
Exporter
(
poetry
)
exporter
.
export
(
"requirements.txt"
,
Path
(
tmp_dir
),
"requirements.txt"
,
dev
=
True
)
with
(
Path
(
tmp_dir
)
/
"requirements.txt"
)
.
open
(
encoding
=
"utf-8"
)
as
f
:
content
=
f
.
read
()
expected
=
"""
\
--trusted-host example.com
--extra-index-url http://example.com/simple
bar==4.5.6
\\
--hash=sha256:67890
"""
assert
expected
==
content
@pytest.mark.parametrize
(
(
"dev"
,
"expected"
),
[
...
...
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