Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/scmrepo/git/credentials.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ def get(self, credential: "Credential", **kwargs) -> "Credential":
cmd,
check=True,
capture_output=True,
input=os.linesep.join(helper_input),
input="\n".join(helper_input),
encoding=self._encoding,
**self._run_kwargs,
)
Expand Down Expand Up @@ -204,7 +204,7 @@ def store(self, credential: "Credential", **kwargs):
res = subprocess.run( # type: ignore # nosec B603 # pylint: disable=W1510
cmd,
capture_output=True,
input=os.linesep.join(helper_input),
input="\n".join(helper_input),
encoding=self._encoding,
**self._run_kwargs,
)
Expand All @@ -228,7 +228,7 @@ def erase(self, credential: "Credential", **kwargs):
res = subprocess.run( # type: ignore # nosec B603 # pylint: disable=W1510
cmd,
capture_output=True,
input=os.linesep.join(helper_input),
input="\n".join(helper_input),
encoding=self._encoding,
**self._run_kwargs,
)
Expand Down
16 changes: 8 additions & 8 deletions tests/test_credentials.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@ def test_subprocess_get(git_helper, mocker):
run = mocker.patch(
"subprocess.run",
return_value=mocker.Mock(
stdout=os.linesep.join(
stdout="\n".join(
["protocol=https", "host=foo.com", "username=foo", "password=bar", ""]
)
),
)
creds = git_helper.get(Credential(protocol="https", host="foo.com", path="foo.git"))
assert run.call_args.args[0] == ["git-credential-foo", "get"]
assert run.call_args.kwargs.get("input") == os.linesep.join(
assert run.call_args.kwargs.get("input") == "\n".join(
["protocol=https", "host=foo.com", ""]
)
assert creds == Credential(url="https://foo:bar@foo.com")
Expand All @@ -39,12 +39,12 @@ def test_subprocess_get_use_http_path(git_helper, mocker):
run = mocker.patch(
"subprocess.run",
return_value=mocker.Mock(
stdout=os.linesep.join(["username=foo", "password=bar", ""])
stdout="\n".join(["username=foo", "password=bar", ""])
),
)
creds = git_helper.get(Credential(protocol="https", host="foo.com", path="foo.git"))
assert run.call_args.args[0] == ["git-credential-foo", "get"]
assert run.call_args.kwargs.get("input") == os.linesep.join(
assert run.call_args.kwargs.get("input") == "\n".join(
["protocol=https", "host=foo.com", "path=foo.git", ""]
)
assert creds == Credential(username="foo", password="bar")
Expand All @@ -59,7 +59,7 @@ def test_subprocess_get_failed(git_helper, mocker):


def test_subprocess_get_no_output(git_helper, mocker):
mocker.patch("subprocess.run", return_value=mocker.Mock(stdout=os.linesep))
mocker.patch("subprocess.run", return_value=mocker.Mock(stdout="\n"))
with pytest.raises(CredentialNotFoundError):
git_helper.get(Credential(protocol="https", host="foo.com"))

Expand All @@ -70,7 +70,7 @@ def test_subprocess_store(git_helper, mocker):
Credential(protocol="https", host="foo.com", username="foo", password="bar")
)
assert run.call_args.args[0] == ["git-credential-foo", "store"]
assert run.call_args.kwargs.get("input") == os.linesep.join(
assert run.call_args.kwargs.get("input") == "\n".join(
["protocol=https", "host=foo.com", "username=foo", "password=bar", ""]
)

Expand All @@ -79,7 +79,7 @@ def test_subprocess_erase(git_helper, mocker):
run = mocker.patch("subprocess.run")
git_helper.erase(Credential(protocol="https", host="foo.com"))
assert run.call_args.args[0] == ["git-credential-foo", "erase"]
assert run.call_args.kwargs.get("input") == os.linesep.join(
assert run.call_args.kwargs.get("input") == "\n".join(
["protocol=https", "host=foo.com", ""]
)

Expand Down Expand Up @@ -149,7 +149,7 @@ def test_memory_helper_prompt_askpass(mocker):
"subprocess.run",
side_effect=[
mocker.Mock(stdout="foo"),
mocker.Mock(stdout=os.linesep.join(["bar", ""])),
mocker.Mock(stdout="\n".join(["bar", ""])),
],
)
expected = Credential(
Expand Down