Skip to content

Commit 0f4c94e

Browse files
committed
[netrid] Check response validity when calling all_flights
1 parent bac22cb commit 0f4c94e

File tree

4 files changed

+107
-30
lines changed

4 files changed

+107
-30
lines changed

monitoring/uss_qualifier/scenarios/astm/netrid/common/misbehavior.py

Lines changed: 28 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -178,18 +178,38 @@ def poll_func(rect: LatLngRect) -> bool:
178178
poll_func,
179179
)
180180

181+
def _is_area_too_large(self, rect: s2sphere.LatLngRect) -> bool:
182+
diagonal_km = (
183+
rect.lo().get_distance(rect.hi()).degrees * geo.EARTH_CIRCUMFERENCE_KM / 360
184+
)
185+
return diagonal_km > self._rid_version.max_diagonal_km
186+
181187
def _fetch_flights_from_dss(self, rect: LatLngRect) -> dict[str, TelemetryMapping]:
182188
# We grab all flights from the SPs (which we know how to reach by first querying the DSS).
183189
# This is authenticated and is expected to succeed
184190
# TODO: Add the following requests to the documentation. Possibly split it as a test step.
185-
sp_observation = rid.all_flights(
186-
rect,
187-
include_recent_positions=True,
188-
get_details=False,
189-
rid_version=self._rid_version,
190-
session=self._dss.client,
191-
dss_participant_id=self._dss.participant_id,
192-
)
191+
192+
with self.check("ISA query", [self._dss.participant_id]) as check:
193+
sp_observation = rid.all_flights(
194+
rect,
195+
include_recent_positions=True,
196+
get_details=False,
197+
rid_version=self._rid_version,
198+
session=self._dss.client,
199+
dss_participant_id=self._dss.participant_id,
200+
)
201+
202+
self.record_queries(sp_observation.queries)
203+
204+
if not sp_observation.success and not self._is_area_too_large(rect):
205+
check.record_failed(
206+
summary="Could not query ISAs from DSS",
207+
details=f"Query to {self._dss.participant_id}'s DSS at failed: {', '.join(sp_observation.errors)}",
208+
query_timestamps=[
209+
query.request.initiated_at.datetime
210+
for query in sp_observation.queries
211+
],
212+
)
193213

