Skip to content

Commit

Permalink
DSS0210 OIR Awareness (key must be correct)
Browse files Browse the repository at this point in the history
  • Loading branch information
Shastick committed Mar 11, 2024
1 parent 3269901 commit 71c2fd6
Show file tree
Hide file tree
Showing 16 changed files with 683 additions and 31 deletions.
20 changes: 20 additions & 0 deletions monitoring/monitorlib/fetch/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -459,6 +459,26 @@ def __init__(self, msg: str, queries: Optional[Union[Query, List[Query]]] = None
else:
self.queries = queries

@property
def last_status_code(self) -> int:
"""Returns the status code of the last query present in this QueryError,
or 999 if this error contains no queries."""
if len(self.queries) == 0:
return 999
return self.queries[-1].status_code

@property
def query_timestamps(self) -> List[datetime.datetime]:
"""Returns the timestamps of all queries present in this QueryError."""
return [q.request.timestamp for q in self.queries]

@property
def last_query(self) -> Optional[Query]:
"""Returns the last query present in this QueryError, or None if this error contains no queries."""
if len(self.queries) == 0:
return None
return self.queries[-1]

@property
def stacktrace(self) -> str:
return stacktrace_string(self)
Expand Down
11 changes: 11 additions & 0 deletions monitoring/monitorlib/schema_validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,17 @@ class F3548_21(str, Enum):
QuerySubscriptionsResponse = "components.schemas.QuerySubscriptionsResponse"
DeleteSubscriptionResponse = "components.schemas.DeleteSubscriptionResponse"

ChangeOperationalIntentReferenceResponse = (
"components.schemas.ChangeOperationalIntentReferenceResponse"
)
GetOperationalIntentReferenceResponse = (
"components.schemas.GetOperationalIntentReferenceResponse"
)
QueryOperationalIntentReferenceResponse = (
"components.schemas.QueryOperationalIntentReferenceResponse"
)
AirspaceConflictResponse = "components.schemas.AirspaceConflictResponse"


_openapi_content_cache: Dict[str, dict] = {}

Expand Down
2 changes: 1 addition & 1 deletion monitoring/prober/infrastructure.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ def wrapper_default_scope(*args, **kwargs):
resource_type_code_descriptions: Dict[ResourceType, str] = {}


# Next code: 380
# Next code: 383
def register_resource_type(code: int, description: str) -> ResourceType:
"""Register that the specified code refers to the described resource.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ v1:
dss: scd_dss
dss_instances: scd_dss_instances
id_generator: id_generator
utm_client_identity: utm_client_identity
second_utm_auth: second_utm_auth
planning_area: che_planning_area
problematically_big_area: che_problematically_big_area
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from .subscription_validation import SubscriptionValidation
from .subscription_simple import SubscriptionSimple
from .crdb_access import CRDBAccess
from .op_intent_ref_key_validation import OIRKeyValidation
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
# ASTM SCD DSS: Operational Intent Reference Key Validation test scenario

## Overview

Verifies that a DSS requires from a client creating or updating operational intent references that they
provide all OVNs for all currently relevant entities.

## Resources

### dss

[`DSSInstanceResource`](../../../../resources/astm/f3548/v21/dss.py) the DSS instance through which entities are created, modified and deleted.

### id_generator

[`IDGeneratorResource`](../../../../resources/interuss/id_generator.py) providing the base entity ID for this scenario.

### client_identity

[`ClientIdentityResource`](../../../../resources/communications/client_identity.py) the client identity that will be used to create and update operational intent references.

### planning_area

[`PlanningAreaResource`](../../../../resources/astm/f3548/v21/planning_area.py) describes the 3D volume in which operational intent references will be created.

## Setup test case

### [Ensure clean workspace test step](./clean_workspace.md)

This step ensures that no entities with the known test ID exists in the DSS.

## Key Validation test case

This test case will create multiple operational intent references and verify that the `key` field
of the parameters to create or update an operational intent reference is properly validated.

That is: the DSS should require that the client provide the OVNs for each entity that is in the vicinity,
both geographically and temporally, of the client's operational intent reference.

### Create non-overlapping OIRs test step

This first test step creates two operational intent references that do not overlap in time, and
should therefore both not require any entry in the `key` field.

#### 🛑 First operational intent reference in area creation query succeeds check

With no potentially conflicting entity present, the DSS is expected to allow the creation of an operational intent without
the client specifying any OVN in the `key` field.

If the DSS rejects a well-formed request to create the operational intent reference, it is in violation of **[astm.f3548.v21.DSS0005,1](../../../../requirements/astm/f3548/v21.md)**.

#### 🛑 Second, non-overlapping operational intent reference creation succeeds check

With a single existing OIR in the area that is not overlapping in time, the DSS is expected to allow the creation of an operational intent without
the client specifying any OVN in the `key` field.

If the DSS rejects a well-formed request to create the operational intent reference, it is in violation of **[astm.f3548.v21.DSS0005,1](../../../../requirements/astm/f3548/v21.md)**.

### Attempt creation of overlapping OIRs test step

This test step will attempt to create various operational intent references that intersect with either one or both of the previously created ones,
and expect the DSS to require the relevant OVNs to be provided in the `key` field.

Note that this step will optionally validate the response body of for `HTTP 409` error responses from the DSS when these contain the expected `missing_operational_intents` field.

At the end of this step, the DSS is expected to have accepted the creation of 3 operational intent references.

#### 🛑 Create operational intent reference with missing OVN fails check

If the DSS allows the creation of an operational intent reference that is missing the required OVNs for other entities that exist in its geo-temporal vicinity,
it is in violation of **[astm.f3548.v21.DSS0005,1](../../../../requirements/astm/f3548/v21.md)** and **[astm.f3548.v21.DSS0210,A2-7-2,2a](../../../../requirements/astm/f3548/v21.md)**

#### 🛑 Failure response due to conflict has proper format check

The DSS is expected to return a `HTTP 409` error response when the creation of an operational intent reference fails due to a conflict.
This response is expected to conform to the OpenAPI spec that is part of **[astm.f3548.v21.DSS0005,1](../../../../requirements/astm/f3548/v21.md)**.

Should this not be the case, then the DSS is in violation of the aforementioned requirement.

#### 🛑 Failure response due to conflict contains conflicting OIRs check

If the DSS returns a `HTTP 409` error response due to a conflict, and the response body contains a `missing_operational_intents` field,
this field is expected to contain the conflicting OVNs.

If the field exists but does not contain the conflicting OVNs, then the DSS is in violation of **[astm.f3548.v21.DSS0005,1](../../../../requirements/astm/f3548/v21.md)**.

#### 🛑 Create operational intent reference with proper OVNs succeeds check

If the DSS prevents the creation of an operational intent reference that is providing all required OVNs for other entities that exist in its geo-temporal vicinity,
it is in violation of **[astm.f3548.v21.DSS0005,1](../../../../requirements/astm/f3548/v21.md)**.

### Attempt mutation of operational intent reference to cause an overlap test step

This test step will attempt to mutate an existing operational intent reference so that it overlaps with an existing one.

The expectation is that the DSS will require the relevant OVNs to be provided in the `key` field.

#### 🛑 Mutate operational intent reference with missing OVN fails check

If the DSS allows the mutation of an operational intent reference that is missing the required OVNs for other entities that exist in its geo-temporal vicinity,
it is in violation of **[astm.f3548.v21.DSS0005,1](../../../../requirements/astm/f3548/v21.md)** and **[astm.f3548.v21.DSS0210,A2-7-2,2b](../../../../requirements/astm/f3548/v21.md)**

#### 🛑 Failure response due to conflict has proper format check

The DSS is expected to return a `HTTP 409` error response when the creation of an operational intent reference fails due to a conflict.
This response is expected to conform to the OpenAPI spec that is part of **[astm.f3548.v21.DSS0005,1](../../../../requirements/astm/f3548/v21.md)**.

Should this not be the case, then the DSS is in violation of the aforementioned requirement.

#### 🛑 Failure response due to conflict contains conflicting OIRs check

If the DSS returns a `HTTP 409` error response due to a conflict, and the response body contains a `missing_operational_intents` field,
this field is expected to contain the conflicting OVNs.

If the field exists but does not contain the conflicting OVNs, then the DSS is in violation of **[astm.f3548.v21.DSS0005,1](../../../../requirements/astm/f3548/v21.md)**.


## [Cleanup](./clean_workspace.md)
Loading

0 comments on commit 71c2fd6

Please sign in to comment.