@@ -14,6 +14,15 @@ def test_stac_api(stac_endpoint):
1414 # Ping
1515 assert client .get (f"{ stac_endpoint } /_mgmt/ping" ).status_code == 200
1616
17+ # Landing page
18+ resp = client .get (stac_endpoint )
19+ assert resp .status_code == 200
20+ landing = resp .json ()
21+ # Verify landing page links have correct base path
22+ for link in landing ["links" ]:
23+ if link ["href" ].startswith ("/" ):
24+ assert link ["href" ].startswith (stac_endpoint .split ("://" )[1 ])
25+
1726 # viewer
1827 #assert client.get(f"{stac_endpoint}/index.html").status_code == 200
1928 assert client .get (f"{ stac_endpoint } /index.html" ).status_code == 404
@@ -26,11 +35,21 @@ def test_stac_api(stac_endpoint):
2635 ids = [c ["id" ] for c in collections ]
2736 assert "noaa-emergency-response" in ids
2837
38+ # Verify collection links have correct base path
39+ for collection in collections :
40+ for link in collection ["links" ]:
41+ if link ["href" ].startswith ("/" ):
42+ assert link ["href" ].startswith (stac_endpoint .split ("://" )[1 ])
43+
2944 # items
3045 resp = client .get (f"{ stac_endpoint } /collections/noaa-emergency-response/items" )
3146 assert resp .status_code == 200
32- items = resp .json ()["features" ]
33- assert len (items ) == 10
47+ items = resp .json ()
48+ # Verify item links have correct base path
49+ for feature in items ["features" ]:
50+ for link in feature ["links" ]:
51+ if link ["href" ].startswith ("/" ):
52+ assert link ["href" ].startswith (stac_endpoint .split ("://" )[1 ])
3453
3554 # item
3655 resp = client .get (
@@ -51,6 +70,45 @@ def test_stac_to_raster(stac_endpoint):
5170 #assert resp.status_code == 307
5271 assert resp .status_code == 404
5372
73+ def test_stac_custom_path (stac_endpoint ):
74+ """test stac with custom ingress path."""
75+ # If we're using a custom path (e.g., /api instead of /stac)
76+ base_path = stac_endpoint .split ("://" )[1 ]
77+
78+ # Landing page
79+ resp = client .get (stac_endpoint )
80+ assert resp .status_code == 200
81+ landing = resp .json ()
82+
83+ # All links should use the custom path
84+ for link in landing ["links" ]:
85+ if link ["href" ].startswith ("/" ):
86+ assert link ["href" ].startswith (base_path ), \
87+ f"Link { link ['href' ]} doesn't start with { base_path } "
88+
89+ # Collections should also use the custom path
90+ resp = client .get (f"{ stac_endpoint } /collections" )
91+ assert resp .status_code == 200
92+ collections = resp .json ()["collections" ]
93+
94+ for collection in collections :
95+ for link in collection ["links" ]:
96+ if link ["href" ].startswith ("/" ):
97+ assert link ["href" ].startswith (base_path ), \
98+ f"Collection link { link ['href' ]} doesn't start with { base_path } "
99+
100+ # Test a specific item
101+ resp = client .get (f"{ stac_endpoint } /collections/noaa-emergency-response/items" )
102+ assert resp .status_code == 200
103+ items = resp .json ()
104+
105+ # Item links should also use the custom path
106+ for feature in items ["features" ]:
107+ for link in feature ["links" ]:
108+ if link ["href" ].startswith ("/" ):
109+ assert link ["href" ].startswith (base_path ), \
110+ f"Item link { link ['href' ]} doesn't start with { base_path } "
111+
54112 # viewer
55113 resp = client .get (
56114 f"{ stac_endpoint } /collections/noaa-emergency-response/items/20200307aC0853300w361200/viewer" ,
0 commit comments