chore: ignore dokploy shots and add chat/traefik ops smokes
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
77
scripts/smoke_chat_auth.py
Normal file
77
scripts/smoke_chat_auth.py
Normal file
@@ -0,0 +1,77 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Authenticated chat smoke on app.4ventures.es."""
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
import re
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
from playwright.sync_api import sync_playwright
|
||||
|
||||
ROOT = Path("/Users/4ventures/4ventures-client-portal")
|
||||
APP = "https://app.4ventures.es"
|
||||
CREDS = ROOT / ".ops" / "marketing-credentials.txt"
|
||||
|
||||
|
||||
def main() -> int:
|
||||
email, password = "marketing@4ventures.es", ""
|
||||
for line in CREDS.read_text().splitlines():
|
||||
if line.startswith("email="):
|
||||
email = line.split("=", 1)[1].strip()
|
||||
if line.startswith("password="):
|
||||
password = line.split("=", 1)[1].strip()
|
||||
|
||||
with sync_playwright() as p:
|
||||
browser = p.chromium.launch(headless=True)
|
||||
page = browser.new_page(viewport={"width": 1400, "height": 1000})
|
||||
page.goto(f"{APP}/login", wait_until="networkidle", timeout=90000)
|
||||
page.locator('input[type="email"], input[name="email"]').first.fill(email)
|
||||
page.locator('input[type="password"]').first.fill(password)
|
||||
page.locator('button[type="submit"]').first.click()
|
||||
page.wait_for_timeout(3500)
|
||||
if "/login" in page.url:
|
||||
print("LOGIN_FAILED", flush=True)
|
||||
browser.close()
|
||||
return 2
|
||||
|
||||
# unauth baseline via fresh context later; here authenticated
|
||||
res = page.evaluate(
|
||||
"""async () => {
|
||||
const r = await fetch('/api/chat', {
|
||||
method: 'POST',
|
||||
headers: {'content-type':'application/json'},
|
||||
body: JSON.stringify({ message: 'hola' })
|
||||
});
|
||||
const text = await r.text();
|
||||
let json = null;
|
||||
try { json = JSON.parse(text); } catch {}
|
||||
return { status: r.status, text: text.slice(0, 300), json };
|
||||
}"""
|
||||
)
|
||||
print("auth_chat", json.dumps(res, ensure_ascii=False)[:500], flush=True)
|
||||
browser.close()
|
||||
|
||||
# unauth
|
||||
import urllib.error
|
||||
import urllib.request
|
||||
|
||||
req = urllib.request.Request(
|
||||
f"{APP}/api/chat",
|
||||
data=b'{"message":"hola"}',
|
||||
method="POST",
|
||||
headers={"Content-Type": "application/json"},
|
||||
)
|
||||
try:
|
||||
with urllib.request.urlopen(req, timeout=15) as r:
|
||||
print("unauth_chat", r.status, r.read()[:80], flush=True)
|
||||
except urllib.error.HTTPError as e:
|
||||
print("unauth_chat", e.code, e.read()[:80], flush=True)
|
||||
|
||||
ok = res.get("status") == 200 and isinstance(res.get("json"), list)
|
||||
print("SUCCESS" if ok else "PARTIAL", flush=True)
|
||||
return 0 if ok else 5
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
raise SystemExit(main())
|
||||
Reference in New Issue
Block a user