fix outdated port example
This commit is contained in:
@@ -41,10 +41,10 @@ def _write_store(tmp: Path, payload: dict) -> Path:
|
|||||||
class ReadGitFieldsTests(unittest.TestCase):
|
class ReadGitFieldsTests(unittest.TestCase):
|
||||||
|
|
||||||
def test_full_block(self) -> None:
|
def test_full_block(self) -> None:
|
||||||
buf = io.StringIO("protocol=https\nhost=g.example:6006\npath=a/b.git\n\n")
|
buf = io.StringIO("protocol=https\nhost=g.example:8443\npath=a/b.git\n\n")
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
gcf.read_git_fields(buf),
|
gcf.read_git_fields(buf),
|
||||||
{"protocol": "https", "host": "g.example:6006", "path": "a/b.git"},
|
{"protocol": "https", "host": "g.example:8443", "path": "a/b.git"},
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_eof_without_blank_line(self) -> None:
|
def test_eof_without_blank_line(self) -> None:
|
||||||
@@ -66,24 +66,24 @@ class RequestMatchesTests(unittest.TestCase):
|
|||||||
def test_exact_match_including_port(self) -> None:
|
def test_exact_match_including_port(self) -> None:
|
||||||
self.assertTrue(
|
self.assertTrue(
|
||||||
gcf._request_matches(
|
gcf._request_matches(
|
||||||
{"protocol": "https", "host": "g.example:6006"},
|
{"protocol": "https", "host": "g.example:8443"},
|
||||||
("https", "g.example", 6006),
|
("https", "g.example", 8443),
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_wrong_scheme_no_match(self) -> None:
|
def test_wrong_scheme_no_match(self) -> None:
|
||||||
self.assertFalse(
|
self.assertFalse(
|
||||||
gcf._request_matches(
|
gcf._request_matches(
|
||||||
{"protocol": "http", "host": "g.example:6006"},
|
{"protocol": "http", "host": "g.example:8443"},
|
||||||
("https", "g.example", 6006),
|
("https", "g.example", 8443),
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_wrong_host_no_match(self) -> None:
|
def test_wrong_host_no_match(self) -> None:
|
||||||
self.assertFalse(
|
self.assertFalse(
|
||||||
gcf._request_matches(
|
gcf._request_matches(
|
||||||
{"protocol": "https", "host": "other.example:6006"},
|
{"protocol": "https", "host": "other.example:8443"},
|
||||||
("https", "g.example", 6006),
|
("https", "g.example", 8443),
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -91,7 +91,7 @@ class RequestMatchesTests(unittest.TestCase):
|
|||||||
self.assertFalse(
|
self.assertFalse(
|
||||||
gcf._request_matches(
|
gcf._request_matches(
|
||||||
{"protocol": "https", "host": "g.example:7000"},
|
{"protocol": "https", "host": "g.example:7000"},
|
||||||
("https", "g.example", 6006),
|
("https", "g.example", 8443),
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -116,7 +116,7 @@ class RequestMatchesTests(unittest.TestCase):
|
|||||||
def test_stored_default_https_request_with_other_port_no_match(self) -> None:
|
def test_stored_default_https_request_with_other_port_no_match(self) -> None:
|
||||||
self.assertFalse(
|
self.assertFalse(
|
||||||
gcf._request_matches(
|
gcf._request_matches(
|
||||||
{"protocol": "https", "host": "g.example:6006"},
|
{"protocol": "https", "host": "g.example:8443"},
|
||||||
("https", "g.example", None),
|
("https", "g.example", None),
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
@@ -138,7 +138,7 @@ class CmdGetTests(unittest.TestCase):
|
|||||||
tmp = Path(d)
|
tmp = Path(d)
|
||||||
env = {
|
env = {
|
||||||
"FSDGG_AUTH_STORE_PATH": str(tmp / "client-auth.json"),
|
"FSDGG_AUTH_STORE_PATH": str(tmp / "client-auth.json"),
|
||||||
"FORGE_GITEA_URL": "https://g.example:6006",
|
"FORGE_GITEA_URL": "https://g.example:8443",
|
||||||
"FSDGG_CLI_CLIENT_ID": "client-1",
|
"FSDGG_CLI_CLIENT_ID": "client-1",
|
||||||
"FSDGG_CLI_REDIRECT_URI": "http://127.0.0.1:38111/callback",
|
"FSDGG_CLI_REDIRECT_URI": "http://127.0.0.1:38111/callback",
|
||||||
"HOME": str(tmp),
|
"HOME": str(tmp),
|
||||||
@@ -165,33 +165,33 @@ class CmdGetTests(unittest.TestCase):
|
|||||||
"username": "alice",
|
"username": "alice",
|
||||||
"gitea_access_token": "LIVETOKEN",
|
"gitea_access_token": "LIVETOKEN",
|
||||||
"gitea_token_expires_at": time.time() + 3600,
|
"gitea_token_expires_at": time.time() + 3600,
|
||||||
"_forge_gitea_base_url": "https://g.example:6006",
|
"_forge_gitea_base_url": "https://g.example:8443",
|
||||||
}
|
}
|
||||||
rc, out, _ = self._run(
|
rc, out, _ = self._run(
|
||||||
store_payload=payload,
|
store_payload=payload,
|
||||||
stdin_text="protocol=https\nhost=g.example:6006\npath=org/repo.git\n\n",
|
stdin_text="protocol=https\nhost=g.example:8443\npath=org/repo.git\n\n",
|
||||||
)
|
)
|
||||||
self.assertEqual(rc, 0)
|
self.assertEqual(rc, 0)
|
||||||
parsed = dict(l.split("=", 1) for l in out.strip().splitlines())
|
parsed = dict(l.split("=", 1) for l in out.strip().splitlines())
|
||||||
self.assertEqual(parsed["username"], "alice")
|
self.assertEqual(parsed["username"], "alice")
|
||||||
self.assertEqual(parsed["password"], "LIVETOKEN")
|
self.assertEqual(parsed["password"], "LIVETOKEN")
|
||||||
self.assertEqual(parsed["host"], "g.example:6006")
|
self.assertEqual(parsed["host"], "g.example:8443")
|
||||||
|
|
||||||
def test_no_store_passes_through(self) -> None:
|
def test_no_store_passes_through(self) -> None:
|
||||||
rc, out, _ = self._run(
|
rc, out, _ = self._run(
|
||||||
store_payload=None,
|
store_payload=None,
|
||||||
stdin_text="protocol=https\nhost=g.example:6006\n\n",
|
stdin_text="protocol=https\nhost=g.example:8443\n\n",
|
||||||
)
|
)
|
||||||
self.assertEqual(rc, 0)
|
self.assertEqual(rc, 0)
|
||||||
self.assertNotIn("password=", out)
|
self.assertNotIn("password=", out)
|
||||||
self.assertIn("host=g.example:6006", out)
|
self.assertIn("host=g.example:8443", out)
|
||||||
|
|
||||||
def test_non_matching_host_passes_through(self) -> None:
|
def test_non_matching_host_passes_through(self) -> None:
|
||||||
payload = {
|
payload = {
|
||||||
"username": "alice",
|
"username": "alice",
|
||||||
"gitea_access_token": "LIVETOKEN",
|
"gitea_access_token": "LIVETOKEN",
|
||||||
"gitea_token_expires_at": time.time() + 3600,
|
"gitea_token_expires_at": time.time() + 3600,
|
||||||
"_forge_gitea_base_url": "https://g.example:6006",
|
"_forge_gitea_base_url": "https://g.example:8443",
|
||||||
}
|
}
|
||||||
rc, out, _ = self._run(
|
rc, out, _ = self._run(
|
||||||
store_payload=payload,
|
store_payload=payload,
|
||||||
@@ -205,11 +205,11 @@ class CmdGetTests(unittest.TestCase):
|
|||||||
payload = {
|
payload = {
|
||||||
"username": "alice",
|
"username": "alice",
|
||||||
"gitea_access_token": "",
|
"gitea_access_token": "",
|
||||||
"_forge_gitea_base_url": "https://g.example:6006",
|
"_forge_gitea_base_url": "https://g.example:8443",
|
||||||
}
|
}
|
||||||
rc, out, _ = self._run(
|
rc, out, _ = self._run(
|
||||||
store_payload=payload,
|
store_payload=payload,
|
||||||
stdin_text="protocol=https\nhost=g.example:6006\n\n",
|
stdin_text="protocol=https\nhost=g.example:8443\n\n",
|
||||||
)
|
)
|
||||||
self.assertEqual(rc, 0)
|
self.assertEqual(rc, 0)
|
||||||
self.assertNotIn("password=", out)
|
self.assertNotIn("password=", out)
|
||||||
@@ -221,7 +221,7 @@ class CmdGetTests(unittest.TestCase):
|
|||||||
"username": "alice",
|
"username": "alice",
|
||||||
"gitea_access_token": "EXPIRED",
|
"gitea_access_token": "EXPIRED",
|
||||||
"gitea_token_expires_at": time.time() - 10,
|
"gitea_token_expires_at": time.time() - 10,
|
||||||
"_forge_gitea_base_url": "https://g.example:6006",
|
"_forge_gitea_base_url": "https://g.example:8443",
|
||||||
"_forge_refresh_token": "REFRESH",
|
"_forge_refresh_token": "REFRESH",
|
||||||
"_forge_client_id": "client-1",
|
"_forge_client_id": "client-1",
|
||||||
}
|
}
|
||||||
@@ -239,7 +239,7 @@ class CmdGetTests(unittest.TestCase):
|
|||||||
with mock.patch.object(gcf.forge_auth, "run_refresh", side_effect=fake_refresh):
|
with mock.patch.object(gcf.forge_auth, "run_refresh", side_effect=fake_refresh):
|
||||||
rc, out, _ = self._run(
|
rc, out, _ = self._run(
|
||||||
store_payload=payload,
|
store_payload=payload,
|
||||||
stdin_text="protocol=https\nhost=g.example:6006\n\n",
|
stdin_text="protocol=https\nhost=g.example:8443\n\n",
|
||||||
)
|
)
|
||||||
self.assertEqual(rc, 0)
|
self.assertEqual(rc, 0)
|
||||||
parsed = dict(l.split("=", 1) for l in out.strip().splitlines())
|
parsed = dict(l.split("=", 1) for l in out.strip().splitlines())
|
||||||
@@ -250,7 +250,7 @@ class CmdGetTests(unittest.TestCase):
|
|||||||
"username": "alice",
|
"username": "alice",
|
||||||
"gitea_access_token": "EXPIRED",
|
"gitea_access_token": "EXPIRED",
|
||||||
"gitea_token_expires_at": time.time() - 10,
|
"gitea_token_expires_at": time.time() - 10,
|
||||||
"_forge_gitea_base_url": "https://g.example:6006",
|
"_forge_gitea_base_url": "https://g.example:8443",
|
||||||
"_forge_refresh_token": "DEAD",
|
"_forge_refresh_token": "DEAD",
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -260,7 +260,7 @@ class CmdGetTests(unittest.TestCase):
|
|||||||
with mock.patch.object(gcf.forge_auth, "run_refresh", side_effect=fake_refresh):
|
with mock.patch.object(gcf.forge_auth, "run_refresh", side_effect=fake_refresh):
|
||||||
rc, out, err = self._run(
|
rc, out, err = self._run(
|
||||||
store_payload=payload,
|
store_payload=payload,
|
||||||
stdin_text="protocol=https\nhost=g.example:6006\n\n",
|
stdin_text="protocol=https\nhost=g.example:8443\n\n",
|
||||||
)
|
)
|
||||||
self.assertEqual(rc, 0)
|
self.assertEqual(rc, 0)
|
||||||
self.assertNotIn("password=", out)
|
self.assertNotIn("password=", out)
|
||||||
|
|||||||
Reference in New Issue
Block a user