194214
mapping_by_injection_id = (
195215
display_data_evaluator.map_fetched_to_injected_flights(
@@ -198,7 +218,6 @@ def _fetch_flights_from_dss(self, rect: LatLngRect) -> dict[str, TelemetryMappin
198218
self._query_cache,
199219
)
200220
)
201-
self.record_queries(sp_observation.queries)
202221

203222
return mapping_by_injection_id
204223

monitoring/uss_qualifier/scenarios/astm/netrid/display_data_evaluator.py

Lines changed: 55 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -275,23 +275,37 @@ def evaluate_system_instantaneously(
275275
self._test_scenario.begin_test_step("Service Provider polling")
276276

277277
# Observe Service Provider with uss_qualifier acting as a Display Provider
278-
sp_observation = all_flights(
279-
rect,
280-
include_recent_positions=True,
281-
get_details=True,
282-
rid_version=self._rid_version,
283-
session=self._dss.client,
284-
dss_participant_id=self._dss.participant_id,
285-
)
278+
with self._test_scenario.check(
279+
"ISA query", [self._dss.participant_id]
280+
) as check:
281+
sp_observation = all_flights(
282+
rect,
283+
include_recent_positions=True,
284+
get_details=True,
285+
rid_version=self._rid_version,
286+
session=self._dss.client,
287+
dss_participant_id=self._dss.participant_id,
288+
)
289+
290+
for q in sp_observation.queries:
291+
self._test_scenario.record_query(q)
292+
293+
if not sp_observation.success and not self._is_area_too_large(rect):
294+
check.record_failed(
295+
summary="Could not query ISAs from DSS",
296+
details=f"Query to {self._dss.participant_id}'s DSS at failed: {', '.join(sp_observation.errors)}",
297+
query_timestamps=[
298+
query.request.initiated_at.datetime
299+
for query in sp_observation.queries
300+
],
301+
)
286302

287303
# map observed flights to injected flight and attribute participant ID
288304
mapping_by_injection_id = map_fetched_to_injected_flights(
289305
self._injected_flights,
290306
list(sp_observation.uss_flight_queries.values()),
291307
self._query_cache,
292308
)
293-
for q in sp_observation.queries:
294-
self._test_scenario.record_query(q)
295309

296310
# Evaluate observations
297311
self._evaluate_sp_observation(rect, sp_observation, mapping_by_injection_id)
@@ -325,6 +339,12 @@ def evaluate_system_instantaneously(
325339
# TODO: If bounding rect is smaller than area-too-large threshold, expand slightly above area-too-large threshold and re-observe
326340
self._test_scenario.end_test_step()
327341

342+
def _is_area_too_large(self, rect: s2sphere.LatLngRect) -> bool:
343+
diagonal_km = (
344+
rect.lo().get_distance(rect.hi()).degrees * geo.EARTH_CIRCUMFERENCE_KM / 360
345+
)
346+
return diagonal_km > self._rid_version.max_diagonal_km
347+
328348
def _evaluate_observation(
329349
self,
330350
observer: RIDSystemObserver,
@@ -336,7 +356,7 @@ def _evaluate_observation(
336356
diagonal_km = (
337357
rect.lo().get_distance(rect.hi()).degrees * geo.EARTH_CIRCUMFERENCE_KM / 360
338358
)
339-
if diagonal_km > self._rid_version.max_diagonal_km:
359+
if self._is_area_too_large(rect):
340360
self._evaluate_area_too_large_observation(
341361
observer, rect, diagonal_km, query
342362
)
@@ -1061,23 +1081,37 @@ def evaluate_disconnected_flights(
10611081
self._test_scenario.begin_test_step("Service Provider polling")
10621082

10631083
# Observe Service Provider with uss_qualifier acting as a Display Provider
1064-
sp_observation = all_flights(
1065-
rect,
1066-
include_recent_positions=True,
1067-
get_details=False,
1068-
rid_version=self._rid_version,
1069-
session=self._dss.client,
1070-
dss_participant_id=self._dss.participant_id,
1071-
)
1084+
with self._test_scenario.check(
1085+
"ISA query", [self._dss.participant_id]
1086+
) as check:
1087+
sp_observation = all_flights(
1088+
rect,
1089+
include_recent_positions=True,
1090+
get_details=False,
1091+
rid_version=self._rid_version,
1092+
session=self._dss.client,
1093+
dss_participant_id=self._dss.participant_id,
1094+
)
1095+
1096+
for q in sp_observation.queries:
1097+
self._test_scenario.record_query(q)
1098+
1099+
if not sp_observation.success:
1100+
check.record_failed(
1101+
summary="Could not query ISAs from DSS",
1102+
details=f"Query to {self._dss.participant_id}'s DSS at failed: {', '.join(sp_observation.errors)}",
1103+
query_timestamps=[
1104+
query.request.initiated_at.datetime
1105+
for query in sp_observation.queries
1106+
],
1107+
)
10721108

10731109
# map observed flights to injected flight and attribute participant ID
10741110
mapping_by_injection_id = map_fetched_to_injected_flights(
10751111
self._injected_flights,
10761112
list(sp_observation.uss_flight_queries.values()),
10771113
self._query_cache,
10781114
)
1079-
for q in sp_observation.queries:
1080-
self._test_scenario.record_query(q)
10811115

10821116
# Evaluate observations
10831117
self._evaluate_sp_observation(sp_observation, mapping_by_injection_id)

monitoring/uss_qualifier/scenarios/astm/netrid/v19/misbehavior.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,10 @@ This particular test requires each flight to be uniquely identifiable by its 2D
4343

4444
This step will attempt to search for flights in a rectangular area with a diagonal greater than [NetMaxDisplayAreaDiagonal] km.
4545

46+
#### ⚠️ ISA query check
47+
48+
**[interuss.f3411.dss_endpoints.SearchISAs](../../../../../requirements/interuss/f3411/dss_endpoints.md)** requires a USS providing a DSS instance to implement the DSS endpoints of the OpenAPI specification. If uss_qualifier is unable to query the DSS for ISAs, this check will fail.
49+
4650
#### ⚠️ Area too large check
4751

4852
**[astm.f3411.v19.NET0250](../../../../requirements/astm/f3411/v19.md)** requires that a NetRID Service Provider rejects a request for a very large view area with a diagonal greater than *NetMaxDisplayAreaDiagonal*. If such a large view is requested and a 400 or 413 error code is not received or the response contains Remote ID data, then this check will fail.
@@ -54,6 +58,10 @@ to confirm that the requested data is indeed available to any authorized query.
5458

5559
It then repeats the exact same request without credentials, and expects this to fail.
5660

61+
#### ⚠️ ISA query check
62+
63+
**[interuss.f3411.dss_endpoints.SearchISAs](../../../../../requirements/interuss/f3411/dss_endpoints.md)** requires a USS providing a DSS instance to implement the DSS endpoints of the OpenAPI specification. If uss_qualifier is unable to query the DSS for ISAs, this check will fail.
64+
5765
#### ⚠️ Missing credentials check
5866

5967
This check ensures that all requests are properly authenticated, as required by **[astm.f3411.v19.NET0210](../../../../requirements/astm/f3411/v19.md)**,
@@ -63,6 +71,10 @@ and that requests for existing flights that are executed with missing credential
6371

6472
This step is similar to unauthenticated requests, but uses incorrectly-authenticated requests instead.
6573

74+
#### ⚠️ ISA query check
75+
76+
**[interuss.f3411.dss_endpoints.SearchISAs](../../../../../requirements/interuss/f3411/dss_endpoints.md)** requires a USS providing a DSS instance to implement the DSS endpoints of the OpenAPI specification. If uss_qualifier is unable to query the DSS for ISAs, this check will fail.
77+
6678
#### ⚠️ Invalid credentials check
6779
This check ensures that all requests are properly authenticated, as required by **[astm.f3411.v19.NET0210](../../../../requirements/astm/f3411/v19.md)**,
6880
and that requests for existing flights that are executed with incorrect credentials fail.

monitoring/uss_qualifier/scenarios/astm/netrid/v22a/misbehavior.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@ A [`DSSInstanceResource`](../../../../resources/astm/f3411/dss.py) is required f
3030

3131
This step will attempt to search for flights in a rectangular area with a diagonal greater than [NetMaxDisplayAreaDiagonal] km.
3232

33+
#### ⚠️ ISA query check
34+
35+
**[interuss.f3411.dss_endpoints.SearchISAs](../../../../../requirements/interuss/f3411/dss_endpoints.md)** requires a USS providing a DSS instance to implement the DSS endpoints of the OpenAPI specification. If uss_qualifier is unable to query the DSS for ISAs, this check will fail.
36+
3337
#### ⚠️ Area too large check
3438

3539
**[astm.f3411.v22a.NET0250](../../../../requirements/astm/f3411/v22a.md)** requires that a NetRID Service Provider rejects a request for a very large view area with a diagonal greater than *NetMaxDisplayAreaDiagonal*. If such a large view is requested and a 400 or 413 error code is not received or the response contains Remote ID data, then this check will fail.
@@ -41,6 +45,10 @@ to confirm that the requested data is indeed available to any authorized query.
4145

4246
It then repeats the exact same request without credentials, and expects this to fail.
4347

48+
#### ⚠️ ISA query check
49+
50+
**[interuss.f3411.dss_endpoints.SearchISAs](../../../../../requirements/interuss/f3411/dss_endpoints.md)** requires a USS providing a DSS instance to implement the DSS endpoints of the OpenAPI specification. If uss_qualifier is unable to query the DSS for ISAs, this check will fail.
51+
4452
#### ⚠️ Missing credentials check
4553

4654
This check ensures that all requests are properly authenticated, as required by **[astm.f3411.v22a.NET0210](../../../../requirements/astm/f3411/v22a.md)**,
@@ -50,6 +58,10 @@ and that requests for existing flights that are executed with missing credential
5058

5159
This step is similar to unauthenticated requests, but uses incorrectly-authenticated requests instead.
5260

61+
#### ⚠️ ISA query check
62+
63+
**[interuss.f3411.dss_endpoints.SearchISAs](../../../../../requirements/interuss/f3411/dss_endpoints.md)** requires a USS providing a DSS instance to implement the DSS endpoints of the OpenAPI specification. If uss_qualifier is unable to query the DSS for ISAs, this check will fail.
64+
5365
#### ⚠️ Invalid credentials check
5466

5567
This check ensures that all requests are properly authenticated, as required by **[astm.f3411.v22a.NET0210](../../../../requirements/astm/f3411/v22a.md)**,

0 commit comments

Comments
 (0)