Skip to content

Commit

Permalink
[uss_qualifier] scd OIRSimple scenario checks correct OVN required fo…
Browse files Browse the repository at this point in the history
…r mutations
  • Loading branch information
Shastick committed Sep 10, 2024
1 parent cec1546 commit b276cc8
Show file tree
Hide file tree
Showing 2 changed files with 115 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,26 @@ This step verifies that an existing OIR cannot be deleted with an incorrect OVN.
If the DSS under test allows the qualifier to delete an existing OIR with a request that provided an incorrect OVN,
it is in violation of **[astm.f3548.v21.DSS0005,1](../../../../requirements/astm/f3548/v21.md)**

## Mutation requires correct OVN test case

Test DSS behavior when mutation requests are not providing the required OVN.

### Attempt mutation with missing OVN test step

This step verifies that an existing OIR cannot be mutated with a missing OVN.

#### 🛑 Request to mutate OIR with empty OVN fails check

If the DSS under test allows the qualifier to mutate an existing OIR with a request that provided an empty OVN,
it is in violation of **[astm.f3548.v21.DSS0005,1](../../../../requirements/astm/f3548/v21.md)**

### Attempt mutation with incorrect OVN test step

This step verifies that an existing OIR cannot be mutated with an incorrect OVN.

#### 🛑 Request to mutate OIR with incorrect OVN fails check

If the DSS under test allows the qualifier to mutate an existing OIR with a request that provided an incorrect OVN,
it is in violation of **[astm.f3548.v21.DSS0005,1](../../../../requirements/astm/f3548/v21.md)**

## [Cleanup](./clean_workspace.md)
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,11 @@ def run(self, context: ExecutionContext):
self._step_attempt_delete_incorrect_ovn()
self.end_test_case()

self.begin_test_case("Mutation requires correct OVN")
self._step_attempt_mutation_missing_ovn()
self._step_attempt_mutation_incorrect_ovn()
self.end_test_case()

self.end_test_scenario()

def _step_create_oir(self):
Expand Down Expand Up @@ -146,7 +151,7 @@ def _step_attempt_delete_missing_ovn(self):
except QueryError as qe:
self.record_queries(qe.queries)
if qe.cause_status_code in [400 or 409]:
# An empty OVN cen be seen as both an incorrect parameter as well as a conflict
# An empty OVN can be seen as both an incorrect parameter as well as a conflict
# because the value is incorrect: we accept both a 400 and 409 return code here.
pass
else:
Expand Down Expand Up @@ -190,6 +195,83 @@ def _step_attempt_delete_incorrect_ovn(self):

self.end_test_step()

def _step_attempt_mutation_missing_ovn(self):

self.begin_test_step("Attempt mutation with missing OVN")

oir_params = self._test_params_for_current_time()
with self.check(
"Request to mutate OIR with empty OVN fails", self._pid
) as check:
try:
_, _, query = self._dss.put_op_intent(
extents=oir_params.extents,
key=oir_params.key,
state=oir_params.state,
base_url=oir_params.uss_base_url,
oi_id=self._oir_id,
ovn="",
)
self.record_query(query)
# We don't expect the reach this point:
check.record_failed(
summary="OIR Mutation with missing OVN was not expected to succeed",
details=f"Was expecting an HTTP 400 or 409 response because of a missing OVN, but got {query.status_code} instead",
query_timestamps=[query.request.timestamp],
)
except QueryError as qe:
self.record_queries(qe.queries)
if qe.cause_status_code in [400, 409]:
# An empty OVN can be seen as both an incorrect parameter as well as a conflict
# because the value is incorrect: we accept both a 400 and 409 return code here.
pass
else:
check.record_failed(
summary="OIR Mutation with missing OVN failed for unexpected reason",
details=f"Was expecting an HTTP 400 or 409 response because of a missing OVN, but got {qe.cause_status_code} instead",
query_timestamps=qe.query_timestamps,
)
self.end_test_step()

def _step_attempt_mutation_incorrect_ovn(self):

self.begin_test_step("Attempt mutation with incorrect OVN")

oir_params = self._test_params_for_current_time()
with self.check(
"Request to mutate OIR with incorrect OVN fails", self._pid
) as check:
try:
_, _, query = self._dss.put_op_intent(
extents=oir_params.extents,
key=oir_params.key,
state=oir_params.state,
base_url=oir_params.uss_base_url,
oi_id=self._oir_id,
ovn="ThisIsAnIncorrectOVN",
)
self.record_query(query)
# We don't expect the reach this point:
check.record_failed(
summary="OIR Mutation with incorrect OVN was not expected to succeed",
details=f"Was expecting an HTTP 409 response because of an incorrect OVN, but got {query.status_code} instead",
query_timestamps=[query.request.timestamp],
)
except QueryError as qe:
self.record_queries(qe.queries)
if qe.cause_status_code == 409:
# An empty OVN can be seen as both an incorrect parameter as well as a conflict
# because the value is incorrect: we accept both a 400 and 409 return code here.
pass
else:
check.record_failed(
summary="OIR Mutation with incorrect OVN failed for unexpected reason",
details=f"Was expecting an HTTP 409 response because of an incorrect OVN, but got {qe.cause_status_code} instead",
query_timestamps=qe.query_timestamps,
)

self.end_test_step()

def _setup_case(self):
self.begin_test_case("Setup")
# Multiple runs of the scenario seem to rely on the same instance of it:
Expand Down Expand Up @@ -225,3 +307,13 @@ def cleanup(self):
self.begin_cleanup()
self._ensure_clean_workspace_step()
self.end_cleanup()

def _test_params_for_current_time(self):
return self._planning_area.get_new_operational_intent_ref_params(
key=[],
state=OperationalIntentState.Accepted,
uss_base_url=self._planning_area.base_url,
time_start=datetime.now() - timedelta(seconds=10),
time_end=datetime.now() + timedelta(minutes=20),
subscription_id=None,
)

0 comments on commit b276cc8

Please sign in to comment.