Skip to content

detect conformance classes correctly #43

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
79 changes: 51 additions & 28 deletions COMPLIANCE_REPORT.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

This document shows how well several popular STAC API implementations conform to STAC API.

Many (if not all) of these API are in production use, so the fact that they have validation problems
Many (if not all) of these APIs are in production use, so the fact that they have validation problems
should not be seen as a significant concern. This validation suite is quite strict, so it finds
many obscure issues that can usually be worked around. Many of the defects are around the
correct advertisement of conformance classes and links to support hypermedia, and these more "advanced"
capabilities are only now starting to be fully used in tools like pystac-client.

## Open Source
## Open Source Implementations

### stac-fastapi - sqlalchemy

Expand Down Expand Up @@ -56,9 +56,31 @@ errors:
- POST Search with {'ids': ['fe916452-ba6f-4631-9154-c249924a122d', 'f7f164c9-cfdf-436d-a3f0-69864c38ba2a']} returned items with ids other than specified one
```

### stac-fastapi - Planetary Computer
### stac-fastapi-elasticsearch

based on stac-fastapi
TBD.

### Franklin

TBD.

### stac-server

TBD.

### resto

TBD.

### stac-cmr

### staccato

Non-compliant with 1.0.0-x

## Server Instances

### Microsoft Planetary Computer (stac-fastapi)

URL: https://planetarycomputer.microsoft.com/api/stac/v1/

Expand All @@ -85,7 +107,26 @@ errors:
- Search with datetime=37-01-01T12:00:27.87Z returned status code 500 instead of 400
```

# stac-cmr

### Snap Planet (resto)

URL: https://tamn.snapplanet.io/

Date: 19-Jan-2022

Output
```
Validating https://tamn.snapplanet.io/
STAC API - Core conformance class found.
STAC API - Features conformance class found.
STAC API - Item Search conformance class found.
warnings:
- Search with datetime=1985-04-12T23:20:50,52Z returned status code 200 instead of 400
errors:
- GET Search with {'limit': 10000} returned status code 400
```

### EarthData CMR (stac-cmr)

URL: https://cmr.earthdata.nasa.gov/stac/USGS_EROS

Expand Down Expand Up @@ -143,26 +184,8 @@ errors:
- Search with datetime=2020-07-23T00:00:00.012345678Z returned status code 400
```

# resto

URL: https://tamn.snapplanet.io/

Date: 19-Jan-2022

Output
```
Validating https://tamn.snapplanet.io/
STAC API - Core conformance class found.
STAC API - Features conformance class found.
STAC API - Item Search conformance class found.
warnings:
- Search with datetime=1985-04-12T23:20:50,52Z returned status code 200 instead of 400
errors:
- GET Search with {'limit': 10000} returned status code 400
```


# Landsat Look
### Landsat Look (stac-server)

URL: https://landsatlook.usgs.gov/stac-server

Expand Down Expand Up @@ -228,7 +251,8 @@ errors:
- Search with datetime=1990-12-31T23:59:61Z returned status code 404 instead of 400
```

# Franklin

### Franklin NASA HSI

URL: https://franklin.nasa-hsi.azavea.com/

Expand Down Expand Up @@ -273,7 +297,7 @@ errors:
- Search with datetime=2020-07-23T00:00:00+03:00 returned status code 400
```

# Staccato
### staccato.space

URL: https://staccato.space/

Expand All @@ -287,9 +311,8 @@ errors:
- / : 'conformsTo' must contain at least one STAC API conformance class.
```

## Proprietary

### Earth OnDemand
### EarthAI OnDemand

URL: https://eod-catalog-svc-prod.astraea.earth/

Expand Down
41 changes: 20 additions & 21 deletions stac_api_validator/validations.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,26 +12,25 @@

# resolve_stac_object

core_cc_regex = re.compile('https://api\.stacspec\.org/.+/core')
core_cc_regex = re.compile(r'https://api\.stacspec\.org/.+/core')

oaf_cc_regex = re.compile(
'https://api\.stacspec\.org/.+/ogcapi-features')
r'https://api\.stacspec\.org/.+/ogcapi-features')
oaf_transaction_cc_regex = re.compile(
'https://api\.stacspec\.org/.+/ogcapi-features/extensions/transaction')
r'https://api\.stacspec\.org/.+/ogcapi-features/extensions/transaction')
oaf_version_cc_regex = re.compile(
'https://api\.stacspec\.org/.+/ogcapi-features/extensions/version')
r'https://api\.stacspec\.org/.+/ogcapi-features/extensions/version')

