@@ -8,6 +8,7 @@ import subprocess
|
||||
import sys
|
||||
import unittest
|
||||
import uuid
|
||||
from subprocess import CompletedProcess
|
||||
|
||||
|
||||
sys.path.insert(0, str(Path(__file__).resolve().parents[1] / "scripts"))
|
||||
@@ -20,6 +21,7 @@ from git_repo import ( # noqa: E402
|
||||
UNAVAILABLE,
|
||||
GitRepository,
|
||||
GitRepositoryError,
|
||||
_is_authentication_failure,
|
||||
_display_url,
|
||||
)
|
||||
|
||||
@@ -181,6 +183,26 @@ class GitRepositoryTests(unittest.TestCase):
|
||||
_display_url("https://user:[email protected]/owner/repository.git"),
|
||||
)
|
||||
|
||||
def test_authentication_failure_is_detected(self) -> None:
|
||||
result = CompletedProcess(
|
||||
["git", "push"],
|
||||
128,
|
||||
"",
|
||||
"remote: Failed to authenticate user\nfatal: Authentication failed",
|
||||
)
|
||||
self.assertTrue(_is_authentication_failure(result))
|
||||
|
||||
def test_clear_https_credential_targets_only_origin_host(self) -> None:
|
||||
self.git(self.work, "config", "credential.helper", "")
|
||||
self.git(
|
||||
self.work,
|
||||
"remote",
|
||||
"set-url",
|
||||
"origin",
|
||||
"https://git.example.test/team/repository.git",
|
||||
)
|
||||
self.assertEqual("git.example.test", self.repository.clear_https_credential())
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
||||
Reference in New Issue
Block a user