fix(titiler): drop @1x suffix + append SAS token top-level
TiTiler /tiles/{z}/{x}/{y} takes a strict int for y; the @1x scale-suffix
template 422s on every SAR tile request (int_parsing on '21@1x').
sign_cog_url wrapped the Planetary Computer SAS token under a single
token= param, which Azure rejects (403→409); the token is a pre-encoded
query string and must be appended top-level (st=…&se=…&sig=…).
Proven live: correct-form URL renders a 200 image/png 256px tile.
This commit is contained in:
parent
405845067e
commit
68e1b63421
2 changed files with 19 additions and 12 deletions
|
|
@ -661,18 +661,19 @@ def test_planespotters_headers_add_contact_when_ua_is_generic(monkeypatch):
|
|||
# ── Sentinel-1 SAR (Planetary Computer STAC → signed COG template) ────────
|
||||
|
||||
def test_sign_cog_url_appends_token():
|
||||
assert sign_cog_url("https://blob.example/x.tif", "tok=abc") == \
|
||||
"https://blob.example/x.tif?token=tok%3Dabc"
|
||||
# PC returns the token pre-encoded as a query string; append verbatim.
|
||||
assert sign_cog_url("https://blob.example/x.tif", "st=s&se=e&sig=x%3D") == \
|
||||
"https://blob.example/x.tif?st=s&se=e&sig=x%3D"
|
||||
# Existing query string → append with &
|
||||
assert sign_cog_url("https://blob.example/x.tif?st=1", "tok") == \
|
||||
"https://blob.example/x.tif?st=1&token=tok"
|
||||
assert sign_cog_url("https://blob.example/x.tif?foo=1", "st=s&sig=x") == \
|
||||
"https://blob.example/x.tif?foo=1&st=s&sig=x"
|
||||
|
||||
|
||||
def test_sentinel1_tile_url_contains_titiler_rescale_and_cfastie():
|
||||
signed = "https://blob.example/x.tif?token=secret"
|
||||
url = sentinel1_tile_url(signed)
|
||||
assert url.startswith(TITILER_COG_TILES + "?")
|
||||
assert "WebMercatorQuad/{z}/{x}/{y}@1x" in url
|
||||
assert "WebMercatorQuad/{z}/{x}/{y}?" in url
|
||||
assert "url=https%3A%2F%2Fblob.example%2Fx.tif%3Ftoken%3Dsecret" in url
|
||||
assert "rescale=0%2C500" in url
|
||||
assert "colormap_name=cfastie" in url
|
||||
|
|
@ -723,12 +724,12 @@ def test_fetch_sentinel1_vv_signed_tile_url(monkeypatch):
|
|||
assert out["opacity"] == 0.8
|
||||
assert out["itemId"].startswith("S1A")
|
||||
assert out["attribution"] == SENTINEL1_ATTRIBUTION
|
||||
assert "WebMercatorQuad/{z}/{x}/{y}@1x" in out["tileUrl"]
|
||||
assert "WebMercatorQuad/{z}/{x}/{y}?" in out["tileUrl"]
|
||||
assert "rescale=0%2C500" in out["tileUrl"]
|
||||
assert "colormap_name=cfastie" in out["tileUrl"]
|
||||
# SAS token "sig=abc123" is signed as ?token=sig%3Dabc123, then the whole
|
||||
# COG URL is percent-encoded again as a query param (=> sig%253Dabc123).
|
||||
assert "sig%253Dabc123" in out["tileUrl"]
|
||||
# SAS token "sig=abc123" is appended top-level, then the whole COG URL is
|
||||
# percent-encoded again as a query param (=> sig%3Dabc123).
|
||||
assert "sig%3Dabc123" in out["tileUrl"]
|
||||
# STAC search payload shape
|
||||
post_url, post_json = calls[0][1], calls[0][2]
|
||||
assert post_url.endswith("/api/stac/v1/search")
|
||||
|
|
|
|||
Loading…
Reference in a new issue