Skip to content
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

[uss_qualifier] expand the authentication validation scenario to include constraint reference endpoints #690

Merged
merged 3 commits into from
Aug 27, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 1 addition & 1 deletion monitoring/uss_qualifier/resources/astm/f3548/v21/dss.py
Original file line number Diff line number Diff line change
Expand Up @@ -717,7 +717,7 @@ def participant_id(self) -> str:
def base_url(self) -> str:
return self._specification.base_url

def get_authorized_scope_not_in(self, ignored_scopes: List[str]) -> Optional[str]:
def get_authorized_scope_not_in(self, ignored_scopes: List[str]) -> Optional[Scope]:
"""Returns a scope that this DSS Resource is allowed to use but that is not any of the ones that are passed
in 'ignored_scopes'. If no such scope is found, None is returned.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ At least one of the following scopes needs to be available for this scenario to

- `utm.strategic_coordination`
- `utm.availability_arbitration`
- `utm.constraint_management`

In order to verify each endpoint group, all scopes above must be available.

Expand Down Expand Up @@ -387,6 +388,146 @@ it is in violation of **[astm.f3548.v21.DSS0100,1](../../../../../requirements/a
The response to a successful USS Availability Set request is expected to conform to the format defined by the OpenAPI specification under the `A3.1` Annex of ASTM F3548−21,
otherwise, the DSS is failing to implement **[astm.f3548.v21.DSS0100,1](../../../../../requirements/astm/f3548/v21.md)**.

### Constraint reference endpoints authentication test step
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably not the highest priority for adjustment, but It seems like the "steps" in this scenario should actually be "cases". A step is supposed to be a single logical action (do one thing), reflecting what a manual checkout test card would look like ("(step 1) Ok, now we're going to X -- did things Q and P happen? (step 2) Now we're going Y -- did things R and S happen?"). I would imagine a good test case would be "test authentication of all the constraint management endpoints", and then each testing of each constraint management endpoint would be a test step (or, testing of each constraint management endpoint in a particular way would be a test step).

Copy link
Contributor Author

@Shastick Shastick Aug 5, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes sense. it might be possible to easily do this as part of this PR, as I need to handle the optional utm.constraint_processing scopes, but I'm not entirely sure yet.

(Replacing the current steps with a test case having a single step would be easy in any case: I might keep splitting each test case into proper steps for later)

I created #742 to keep track of it in any case.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given the current priorities I'll leave the splitting into separate test cases for later.


#### 🛑 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,3](../../../../../requirements/astm/f3548/v21.md)**.

#### 🛑 Create constraint reference with missing credentials check

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

#### 🛑 Create constraint reference with invalid credentials check

If the DSS under test allows the creation of a constraint reference 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 constraint reference with missing scope check

If the DSS under test allows the creation of a constraint reference 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 constraint reference with incorrect scope check

If the DSS under test allows the creation of a constraint reference 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 constraint reference with valid credentials check

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this should be:

Suggested change
it is in violation of **[astm.f3548.v21.DSS0005,1](../../../../../requirements/astm/f3548/v21.md)**.
it is in violation of **[astm.f3548.v21.DSS0005,3](../../../../../requirements/astm/f3548/v21.md)**.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still 1?


#### [Create response format](../fragments/cr/crud/create_format.md)

Check response format of a creation request.

#### 🛑 Get constraint reference with missing credentials check

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

#### 🛑 Get constraint reference with invalid credentials check

If the DSS under test allows the fetching of a constraint reference 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 constraint reference with missing scope check

If the DSS under test allows the fetching of a constraint reference 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 constraint reference with incorrect scope check

If the DSS under test allows the fetching of a constraint reference 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 constraint reference with valid credentials check

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
it is in violation of **[astm.f3548.v21.DSS0005,1](../../../../../requirements/astm/f3548/v21.md)**.
it is in violation of **[astm.f3548.v21.DSS0005,3](../../../../../requirements/astm/f3548/v21.md)**.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also: no checking of the get response format?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. Added to the validator.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still 1?


#### 🛑 Mutate constraint reference with missing credentials check

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

#### 🛑 Mutate constraint reference with invalid credentials check

If the DSS under test allows the mutation of a constraint reference 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 constraint reference with missing scope check

If the DSS under test allows the mutation of a constraint reference 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 constraint reference with incorrect scope check

If the DSS under test allows the mutation of a constraint reference 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 constraint reference with valid credentials check

If the DSS does not allow the mutation of a constraint reference when valid credentials are presented,
it is in violation of **[astm.f3548.v21.DSS0005,1](../../../../../requirements/astm/f3548/v21.md)**.
Shastick marked this conversation as resolved.
Show resolved Hide resolved

#### [Mutate response format](../fragments/cr/crud/update_format.md)

Check response format of a mutation.

#### 🛑 Delete constraint reference with missing credentials check

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

#### 🛑 Delete constraint reference with invalid credentials check

If the DSS under test allows the deletion of a constraint reference 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 constraint reference with missing scope check

If the DSS under test allows the deletion of a constraint reference 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 constraint reference with incorrect scope check

If the DSS under test allows the deletion of a constraint reference 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 constraint reference with valid credentials check

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
it is in violation of **[astm.f3548.v21.DSS0005,1](../../../../../requirements/astm/f3548/v21.md)**.
it is in violation of **[astm.f3548.v21.DSS0005,3](../../../../../requirements/astm/f3548/v21.md)**.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, no checking of delete response format?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still 1?


#### 🛑 Search constraint references with missing credentials check

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

#### 🛑 Search constraint references with invalid credentials check

If the DSS under test allows searching for constraint references 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 constraint references with missing scope check

If the DSS under test allows searching for constraint references 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 constraint references with incorrect scope check

If the DSS under test allows searching for constraint references 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 constraint references with valid credentials check

If the DSS does not allow searching for constraint references when valid credentials are presented,
it is in violation of **[astm.f3548.v21.DSS0005,1](../../../../../requirements/astm/f3548/v21.md)**.
Shastick marked this conversation as resolved.
Show resolved Hide resolved

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

### [Availability can be requested](../fragments/availability/read.md)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@
from monitoring.uss_qualifier.scenarios.astm.utm.dss.authentication.availability_api_validator import (
AvailabilityAuthValidator,
)
from monitoring.uss_qualifier.scenarios.astm.utm.dss.authentication.cr_api_validator import (
ConstraintRefAuthValidator,
)
from monitoring.uss_qualifier.scenarios.astm.utm.dss.authentication.generic import (
GenericAuthValidator,
)
Expand Down Expand Up @@ -59,6 +62,7 @@ class AuthenticationValidation(TestScenario):

_scd_dss: Optional[DSSInstance] = None
_availability_dss: Optional[DSSInstance] = None
_constraints_dss: Optional[DSSInstance] = None

def __init__(
self,
Expand Down Expand Up @@ -119,6 +123,27 @@ def __init__(
availability_scopes = None
self._wrong_scope_for_availability = None

if dss.can_use_scope(Scope.ConstraintManagement):
constraints_scopes = {
Scope.ConstraintManagement: "Create, update, and delete constraints",
}

self._wrong_scope_for_constraints = dss.get_authorized_scope_not_in(
[
Scope.ConstraintManagement, # Allowed to get and update
Scope.ConstraintProcessing, # Allowed to get
"", # Already Used for empty scope testing
]
)

if self._wrong_scope_for_constraints is not None:
constraints_scopes[
self._wrong_scope_for_constraints
] = "Attempt to query constraints with wrong scope"
else:
constraints_scopes = None
self._wrong_scope_for_constraints = None

self._test_missing_scope = False
if dss.can_use_scope(""):
# Add empty scope to every map when they are non-empty:
Expand All @@ -131,6 +156,10 @@ def __init__(
availability_scopes[
""
] = "Attempt to query availability with missing scope"
if constraints_scopes:
constraints_scopes[
""
] = "Attempt to query constraints with missing scope"
self._test_missing_scope = True

# Note: .get_instance should be called once we know every scope we will need,
Expand All @@ -139,6 +168,8 @@ def __init__(
# and skip .get_instance altogether (otherwise the scenario would not be run)
if scd_scopes:
self._scd_dss = dss.get_instance(scd_scopes)
if constraints_scopes:
self._constraints_dss = dss.get_instance(constraints_scopes)
if availability_scopes:
self._availability_dss = dss.get_instance(availability_scopes)

Expand All @@ -162,7 +193,11 @@ def __init__(
self._scd_dss.base_url, auth_adapter=InvalidTokenSignatureAuth()
)

if not self._scd_dss and not self._availability_dss:
if (
not self._scd_dss
and not self._constraints_dss
and not self._availability_dss
):
raise MissingResourceError(
f"AuthAdapterResource provided to {fullname(type(self))} has none of the required scopes for this scenario.",
"<unknown>",
Expand Down Expand Up @@ -269,6 +304,37 @@ def run(self, context: ExecutionContext):
else:
self.record_note("availability", "Skipping Availability endpoints")

if self._constraints_dss:
self.record_note("constraints", "Testing Constraint Reference endpoints")
self.begin_test_step("Constraint reference endpoints authentication")
if self._wrong_scope_for_constraints:
self.record_note(
"constraints_wrong_scope",
f"Incorrect scope testing enabled with scope {self._wrong_scope_for_constraints}.",
)
else:
self.record_note(
"constraints_wrong_scope", "Incorrect scope testing disabled."
)
cr_validator = ConstraintRefAuthValidator(
scenario=self,
generic_validator=GenericAuthValidator(
self, self._constraints_dss, Scope.ConstraintManagement
),
dss=self._constraints_dss,
test_id=self._test_id,
planning_area=self._planning_area,
planning_area_volume4d=self._planning_area_volume4d,
no_auth_session=self._no_auth_session,
invalid_token_session=self._invalid_token_session,
test_wrong_scope=self._wrong_scope_for_constraints,
test_missing_scope=self._test_missing_scope,
)
cr_validator.verify_cr_endpoints_authentication()
self.end_test_step()
else:
self.record_note("constraints", "Skipping Constraint Reference endpoints")

self.end_test_case()
self.end_test_scenario()

Expand Down
Loading
Loading