Skip to content

Commit

Permalink
Implements latest review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
raul-marquez-csa committed Jan 18, 2024
1 parent 7a4b5cd commit 8f757b0
Showing 1 changed file with 24 additions and 65 deletions.
89 changes: 24 additions & 65 deletions src/python_testing/TC_IDM_4_2.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,14 @@
Category:
Functional
Purpose:
This test case will verify that the response messages returned by
subscription requests are according to specification.
Test Plan:
Description:
Validates Interaction Data Model (IDM), specifically subscription responses. Some example of tests run:
- Subscriptions with varying MaxIntervalCeiling
- Checks for `InvalidAction` results when subscribing to clusters and attributes without access rights
- Checks that subscription is not established for invalid MinIntervalFloor
- Validates that only correctly filtered data is received when a subscription is established
Full test plan link for details:
https://github.com/CHIP-Specifications/chip-test-plans/blob/master/src/interactiondatamodel.adoc#tc-idm-4-2-subscription-response-messages-from-dut-test-cases-dut_server
'''

Expand Down Expand Up @@ -157,11 +160,7 @@ async def test_TC_IDM_4_2(self):
logging.info(
f"Set SUBSCRIPTION_MAX_INTERVAL_PUBLISHER_LIMIT_SEC to {SUBSCRIPTION_MAX_INTERVAL_PUBLISHER_LIMIT_SEC} seconds")

'''
##########
Step 1
##########
'''
########## Step 1 ##########
self.print_step(1, "CR1 sends a subscription message to the DUT with MaxIntervalCeiling set to a value greater than SUBSCRIPTION_MAX_INTERVAL_PUBLISHER_LIMIT_SEC. DUT sends a report data action to the TH. CR1 sends a success status response to the DUT. DUT sends a Subscribe Response Message to the CR1 to activate the subscription.")
min_interval_floor_sec = 1
max_interval_ceiling_sec = SUBSCRIPTION_MAX_INTERVAL_PUBLISHER_LIMIT_SEC + 5
Expand Down Expand Up @@ -198,11 +197,7 @@ async def test_TC_IDM_4_2(self):

sub_cr1_step1.Shutdown()

'''
##########
Step 2
##########
'''
########## Step 2 ##########
self.print_step(2, "CR1 sends a subscription message to the DUT with MaxIntervalCeiling set to a value less than SUBSCRIPTION_MAX_INTERVAL_PUBLISHER_LIMIT_SEC. DUT sends a report data action to the CR1. CR1 sends a success status response to the DUT. DUT sends a Subscribe Response Message to the CR1 to activate the subscription.")
min_interval_floor_sec = 1
max_interval_ceiling_sec = max(2, SUBSCRIPTION_MAX_INTERVAL_PUBLISHER_LIMIT_SEC - 5)
Expand Down Expand Up @@ -239,11 +234,7 @@ async def test_TC_IDM_4_2(self):

sub_cr1_step2.Shutdown()

'''
##########
Step 3
##########
'''
########## Step 3 ##########
self.print_step(3, "Setup CR2 such that it does not have access to a specific cluster. CR2 sends a subscription message to subscribe to an attribute on that cluster for which it does not have access.")

# Limited ACE for controller 2 with single cluster access
Expand Down Expand Up @@ -273,11 +264,7 @@ async def test_TC_IDM_4_2(self):
asserts.assert_equal(e.err, INVALID_ACTION_ERROR_CODE,
"Incorrect error response for subscription to unallowed cluster")

'''
##########
Step 4
##########
'''
########## Step 4 ##########
self.print_step(4, "Setup CR2 such that it does not have access to all attributes on a specific cluster and endpoint. CR2 sends a subscription request to subscribe to all attributes for which it does not have access.")

# Limited ACE for controller 2 with single cluster access and specific endpoint
Expand Down Expand Up @@ -309,11 +296,7 @@ async def test_TC_IDM_4_2(self):
asserts.assert_equal(e.err, INVALID_ACTION_ERROR_CODE,
"Incorrect error response for subscription to unallowed cluster")

'''
##########
Step 5
##########
'''
########## Step 5 ##########
self.print_step(5, "Setup CR2 such that it does not have access to an Endpoint. CR2 sends a subscription request to subscribe to all attributes on all clusters on a specific Endpoint for which it does not have access.")

# Limited ACE for controller 2 with endpoint 1 access only to all clusters and all attributes
Expand Down Expand Up @@ -343,11 +326,7 @@ async def test_TC_IDM_4_2(self):
asserts.assert_equal(e.err, INVALID_ACTION_ERROR_CODE,
"Incorrect error response for subscription to unallowed endpoint")

'''
##########
Step 6
##########
'''
########## Step 6 ##########
self.print_step(6, "Setup CR2 such that it does not have access to the Node. CR2 sends a subscription request to subscribe to all attributes on all clusters on all endpoints on a Node for which it does not have access.")

# Skip setting an ACE for controller 2 so
Expand Down Expand Up @@ -375,11 +354,7 @@ async def test_TC_IDM_4_2(self):
asserts.assert_equal(e.err, INVALID_ACTION_ERROR_CODE,
"Incorrect error response for subscription to unallowed node")

'''
##########
Step 7
##########
'''
########## Step 7 ##########
self.print_step(7, "CR1 sends a subscription request action for an attribute with an empty DataVersionFilters field. DUT sends a report data action with the data of the attribute along with the data version. Tear down the subscription for that attribute. Start another subscription with the DataVersionFilter field set to the data version received above.")

# Subscribe to attribute with empty dataVersionFilters
Expand Down Expand Up @@ -414,11 +389,7 @@ async def test_TC_IDM_4_2(self):

sub_cr1_provided_dvf.Shutdown()

'''
##########
Step 8
##########
'''
########## Step 8 ##########
self.print_step(8, "CR1 sends a subscription request action for an attribute and sets the MinIntervalFloor value to be same as MaxIntervalCeiling. Activate the Subscription between CR1 and DUT. Modify the attribute which has been subscribed to on the DUT.")

# Subscribe to attribute
Expand Down Expand Up @@ -446,11 +417,7 @@ async def test_TC_IDM_4_2(self):

sub_cr1_update_value.Shutdown()

'''
##########
Step 9
##########
'''
########## Step 9 ##########
self.print_step(
9, "CR1 sends a subscription request action for an attribute and set the MinIntervalFloor value to be greater than MaxIntervalCeiling.")

Expand All @@ -467,12 +434,10 @@ async def test_TC_IDM_4_2(self):
# Verify no subscription is established
with asserts.assert_raises(AttributeError):
sub_cr1_invalid_intervals.subscriptionId
except Exception:
asserts.fail("Expected exception was not thrown")

'''
##########
Step 10
##########
'''
########## Step 10 ##########
self.print_step(
10, "CR1 sends a subscription request to subscribe to a specific global attribute from all clusters on all endpoints.")

Expand Down Expand Up @@ -508,11 +473,7 @@ async def test_TC_IDM_4_2(self):

sub_cr1_step10.Shutdown()

'''
##########
Step 11
##########
'''
########## Step 11 ##########
self.print_step(11, "CR1 sends a subscription request to subscribe to a global attribute on an endpoint on all clusters.")

# Specifying single endpoint 0
Expand Down Expand Up @@ -551,11 +512,7 @@ async def test_TC_IDM_4_2(self):

sub_cr1_step11.Shutdown()

'''
##########
Step 12
##########
'''
########## Step 12 ##########
self.print_step(12, "CR1 sends a subscription request to the DUT with both AttributeRequests and EventRequests as empty.")

# Attempt a subscription with both AttributeRequests and EventRequests as empty
Expand All @@ -576,6 +533,8 @@ async def test_TC_IDM_4_2(self):
# Verify no subscription is established
with asserts.assert_raises(AttributeError):
sub_cr1_step12.subscriptionId
except Exception:
asserts.fail("Expected exception was not thrown")


if __name__ == "__main__":
Expand Down

0 comments on commit 8f757b0

Please sign in to comment.