Restyle landing to match aimloperations.com and use piha.lc.
CI / test (pull_request) Successful in 4s

Public short hosts are piha.lc (prod) and beta.piha.li (beta). The root
page is a marketing CTA to contact AI ML Operations for access.
Closes #3.
This commit is contained in:
2026-08-30 08:34:10 -05:00
parent 630b770c12
commit bb1aa449d6
18 changed files with 1373 additions and 214 deletions
+27 -24
View File
@@ -18,8 +18,9 @@ TOKENS = [("monica", "dev-only-token")]
SETTINGS = dict(
SHORTENER_API_TOKENS=TOKENS,
PUBLIC_SHORT_URL="https://go.mkdrealtor.com",
SHORT_PUBLIC_HOSTS=["go.mkdrealtor.com"],
SHORT_DOMAIN="piha.lc",
PUBLIC_SHORT_URL="https://piha.lc",
SHORT_PUBLIC_HOSTS=["piha.lc"],
SHORT_API_HOSTS=["testserver", "localhost", "127.0.0.1", "shortener.example.com"],
SHORT_ADMIN_HOSTS=["localhost", "127.0.0.1"],
SHORT_ALLOWED_HOSTS=["mkdrealtor.com"],
@@ -28,7 +29,7 @@ SETTINGS = dict(
"testserver",
"localhost",
"127.0.0.1",
"go.mkdrealtor.com",
"piha.lc",
"shortener.example.com",
],
SHORT_CODE_LENGTH=6,
@@ -93,7 +94,7 @@ class HostSplitTests(TestCase):
data=json.dumps({"target_url": "https://mkdrealtor.com/x"}),
content_type="application/json",
HTTP_AUTHORIZATION=AUTH,
HTTP_HOST="go.mkdrealtor.com",
HTTP_HOST="piha.lc",
)
self.assertEqual(response.status_code, 404)
@@ -103,7 +104,7 @@ class HostSplitTests(TestCase):
"localhost",
"127.0.0.1",
"shortener.example.com",
"go.mkdrealtor.com",
"piha.lc",
]
)
def test_short_host_never_serves_api_even_if_also_listed_as_api(self):
@@ -112,12 +113,12 @@ class HostSplitTests(TestCase):
data=json.dumps({"target_url": "https://mkdrealtor.com/x"}),
content_type="application/json",
HTTP_AUTHORIZATION=AUTH,
HTTP_HOST="go.mkdrealtor.com",
HTTP_HOST="piha.lc",
)
self.assertEqual(response.status_code, 404)
def test_public_host_admin_404(self):
response = self.client.get("/admin/", HTTP_HOST="go.mkdrealtor.com")
response = self.client.get("/admin/", HTTP_HOST="piha.lc")
self.assertEqual(response.status_code, 404)
def test_public_api_host_without_bearer_401(self):
@@ -155,7 +156,7 @@ class HostSplitTests(TestCase):
self.assertEqual(response.status_code, 404)
def test_healthz_on_public_and_api(self):
for host in ("go.mkdrealtor.com", "testserver", "shortener.example.com"):
for host in ("piha.lc", "testserver", "shortener.example.com"):
response = self.client.get("/healthz/", HTTP_HOST=host)
self.assertEqual(response.status_code, 200)
self.assertEqual(_json(response), {"status": "ok"})
@@ -216,7 +217,7 @@ class RedirectTests(TestCase):
def test_active_code_302_to_target(self):
response = self.client.get(
"/a3k9xm", HTTP_HOST="go.mkdrealtor.com", follow=False
"/a3k9xm", HTTP_HOST="piha.lc", follow=False
)
self.assertEqual(response.status_code, 302)
self.assertNotEqual(response.status_code, 301)
@@ -226,7 +227,7 @@ class RedirectTests(TestCase):
def test_head_also_302_without_click(self):
response = self.client.head(
"/a3k9xm", HTTP_HOST="go.mkdrealtor.com", follow=False
"/a3k9xm", HTTP_HOST="piha.lc", follow=False
)
self.assertEqual(response.status_code, 302)
self.assertEqual(
@@ -239,34 +240,36 @@ class RedirectTests(TestCase):
def test_inactive_404(self):
self.link.is_active = False
self.link.save()
response = self.client.get("/a3k9xm", HTTP_HOST="go.mkdrealtor.com")
response = self.client.get("/a3k9xm", HTTP_HOST="piha.lc")
self.assertEqual(response.status_code, 404)
def test_expired_404(self):
self.link.expires_at = timezone.now() - timedelta(minutes=1)
self.link.save()
response = self.client.get("/a3k9xm", HTTP_HOST="go.mkdrealtor.com")
response = self.client.get("/a3k9xm", HTTP_HOST="piha.lc")
self.assertEqual(response.status_code, 404)
def test_unknown_404(self):
response = self.client.get("/zzzzzz", HTTP_HOST="go.mkdrealtor.com")
response = self.client.get("/zzzzzz", HTTP_HOST="piha.lc")
self.assertEqual(response.status_code, 404)
def test_invalid_code_shape_404(self):
response = self.client.get("/AB", HTTP_HOST="go.mkdrealtor.com")
response = self.client.get("/AB", HTTP_HOST="piha.lc")
self.assertEqual(response.status_code, 404)
def test_public_root_is_landing(self):
response = self.client.get("/", HTTP_HOST="go.mkdrealtor.com")
response = self.client.get("/", HTTP_HOST="piha.lc")
self.assertEqual(response.status_code, 200)
self.assertContains(response, "URL Shortening Service")
self.assertContains(response, "piha.lc")
self.assertContains(response, "Request access")
self.assertContains(response, "aimloperations.com")
self.assertContains(response, "Contact")
self.assertNotContains(response, "Create a short link")
def test_click_row_and_count(self):
self.client.get(
"/a3k9xm",
HTTP_HOST="go.mkdrealtor.com",
HTTP_HOST="piha.lc",
HTTP_USER_AGENT="sms-client",
)
self.link.refresh_from_db()
@@ -296,7 +299,7 @@ class CreateTests(TestCase):
)
self.assertEqual(response.status_code, 201)
body = _json(response)
self.assertTrue(body["short_url"].startswith("https://go.mkdrealtor.com/"))
self.assertTrue(body["short_url"].startswith("https://piha.lc/"))
self.assertNotIn("testserver", body["short_url"])
def test_idempotent_same_target_and_external_ref(self):
@@ -349,9 +352,9 @@ class CreateTests(TestCase):
self.assertEqual(first.status_code, 200)
self.assertEqual(second.status_code, 200)
self.assertFalse(_json(second)["is_active"])
self.client.get(f"/{code}", HTTP_HOST="go.mkdrealtor.com")
self.client.get(f"/{code}", HTTP_HOST="piha.lc")
# disabled → no redirect
response = self.client.get(f"/{code}", HTTP_HOST="go.mkdrealtor.com")
response = self.client.get(f"/{code}", HTTP_HOST="piha.lc")
self.assertEqual(response.status_code, 404)
@@ -379,12 +382,12 @@ class UseCaseTests(TestCase):
self.assertEqual(create.status_code, 201)
body = _json(create)
self.assertEqual(
body["short_url"], f"https://go.mkdrealtor.com/{body['code']}"
body["short_url"], f"https://piha.lc/{body['code']}"
)
follow = self.client.get(
f"/{body['code']}",
HTTP_HOST="go.mkdrealtor.com",
HTTP_HOST="piha.lc",
follow=False,
)
self.assertEqual(follow.status_code, 302)
@@ -408,7 +411,7 @@ class DebugCreateTests(TestCase):
@override_settings(DEBUG=True)
def test_hidden_on_public_short_host_even_in_debug(self):
response = self.client.get("/debug/", HTTP_HOST="go.mkdrealtor.com")
response = self.client.get("/debug/", HTTP_HOST="piha.lc")
self.assertEqual(response.status_code, 404)
@override_settings(DEBUG=True)
@@ -494,7 +497,7 @@ class AdminTests(TestCase):
def test_admin_404_on_public_hosts(self):
self.client.logout()
response = self.client.get("/admin/", HTTP_HOST="go.mkdrealtor.com")
response = self.client.get("/admin/", HTTP_HOST="piha.lc")
self.assertEqual(response.status_code, 404)
response = self.client.get("/admin/", HTTP_HOST="shortener.example.com")
self.assertEqual(response.status_code, 404)