Skip to content

Commit

Permalink
DSS02120,A2-7-2,7
Browse files Browse the repository at this point in the history
  • Loading branch information
Shastick committed Feb 22, 2024
1 parent 69e3adf commit 57e5057
Show file tree
Hide file tree
Showing 13 changed files with 979 additions and 42 deletions.
53 changes: 40 additions & 13 deletions monitoring/monitorlib/mutate/scd.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,12 @@
import s2sphere
import yaml
from implicitdict import ImplicitDict
from uas_standards.astm.f3548.v21.api import OPERATIONS, OperationID, Subscription
from uas_standards.astm.f3548.v21.api import (
OPERATIONS,
OperationID,
Subscription,
PutSubscriptionParameters,
)
from yaml.representer import Representer

from monitoring.monitorlib import fetch
Expand Down Expand Up @@ -74,18 +79,16 @@ def upsert_subscription(
path = op.path.format(subscriptionid=subscription_id, version=version)
query_type = QueryType.F3548v21DSSUpdateSubscription

body = {
"extents": Volume4D.from_values(
start_time,
end_time,
min_alt_m,
max_alt_m,
polygon=Polygon.from_latlng_rect(latlngrect=area),
).to_f3548v21(),
"uss_base_url": base_url,
"notify_for_operational_intents": notify_for_op_intents,
"notify_for_constraints": notify_for_constraints,
}
body = build_upsert_subscription_params(
area_vertices=area,
start_time=start_time,
end_time=end_time,
base_url=base_url,
notify_for_op_intents=notify_for_op_intents,
notify_for_constraints=notify_for_constraints,
min_alt_m=min_alt_m,
max_alt_m=max_alt_m,
)

result = MutatedSubscription(
fetch.query_and_describe(
Expand All @@ -102,6 +105,30 @@ def upsert_subscription(
return result


def build_upsert_subscription_params(
area_vertices: s2sphere.LatLngRect,
start_time: datetime.datetime,
end_time: datetime.datetime,
base_url: str,
notify_for_op_intents: bool,
notify_for_constraints: bool,
min_alt_m: float,
max_alt_m: float,
) -> PutSubscriptionParameters:
return PutSubscriptionParameters(
extents=Volume4D.from_values(
start_time,
end_time,
min_alt_m,
max_alt_m,
polygon=Polygon.from_latlng_rect(latlngrect=area_vertices),
).to_f3548v21(),
uss_base_url=base_url,
notify_for_operational_intents=notify_for_op_intents,
notify_for_constraints=notify_for_constraints,
)


def delete_subscription(
utm_client: infrastructure.UTMClientSession,
subscription_id: str,
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: 379
# Next code: 381
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
@@ -1,9 +1,12 @@
import datetime
from typing import List, Optional, Self

import s2sphere
from implicitdict import ImplicitDict
from uas_standards.astm.f3548.v21.api import PutSubscriptionParameters

from monitoring.monitorlib.geo import LatLngPoint
from monitoring.monitorlib.mutate import scd as mutate


class SubscriptionParams(ImplicitDict):
Expand Down Expand Up @@ -44,3 +47,28 @@ class SubscriptionParams(ImplicitDict):

def copy(self) -> Self:
return SubscriptionParams(super().copy())

def to_upsert_subscription_params(
self, area: s2sphere.LatLngRect
) -> PutSubscriptionParameters:
"""
Prepares the subscription parameters to be used in the body of an HTTP request
to create or update a subscription on the DSS in the SCD context.
Args:
area: area to include in the subscription parameters
Returns:
A dict to be passed as the request body when calling the subscription creation or update API.
"""
return mutate.build_upsert_subscription_params(
area_vertices=area,
start_time=self.start_time,
end_time=self.end_time,
base_url=self.base_url,
notify_for_op_intents=self.notify_for_op_intents,
notify_for_constraints=self.notify_for_constraints,
min_alt_m=self.min_alt_m,
max_alt_m=self.max_alt_m,
)
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
from .subscription_validation import SubscriptionValidation
from .subscription_simple import SubscriptionSimple
from .authentication_validation import AuthenticationValidation
Original file line number Diff line number Diff line change
@@ -0,0 +1,164 @@
# ASTM SCD DSS: Interfaces authentication test scenario

## Overview

Ensures that a DSS properly authenticates requests to all its endpoints.

Note that this does not cover authorization.

## Resources

### dss

[`DSSInstanceResource`](../../../../resources/astm/f3548/v21/dss.py) to be tested in this scenario.

### id_generator

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

### planning_area

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

## Setup test case

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

This step ensures that no entity with the known test IDs exists in the DSS.

## Endpoint authorization test case

This test case ensures that the DSS properly authenticates requests to all its endpoints.

### Subscription endpoints authentication test step

#### 🛑 Unauthorized requests return the proper error message body check

If the DSS under test does not return a proper error message body when an unauthorized request is received, it fails to properly implement the OpenAPI specification that is part of **[astm.f3548.v21.DSS0005,5](../../../../requirements/astm/f3548/v21.md)**.

#### 🛑 Create subscription with missing credentials check

If the DSS under test allows the creation of a subscription without any credentials being presented, it is in violation of **[astm.f3548.v21.DSS0210,A2-7-2,7](../../../../requirements/astm/f3548/v21.md)**.

#### 🛑 Create subscription with invalid credentials check

If the DSS under test allows the creation of a subscription with credentials that are well-formed but invalid,
it is in violation of **[astm.f3548.v21.DSS0210,A2-7-2,7](../../../../requirements/astm/f3548/v21.md)**.

#### 🛑 Create subscription with missing scope check

If the DSS under test allows the creation of a subscription with valid credentials but a missing scope,
it is in violation of **[astm.f3548.v21.DSS0210,A2-7-2,7](../../../../requirements/astm/f3548/v21.md)**.

#### 🛑 Create subscription with incorrect scope check

If the DSS under test allows the creation of a subscription with valid credentials but an incorrect scope,
it is in violation of **[astm.f3548.v21.DSS0210,A2-7-2,7](../../../../requirements/astm/f3548/v21.md)**.

#### 🛑 Create subscription with valid credentials check

If the DSS does not allow the creation of a subscription when valid credentials are presented,
it is in violation of **[astm.f3548.v21.DSS0005,5](../../../../requirements/astm/f3548/v21.md)**.

#### 🛑 Get subscription with missing credentials check

If the DSS under test allows the fetching of a subscription without any credentials being presented, it is in violation of **[astm.f3548.v21.DSS0210,A2-7-2,7](../../../../requirements/astm/f3548/v21.md)**.

#### 🛑 Get subscription with invalid credentials check

If the DSS under test allows the fetching of a subscription with credentials that are well-formed but invalid,
it is in violation of **[astm.f3548.v21.DSS0210,A2-7-2,7](../../../../requirements/astm/f3548/v21.md)**.

#### 🛑 Get subscription with missing scope check

If the DSS under test allows the fetching of a subscription with valid credentials but a missing scope,
it is in violation of **[astm.f3548.v21.DSS0210,A2-7-2,7](../../../../requirements/astm/f3548/v21.md)**.

#### 🛑 Get subscription with incorrect scope check

If the DSS under test allows the fetching of a subscription with valid credentials but an incorrect scope,
it is in violation of **[astm.f3548.v21.DSS0210,A2-7-2,7](../../../../requirements/astm/f3548/v21.md)**.

#### 🛑 Get subscription with valid credentials check

If the DSS does not allow fetching a subscription when valid credentials are presented,
it is in violation of **[astm.f3548.v21.DSS0005,5](../../../../requirements/astm/f3548/v21.md)**.

#### 🛑 Mutate subscription with missing credentials check

If the DSS under test allows the mutation of a subscription without any credentials being presented,
it is in violation of **[astm.f3548.v21.DSS0210,A2-7-2,7](../../../../requirements/astm/f3548/v21.md)**.

#### 🛑 Mutate subscription with invalid credentials check

If the DSS under test allows the mutation of a subscription with credentials that are well-formed but invalid,
it is in violation of **[astm.f3548.v21.DSS0210,A2-7-2,7](../../../../requirements/astm/f3548/v21.md)**.

#### 🛑 Mutate subscription with missing scope check

If the DSS under test allows the mutation of a subscription with valid credentials but a missing scope,
it is in violation of **[astm.f3548.v21.DSS0210,A2-7-2,7](../../../../requirements/astm/f3548/v21.md)**.

#### 🛑 Mutate subscription with incorrect scope check

If the DSS under test allows the mutation of a subscription with valid credentials but an incorrect scope,
it is in violation of **[astm.f3548.v21.DSS0210,A2-7-2,7](../../../../requirements/astm/f3548/v21.md)**.

#### 🛑 Mutate subscription with valid credentials check

If the DSS does not allow the mutation of a subscription when valid credentials are presented,
it is in violation of **[astm.f3548.v21.DSS0005,5](../../../../requirements/astm/f3548/v21.md)**.

#### 🛑 Delete subscription with missing credentials check

If the DSS under test allows the deletion of a subscription without any credentials being presented,
it is in violation of **[astm.f3548.v21.DSS0210,A2-7-2,7](../../../../requirements/astm/f3548/v21.md)**.

#### 🛑 Delete subscription with invalid credentials check

If the DSS under test allows the deletion of a subscription with credentials that are well-formed but invalid,
it is in violation of **[astm.f3548.v21.DSS0210,A2-7-2,7](../../../../requirements/astm/f3548/v21.md)**.

#### 🛑 Delete subscription with missing scope check

If the DSS under test allows the deletion of a subscription with valid credentials but a missing scope,
it is in violation of **[astm.f3548.v21.DSS0210,A2-7-2,7](../../../../requirements/astm/f3548/v21.md)**.

#### 🛑 Delete subscription with incorrect scope check

If the DSS under test allows the deletion of a subscription with valid credentials but an incorrect scope,
it is in violation of **[astm.f3548.v21.DSS0210,A2-7-2,7](../../../../requirements/astm/f3548/v21.md)**.

#### 🛑 Delete subscription with valid credentials check

If the DSS does not allow the deletion of a subscription when valid credentials are presented,
it is in violation of **[astm.f3548.v21.DSS0005,5](../../../../requirements/astm/f3548/v21.md)**.

#### 🛑 Search subscriptions with missing credentials check

If the DSS under test allows searching for subscriptions without any credentials being presented,
it is in violation of **[astm.f3548.v21.DSS0210,A2-7-2,7](../../../../requirements/astm/f3548/v21.md)**.

#### 🛑 Search subscriptions with invalid credentials check

If the DSS under test allows searching for subscriptions with credentials that are well-formed but invalid,
it is in violation of **[astm.f3548.v21.DSS0210,A2-7-2,7](../../../../requirements/astm/f3548/v21.md)**.

#### 🛑 Search subscriptions with missing scope check

If the DSS under test allows searching for subscriptions with valid credentials but a missing scope,
it is in violation of **[astm.f3548.v21.DSS0210,A2-7-2,7](../../../../requirements/astm/f3548/v21.md)**.

#### 🛑 Search subscriptions with incorrect scope check

If the DSS under test allows searching for subscriptions with valid credentials but an incorrect scope,
it is in violation of **[astm.f3548.v21.DSS0210,A2-7-2,7](../../../../requirements/astm/f3548/v21.md)**.

#### 🛑 Search subscriptions with valid credentials check

If the DSS does not allow searching for subscriptions when valid credentials are presented,
it is in violation of **[astm.f3548.v21.DSS0005,5](../../../../requirements/astm/f3548/v21.md)**.

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

The cleanup phase of this test scenario removes the subscription with the known test ID if it has not been removed before.
Loading

0 comments on commit 57e5057

Please sign in to comment.