search_cc_regex = re.compile('https://api\.stacspec\.org/.+/item-search')
search_cc_regex = re.compile(r'https://api\.stacspec\.org/.+/item-search')
search_fields_cc_regex = re.compile(
'https://api\.stacspec\.org/.+/item-search#fields')
r'https://api\.stacspec\.org/.+/item-search#fields')
search_contextsearch_fields_cc_regex_cc_regex = re.compile(
'https://api\.stacspec\.org/.+/item-search#context')
r'https://api\.stacspec\.org/.+/item-search#context')
search_sort_cc_regex = re.compile(
'https://api\.stacspec\.org/.+/item-search#sort')
r'https://api\.stacspec\.org/.+/item-search#sort')
search_query_cc_regex = re.compile(
'https://api\.stacspec\.org/.+/item-search#query')
r'https://api\.stacspec\.org/.+/item-search#query')

openapi_media_type = "application/vnd.oai.openapi+json;version=3.0"
geojson_mt = 'application/geo+json'
geojson_charset_mt = 'application/geo+json; charset=utf-8'

Expand Down Expand Up @@ -115,9 +114,9 @@ def validate_api(root_url: str, post: bool) -> Tuple[List[str], List[str]]:
errors.append("/ : 'links' field must be defined and non-empty.")

if conforms_to and \
not any(core_cc_regex.match(x) for x in conforms_to) and \
not any(oaf_cc_regex.match(x) for x in conforms_to) and \
not any(search_cc_regex.match(x) for x in conforms_to):
not any(core_cc_regex.fullmatch(x) for x in conforms_to) and \
not any(oaf_cc_regex.fullmatch(x) for x in conforms_to) and \
not any(search_cc_regex.fullmatch(x) for x in conforms_to):
errors.append(
"/ : 'conformsTo' must contain at least one STAC API conformance class.")

Expand All @@ -130,18 +129,18 @@ def validate_api(root_url: str, post: bool) -> Tuple[List[str], List[str]]:
if errors:
return (warnings, errors)

if any(core_cc_regex.match(x) for x in conforms_to):
if any(core_cc_regex.fullmatch(x) for x in conforms_to):
print("STAC API - Core conformance class found.")
validate_core(root_body, warnings, errors)
else:
errors.append(
"/ : 'conformsTo' must contain STAC API - Core conformance class.")

if any(oaf_cc_regex.match(x) for x in conforms_to):
if any(oaf_cc_regex.fullmatch(x) for x in conforms_to):
print("STAC API - Features conformance class found.")
validate_oaf(root_body, warnings, errors)

if any(search_cc_regex.match(x) for x in conforms_to):
if any(search_cc_regex.fullmatch(x) for x in conforms_to):
print("STAC API - Item Search conformance class found.")
validate_search(root_body, post, conforms_to, warnings, errors)

Expand Down Expand Up @@ -235,7 +234,7 @@ def validate_oaf(root_body: Dict, warnings: List[str],
"conformance must return 200",
lambda: r_conformance.status_code == 200)

if (ct := r_conformance.headers.get('content-type')) == 'application/json':
if (ct := r_conformance.headers.get('content-type')).split(';')[0] == 'application/json':
pass
else:
errors.append(
Expand Down Expand Up @@ -300,7 +299,7 @@ def validate_search(root_body: Dict, post: bool, conforms_to: List,
errors.append(
f"Search ({search_url}): must return JSON, instead got non-JSON text")

if any(search_fields_cc_regex.match(x) for x in conforms_to):
if any(search_fields_cc_regex.fullmatch(x) for x in conforms_to):
print("STAC API - Item Search Fields extension conformance class found.")

context = r.json().get("context")
Expand Down Expand Up @@ -604,16 +603,16 @@ def validate_search_ids(
warnings: List[str],
errors: List[str]
):
r = requests.get(f"{search_url}?limit=10")
r = requests.get(f"{search_url}?limit=2")
items = r.json().get("features")
if items:
if items and len(items) >= 2:
_validate_search_ids_with_ids(search_url, [items[0].get("id")], post, errors)
_validate_search_ids_with_ids(
search_url, [items[0].get("id"), items[1].get("id")], post, errors)
_validate_search_ids_with_ids(
search_url, [i["id"] for i in items], post, errors)
else:
warnings.append(f"Get Search with no parameters returned zero results")
warnings.append(f"Get Search with no parameters returned < 2 results")


def _validate_search_collections_request(
Expand Down