feat: X-Proxy
This commit is contained in:
@@ -30,17 +30,21 @@ class TestRegistry(BaseTestCase):
|
||||
["test_1", Registry.HOST_FILE],
|
||||
["test_1", Registry.TOKEN_FILE],
|
||||
["test_1", Registry.REDIRECT_FILE],
|
||||
["test_1", Registry.PROXY_FILE],
|
||||
["test_2", Registry.HOST_FILE],
|
||||
["test_2", Registry.TOKEN_FILE],
|
||||
["test_2", Registry.REDIRECT_FILE],
|
||||
["test_2", Registry.PROXY_FILE],
|
||||
],
|
||||
[
|
||||
"test_1_host",
|
||||
"test_1_token",
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
"test_2_token",
|
||||
"test_2_redirect",
|
||||
None,
|
||||
],
|
||||
),
|
||||
self.seal_mocks(),
|
||||
@@ -114,12 +118,33 @@ class TestRegistry(BaseTestCase):
|
||||
self.registry.set_token_hash("test_1", "new_value")
|
||||
self.assertEqual(self.registry.pages["test_1"].token_hash, "new_value")
|
||||
|
||||
def test_set_token_hash_no_change(self) -> None:
|
||||
self.registry.pages["test_1"] = Page(
|
||||
"test_1",
|
||||
token_hash="secret", # noqa: S106
|
||||
)
|
||||
with (
|
||||
self.seal_mocks(),
|
||||
):
|
||||
self.registry.set_token_hash("test_1", "secret")
|
||||
self.assertEqual(self.registry.pages["test_1"].token_hash, "secret")
|
||||
|
||||
def test_set_token_hash_not_found(self) -> None:
|
||||
with (
|
||||
self.seal_mocks(),
|
||||
):
|
||||
self.registry.set_token_hash("test_1", "secret")
|
||||
|
||||
def test_set_redirect(self) -> None:
|
||||
self.registry.pages["test_1"] = Page(
|
||||
"test_1",
|
||||
redirect="https://example.com",
|
||||
)
|
||||
with (
|
||||
self.mock_call(
|
||||
self.data_dir.empty,
|
||||
["test_1"],
|
||||
),
|
||||
self.mock_call(
|
||||
self.data_dir.set_file,
|
||||
["test_1", Registry.REDIRECT_FILE, "https://new-example.com"],
|
||||
@@ -131,6 +156,81 @@ class TestRegistry(BaseTestCase):
|
||||
self.registry.pages["test_1"].redirect, "https://new-example.com"
|
||||
)
|
||||
|
||||
def test_set_redirect_no_change(self) -> None:
|
||||
self.registry.pages["test_1"] = Page(
|
||||
"test_1",
|
||||
redirect="https://example.com",
|
||||
)
|
||||
with (
|
||||
self.seal_mocks(),
|
||||
):
|
||||
self.registry.set_redirect("test_1", "https://example.com")
|
||||
self.assertEqual(self.registry.pages["test_1"].redirect, "https://example.com")
|
||||
|
||||
def test_set_redirect_not_found(self) -> None:
|
||||
with (
|
||||
self.mock_call(
|
||||
self.data_dir.empty,
|
||||
["test_1"],
|
||||
),
|
||||
self.mock_call(
|
||||
self.data_dir.set_file,
|
||||
["test_1", Registry.REDIRECT_FILE, "https://new-example.com"],
|
||||
),
|
||||
self.seal_mocks(),
|
||||
):
|
||||
self.registry.set_redirect("test_1", "https://new-example.com")
|
||||
self.assertIn("test_1", self.registry.pages)
|
||||
self.assertEqual(
|
||||
self.registry.pages["test_1"].redirect, "https://new-example.com"
|
||||
)
|
||||
|
||||
def test_set_proxy(self) -> None:
|
||||
self.registry.pages["test_1"] = Page(
|
||||
"test_1",
|
||||
proxy="https://example.com",
|
||||
)
|
||||
with (
|
||||
self.mock_call(
|
||||
self.data_dir.empty,
|
||||
["test_1"],
|
||||
),
|
||||
self.mock_call(
|
||||
self.data_dir.set_file,
|
||||
["test_1", Registry.PROXY_FILE, "https://new-example.com"],
|
||||
),
|
||||
self.seal_mocks(),
|
||||
):
|
||||
self.registry.set_proxy("test_1", "https://new-example.com")
|
||||
self.assertEqual(self.registry.pages["test_1"].proxy, "https://new-example.com")
|
||||
|
||||
def test_set_proxy_no_change(self) -> None:
|
||||
self.registry.pages["test_1"] = Page(
|
||||
"test_1",
|
||||
proxy="https://example.com",
|
||||
)
|
||||
with (
|
||||
self.seal_mocks(),
|
||||
):
|
||||
self.registry.set_proxy("test_1", "https://example.com")
|
||||
self.assertEqual(self.registry.pages["test_1"].proxy, "https://example.com")
|
||||
|
||||
def test_set_proxy_not_found(self) -> None:
|
||||
with (
|
||||
self.mock_call(
|
||||
self.data_dir.empty,
|
||||
["test_1"],
|
||||
),
|
||||
self.mock_call(
|
||||
self.data_dir.set_file,
|
||||
["test_1", Registry.PROXY_FILE, "https://new-example.com"],
|
||||
),
|
||||
self.seal_mocks(),
|
||||
):
|
||||
self.registry.set_proxy("test_1", "https://new-example.com")
|
||||
self.assertIn("test_1", self.registry.pages)
|
||||
self.assertEqual(self.registry.pages["test_1"].proxy, "https://new-example.com")
|
||||
|
||||
def test_remove(self) -> None:
|
||||
self.registry.pages["test_1"] = Page(
|
||||
"test_1",
|
||||
|
||||
Reference in New Issue
Block a user