Skip to content

Commit

Permalink
Add test capturing expectation that the password prompt occurs if no …
Browse files Browse the repository at this point in the history
…password was indicated. Ref #426 #450.
  • Loading branch information
jaraco committed Feb 9, 2019
1 parent 78c46f0 commit cad2ccf
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,12 @@ def get_password(system, user):
assert pw == 'entered pw'


def test_no_password_defers_to_prompt(monkeypatch):
monkeypatch.setattr(utils, 'password_prompt', lambda prompt: 'entered pw')
pw = utils.get_password('system', 'user', None, {'password': None})

This comment has been minimized.

Copy link
@marob

marob Feb 9, 2019

Contributor

By passing {'password': None} as argument, you're configuring it to be anonymous, which is the purpose of #426.
So, not asking for prompt is the desired behavior.

This comment has been minimized.

Copy link
@jaraco

jaraco Feb 9, 2019

Author Member

But {'password': None} is set by default (unconfigured), in which case asking for a prompt is the desired behavior. I think you intended for {'password': ''} to be the special value indicating anonymous.

This comment has been minimized.

Copy link
@marob

marob Feb 9, 2019

Contributor

Where does the {'password': None} is set by default when unconfigured?

This comment has been minimized.

Copy link
@jaraco

jaraco Feb 9, 2019

Author Member

It's here.

assert pw == 'entered pw'


def test_get_username_and_password_keyring_overrides_prompt(monkeypatch):
import collections
Credential = collections.namedtuple('Credential', 'username password')
Expand Down

0 comments on commit cad2ccf

Please sign in to comment.