From bd8d6e68108726e9020011a146cfdd1f9ff78780 Mon Sep 17 00:00:00 2001 From: Julien Perrochet Date: Fri, 6 Sep 2024 11:18:40 +0200 Subject: [PATCH] [uss_qualifier] scd subscription_simple: check mutation is only allowed with correct version (#763) --- .../astm/utm/dss/subscription_simple.md | 12 +++++ .../astm/utm/dss/subscription_simple.py | 44 +++++++++++++++++++ 2 files changed, 56 insertions(+) diff --git a/monitoring/uss_qualifier/scenarios/astm/utm/dss/subscription_simple.md b/monitoring/uss_qualifier/scenarios/astm/utm/dss/subscription_simple.md index 2222b8cf25..00ea688bb8 100644 --- a/monitoring/uss_qualifier/scenarios/astm/utm/dss/subscription_simple.md +++ b/monitoring/uss_qualifier/scenarios/astm/utm/dss/subscription_simple.md @@ -96,6 +96,18 @@ Verify that the subscription returned by the DSS via the search is correctly for Verify that the version field is as expected. +### Attempt Subscription mutation with incorrect version test step + +This test step attempts to mutate the subscription both with a missing and incorrect OVN, and checks that the DSS reacts properly. + +#### 🛑 Mutation with empty version fails check + +If a request to mutate a subscription is missing the version and succeeds, the DSS is failing to properly implement **[astm.f3548.v21.DSS0005,5](../../../../requirements/astm/f3548/v21.md)**. + +#### 🛑 Mutation with incorrect version fails check + +If a request to mutate a subscription providing the wrong version succeeds, the DSS is failing to properly implement **[astm.f3548.v21.DSS0005,5](../../../../requirements/astm/f3548/v21.md)**. + ### Mutate Subscription test step This test step mutates the previously created subscription to verify that the DSS reacts properly: notably, it checks that the subscription version is updated, diff --git a/monitoring/uss_qualifier/scenarios/astm/utm/dss/subscription_simple.py b/monitoring/uss_qualifier/scenarios/astm/utm/dss/subscription_simple.py index e0f8f9c57a..d60fe8b876 100644 --- a/monitoring/uss_qualifier/scenarios/astm/utm/dss/subscription_simple.py +++ b/monitoring/uss_qualifier/scenarios/astm/utm/dss/subscription_simple.py @@ -124,6 +124,10 @@ def run(self, context: ExecutionContext): self._create_and_validate_subs() self.end_test_step() + self.begin_test_step("Attempt Subscription mutation with incorrect version") + self._test_mutate_subscription_version_check() + self.end_test_step() + self.begin_test_step("Mutate Subscription") self._test_mutate_subscriptions_shift_time() self._test_mutate_subscriptions_change_area() @@ -277,6 +281,46 @@ def _compare_upsert_resp_with_params( query_timestamps=[creation_resp_under_test.request.timestamp], ) + def _test_mutate_subscription_version_check(self): + """Attempt to mutate a subscription while providing a missing and incorrect OVN""" + orig_params = self._sub_params_by_sub_id[self._base_sub_id].copy() + sub = self._current_subscriptions[self._base_sub_id] + new_params = SubscriptionParams( + sub_id=self._base_sub_id, + area_vertices=orig_params.area_vertices, + min_alt_m=orig_params.min_alt_m, + max_alt_m=orig_params.max_alt_m, + start_time=sub.time_start.value.datetime + timedelta(seconds=10), + end_time=sub.time_end.value.datetime + timedelta(seconds=10), + base_url=orig_params.base_url, + notify_for_op_intents=orig_params.notify_for_op_intents, + notify_for_constraints=orig_params.notify_for_constraints, + ) + + with self.check("Mutation with empty version fails", self._pid) as check: + no_version_res = self._dss.upsert_subscription( + version="", + **new_params, + ) + if no_version_res.status_code not in [400, 409]: + check.record_failed( + "Mutation with empty version did not fail as expected", + details=f"Mutation with an empty version is expected , received status code {no_version_res.status_code}", + query_timestamps=[no_version_res.request.timestamp], + ) + + with self.check("Mutation with incorrect version fails", self._pid) as check: + wrong_version_res = self._dss.upsert_subscription( + version="ThisIsAnIncorrectVersion", + **new_params, + ) + if wrong_version_res.status_code not in [400, 409]: + check.record_failed( + "Mutation with incorrect version did not fail as expected", + details=f"Mutation with an incorrect version is expected , received status code {wrong_version_res.status_code}", + query_timestamps=[wrong_version_res.request.timestamp], + ) + def _test_mutate_subscriptions_shift_time(self): """Mutate all existing subscriptions by adding 10 seconds to their start and end times"""