mirror of
https://github.com/Sea-Haven-Industries/meal-order-manager.git
synced 2026-09-30 10:03:13 +00:00
* feat(api): serve meals on ECS Fargate instead of Lambda Keep the Flask app always-on with in-process jobs so CloudFront no longer fronts a cold-start API Gateway. * fix(jobs): run delayed close and reminder deliveries Wall-clock skip windows dropped the only weekly SQS attempt when Scheduler already fired in Eastern time. Dev schedules stay disabled. * fix(api): return JSON objects and stop logging job payloads Flask now jsonify-s handler dicts so API responses are not HTML, and the worker logs only event and status. * fix(ci): restore the reusable workflow so the required check is named ci / ci Inlining the job reported `ci` instead of the org ruleset's `ci / ci`. * fix(secrets): drop unused os import so ruff check passes * style: apply ruff format so ci-python-app lint passes * fix(infra): give meals its own VPC because prod has none * chore(security): re-key ALB SG checkov suppression after vpc.tf
47 lines
1.5 KiB
Python
47 lines
1.5 KiB
Python
"""Flask app health and CORS preflight."""
|
|
|
|
import os
|
|
|
|
os.environ.setdefault("AWS_DEFAULT_REGION", "us-east-1")
|
|
os.environ.setdefault("TABLE_NAME", "test-orders-table")
|
|
|
|
from server.app import create_app
|
|
|
|
|
|
def test_health_returns_stage_and_sha(monkeypatch):
|
|
monkeypatch.setenv("STAGE", "local")
|
|
monkeypatch.setenv("GIT_SHA", "abc123")
|
|
client = create_app().test_client()
|
|
response = client.get("/api/health")
|
|
assert response.status_code == 200
|
|
assert response.get_json() == {"stage": "local", "sha": "abc123"}
|
|
|
|
|
|
def test_options_preflight_from_portal_origin():
|
|
client = create_app().test_client()
|
|
response = client.options(
|
|
"/api/submit-order",
|
|
headers={"Origin": "https://internal.seahaven.com"},
|
|
)
|
|
assert response.status_code == 204
|
|
assert (
|
|
response.headers["Access-Control-Allow-Origin"]
|
|
== "https://internal.seahaven.com"
|
|
)
|
|
assert "Authorization" in response.headers["Access-Control-Allow-Headers"]
|
|
|
|
|
|
def test_api_dispatch_jsonifies_handler_body():
|
|
from unittest.mock import patch
|
|
|
|
with patch("server.http_api.lambda_handler") as mock_handler:
|
|
mock_handler.return_value = {
|
|
"statusCode": 400,
|
|
"headers": {"Content-Type": "application/json"},
|
|
"body": '{"error": "Bad request"}',
|
|
}
|
|
client = create_app().test_client()
|
|
response = client.get("/api/menu")
|
|
assert response.status_code == 400
|
|
assert response.get_json() == {"error": "Bad request"}
|
|
assert response.content_type.startswith("application/json")
|