feat: 다른 사이트에 붙이는 날씨각 위젯 — 누구나 붙이는 카드(/embed/card, 기본형·상세형, 배경 3종)와 사용 방법 페이지(/widget, 스크립트·iframe 코드)
- 카드: 군산각 카드를 옮겨 그림, 토끼 로딩, 실패하면 '날씨각에서 날씨 보기' 링크, 8초 제한, nginx 대체 화면, '자세히 보기' 버튼만 링크 - 크기: 폭은 자리에 맞춰 자동, 높이는 폭에 따라 비율대로(기본형 245~320px, 상세형 400~520px) - 부하: 지역별 카드 데이터 5분 저장, 저장분이 비면 지역마다 한 요청만 새로 만듦, 노출 수는 Redis 에 쌓았다가 관리자 조회 때 DB(widget_view_daily)로 옮김 - 사용 방법 페이지: 지역(앱 지역은 바꾸지 않음)·모양·배경 고르기, 미리보기, 코드 복사. 들어오는 길은 문의 창 버튼(토스에서는 숨김)과 검색 - GA: 위젯_안내_보기, 위젯_옵션_고름, 위젯_코드_복사 - 문서: docs/위젯_운영.md, 백엔드 테스트 실행법(CLAUDE.md)
This commit is contained in:
1 parent
1a98adc155
commit
dc8201e5f5
38 files changed
+4219
-28
No files matched your search
@@ -0,0 +1,39 @@
|
||||
from services.embed_referer import UNKNOWN_HOST, normalize_host, view_host
|
||||
|
||||
OWN = frozenset({"weather.o2o.kr", "localhost:8080"})
|
||||
|
||||
|
||||
def test_normalize_host_trims_address_to_host():
|
||||
assert normalize_host("https://Co.WebForAI.kr/s/stay") == "co.webforai.kr"
|
||||
assert normalize_host(" gunsan.webforai.kr ") == "gunsan.webforai.kr"
|
||||
assert normalize_host("www.example.co.kr") == "www.example.co.kr"
|
||||
assert normalize_host("my-shop.example.co.kr") == "my-shop.example.co.kr"
|
||||
|
||||
|
||||
def test_normalize_host_rejects_what_cannot_go_in_a_header():
|
||||
for bad in ("", "localhost", "exa mple.com", "a.com; script-src *", "https://a.com:8443", "1.2.3.4", "*.example.com", "a..com", "'self'", "-a.com", "a-.com", "a.-b.kr"):
|
||||
assert normalize_host(bad) is None, bad
|
||||
|
||||
|
||||
def test_normalize_host_length_limits():
|
||||
assert normalize_host("a" * 63 + ".example.com") == "a" * 63 + ".example.com"
|
||||
assert normalize_host("a" * 64 + ".example.com") is None
|
||||
ok = ".".join(["a" * 63, "b" * 63, "c" * 63, "d" * 58]) + ".kr" # 253자
|
||||
assert len(ok) == 253 and normalize_host(ok) == ok
|
||||
assert normalize_host(".".join(["a" * 63, "b" * 63, "c" * 63, "d" * 59]) + ".kr") is None # 254자
|
||||
|
||||
|
||||
def test_view_host_takes_site_host():
|
||||
assert view_host("https://co.webforai.kr/s/stay", OWN) == "co.webforai.kr"
|
||||
assert view_host("http://Blog.Example.com:8080/a", OWN) == "blog.example.com"
|
||||
|
||||
|
||||
def test_view_host_self_is_not_counted():
|
||||
assert view_host("https://weather.o2o.kr/widget", OWN) is None
|
||||
assert view_host("http://localhost:8080/widget", OWN) is None
|
||||
|
||||
|
||||
def test_view_host_unknown():
|
||||
for bad in (None, "", "null", "about:blank", "android-app://com.example/", "https://", "not a url",
|
||||
"https://1.2.3.4/", "https://a.com; x/", "https://" + "a" * 300 + ".com/"):
|
||||
assert view_host(bad, OWN) == UNKNOWN_HOST, bad
|
||||
Reference in new issue
Block a user