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
09c18da4
Unverified
Commit
09c18da4
authored
Oct 16, 2018
by
Sébastien Eustace
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add support for empty passwords when publishing
parent
ea420b83
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
52 additions
and
33 deletions
+52
-33
CHANGELOG.md
+1
-0
poetry/masonry/publishing/publisher.py
+2
-2
poetry/poetry.py
+9
-0
poetry/repositories/legacy_repository.py
+3
-1
poetry/utils/helpers.py
+6
-8
tests/conftest.py
+13
-0
tests/repositories/test_legacy_repository.py
+0
-10
tests/test_config.py
+0
-12
tests/utils/test_helpers.py
+18
-0
No files found.
CHANGELOG.md
View file @
09c18da4
...
@@ -20,6 +20,7 @@
...
@@ -20,6 +20,7 @@
-
The
`install`
command will now install the current project in editable mode.
-
The
`install`
command will now install the current project in editable mode.
-
The
`develop`
command is now deprecated in favor of
`install`
.
-
The
`develop`
command is now deprecated in favor of
`install`
.
-
Improved the
`check`
command.
-
Improved the
`check`
command.
-
Empty passwords are now supported when publishing.
### Fixed
### Fixed
...
...
poetry/masonry/publishing/publisher.py
View file @
09c18da4
...
@@ -65,7 +65,7 @@ class Publisher:
...
@@ -65,7 +65,7 @@ class Publisher:
url
=
config
[
"repositories"
][
repository_name
][
"url"
]
url
=
config
[
"repositories"
][
repository_name
][
"url"
]
if
not
(
username
and
password
):
if
not
(
username
and
password
):
auth
=
get_http_basic_auth
(
repository_name
)
auth
=
get_http_basic_auth
(
self
.
_poetry
.
auth_config
,
repository_name
)
if
auth
:
if
auth
:
username
=
auth
[
0
]
username
=
auth
[
0
]
password
=
auth
[
1
]
password
=
auth
[
1
]
...
@@ -74,7 +74,7 @@ class Publisher:
...
@@ -74,7 +74,7 @@ class Publisher:
if
not
username
:
if
not
username
:
username
=
self
.
_io
.
ask
(
"Username:"
)
username
=
self
.
_io
.
ask
(
"Username:"
)
if
not
password
:
if
password
is
None
:
password
=
self
.
_io
.
ask_hidden
(
"Password:"
)
password
=
self
.
_io
.
ask_hidden
(
"Password:"
)
# TODO: handle certificates
# TODO: handle certificates
...
...
poetry/poetry.py
View file @
09c18da4
...
@@ -37,6 +37,7 @@ class Poetry:
...
@@ -37,6 +37,7 @@ class Poetry:
self
.
_local_config
=
local_config
self
.
_local_config
=
local_config
self
.
_locker
=
locker
self
.
_locker
=
locker
self
.
_config
=
Config
.
create
(
"config.toml"
)
self
.
_config
=
Config
.
create
(
"config.toml"
)
self
.
_auth_config
=
Config
.
create
(
"auth.toml"
)
# Configure sources
# Configure sources
self
.
_pool
=
Pool
()
self
.
_pool
=
Pool
()
...
@@ -66,6 +67,14 @@ class Poetry:
...
@@ -66,6 +67,14 @@ class Poetry:
def
pool
(
self
):
# type: () -> Pool
def
pool
(
self
):
# type: () -> Pool
return
self
.
_pool
return
self
.
_pool
@property
def
config
(
self
):
# type: () -> Config
return
self
.
_config
@property
def
auth_config
(
self
):
# type: () -> Config
return
self
.
_auth_config
@classmethod
@classmethod
def
create
(
cls
,
cwd
):
# type: (Path) -> Poetry
def
create
(
cls
,
cwd
):
# type: (Path) -> Poetry
candidates
=
[
Path
(
cwd
)]
candidates
=
[
Path
(
cwd
)]
...
...
poetry/repositories/legacy_repository.py
View file @
09c18da4
...
@@ -171,7 +171,9 @@ class LegacyRepository(PyPiRepository):
...
@@ -171,7 +171,9 @@ class LegacyRepository(PyPiRepository):
url_parts
=
urlparse
.
urlparse
(
self
.
_url
)
url_parts
=
urlparse
.
urlparse
(
self
.
_url
)
if
not
url_parts
.
username
:
if
not
url_parts
.
username
:
self
.
_session
.
auth
=
get_http_basic_auth
(
self
.
name
)
self
.
_session
.
auth
=
get_http_basic_auth
(
Config
.
create
(
"auth.toml"
),
self
.
name
)
self
.
_disable_cache
=
disable_cache
self
.
_disable_cache
=
disable_cache
...
...
poetry/utils/helpers.py
View file @
09c18da4
...
@@ -3,6 +3,7 @@ import shutil
...
@@ -3,6 +3,7 @@ import shutil
import
tempfile
import
tempfile
from
contextlib
import
contextmanager
from
contextlib
import
contextmanager
from
typing
import
Optional
from
typing
import
Union
from
typing
import
Union
from
poetry.config
import
Config
from
poetry.config
import
Config
...
@@ -80,14 +81,11 @@ def parse_requires(requires): # type: (str) -> Union[list, None]
...
@@ -80,14 +81,11 @@ def parse_requires(requires): # type: (str) -> Union[list, None]
return
requires_dist
return
requires_dist
def
get_http_basic_auth
(
repository_name
):
# type: (str) -> tuple
def
get_http_basic_auth
(
config
=
Config
.
create
(
"auth.toml"
)
config
,
repository_name
):
# type: (Config, str) -> Optional[tuple]
repo_auth
=
config
.
setting
(
"http-basic.{}"
.
format
(
repository_name
))
repo_auth
=
config
.
setting
(
"http-basic.{}"
.
format
(
repository_name
))
if
repo_auth
:
if
repo_auth
:
return
repo_auth
[
"username"
],
repo_auth
[
"password"
]
return
repo_auth
[
"username"
],
repo_auth
.
get
(
"password"
)
return
None
def
constraint_to_marker
(
constraint
):
# type: (Any) -> Marker
return
None
if
constraint
.
is_any
():
return
AnyMarker
()
tests/conftest.py
0 → 100644
View file @
09c18da4
import
pytest
import
tempfile
from
poetry.config
import
Config
from
poetry.utils.toml_file
import
TomlFile
@pytest.fixture
def
config
():
# type: () -> Config
with
tempfile
.
NamedTemporaryFile
()
as
f
:
f
.
close
()
return
Config
(
TomlFile
(
f
.
name
))
tests/repositories/test_legacy_repository.py
View file @
09c18da4
...
@@ -42,16 +42,6 @@ def test_page_absolute_links_path_are_correct():
...
@@ -42,16 +42,6 @@ def test_page_absolute_links_path_are_correct():
assert
link
.
path
.
startswith
(
"/packages/"
)
assert
link
.
path
.
startswith
(
"/packages/"
)
def
test_http_basic_auth_repo
(
mocker
):
mock
=
mocker
.
patch
(
"poetry.repositories.legacy_repository.get_http_basic_auth"
)
mock
.
return_value
=
(
"user1"
,
"p4ss"
)
repo
=
MockRepository
()
mock
.
assert_called_once_with
(
"legacy"
)
assert
repo
.
_session
.
auth
==
(
"user1"
,
"p4ss"
)
def
test_sdist_format_support
():
def
test_sdist_format_support
():
repo
=
MockRepository
()
repo
=
MockRepository
()
page
=
repo
.
_get
(
"/relative"
)
page
=
repo
.
_get
(
"/relative"
)
...
...
tests/test_config.py
View file @
09c18da4
import
os
import
os
import
pytest
import
pytest
import
sys
import
sys
import
tempfile
from
poetry.config
import
Config
from
poetry.utils.toml_file
import
TomlFile
@pytest.fixture
def
config
():
with
tempfile
.
NamedTemporaryFile
()
as
f
:
f
.
close
()
return
Config
(
TomlFile
(
f
.
name
))
@pytest.mark.skipif
(
@pytest.mark.skipif
(
...
...
tests/utils/test_helpers.py
View file @
09c18da4
from
poetry.utils.helpers
import
get_http_basic_auth
from
poetry.utils.helpers
import
parse_requires
from
poetry.utils.helpers
import
parse_requires
...
@@ -48,3 +49,20 @@ zipfile36>=0.1.0.0,<0.2.0.0
...
@@ -48,3 +49,20 @@ zipfile36>=0.1.0.0,<0.2.0.0
'zipfile36>=0.1.0.0,<0.2.0.0; python_version >= "3.4.0.0" and python_version < "3.6.0.0"'
,
'zipfile36>=0.1.0.0,<0.2.0.0; python_version >= "3.4.0.0" and python_version < "3.6.0.0"'
,
]
]
assert
result
==
expected
assert
result
==
expected
def
test_get_http_basic_auth
(
config
):
config
.
add_property
(
"http-basic.foo.username"
,
"foo"
)
config
.
add_property
(
"http-basic.foo.password"
,
"bar"
)
assert
get_http_basic_auth
(
config
,
"foo"
)
==
(
"foo"
,
"bar"
)
def
test_get_http_basic_auth_without_password
(
config
):
config
.
add_property
(
"http-basic.foo.username"
,
"foo"
)
assert
get_http_basic_auth
(
config
,
"foo"
)
==
(
"foo"
,
None
)
def
test_get_http_basic_auth_missing
(
config
):
assert
get_http_basic_auth
(
config
,
"foo"
)
is
None
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