Skip to content

Commit 47c6d46

Browse files
authoredApr 17, 2024
TC-DA-1.2: cover PAI incorrect PID encoding (#32717)
* TC-DA-1.2: add test to tests.yaml This wasn't here before. I want to see this fail before adding the fix. * actually set exit value Also, apparently the formatting rules changed. OK... * Add check for incorrectly formatted fallback PID on PAI
1 parent 0b0d116 commit 47c6d46

File tree

3 files changed

+26
-11
lines changed

3 files changed

+26
-11
lines changed
 

‎.github/workflows/tests.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -559,6 +559,7 @@ jobs:
559559
scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --app out/linux-x64-rvc-ipv6only-no-ble-no-wifi-tsan-clang-test/chip-rvc-app --factoryreset --app-args "--discriminator 1234 --KVS kvs1 --trace_file json:out/trace_data/app-{SCRIPT_BASE_NAME}.json" --script "src/python_testing/TC_RVCOPSTATE_2_1.py" --script-args "--storage-path admin_storage.json --commissioning-method on-network --discriminator 1234 --passcode 20202021 --PICS examples/rvc-app/rvc-common/pics/rvc-app-pics-values --endpoint 1 --trace-to json:out/trace_data/test-{SCRIPT_BASE_NAME}.json --trace-to perfetto:out/trace_data/test-{SCRIPT_BASE_NAME}.perfetto"'
560560
scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --app out/linux-x64-rvc-ipv6only-no-ble-no-wifi-tsan-clang-test/chip-rvc-app --factoryreset --app-args "--discriminator 1234 --KVS kvs1 --trace_file json:out/trace_data/app-{SCRIPT_BASE_NAME}.json" --script "src/python_testing/TC_RVCOPSTATE_2_3.py" --script-args "--storage-path admin_storage.json --commissioning-method on-network --discriminator 1234 --passcode 20202021 --PICS examples/rvc-app/rvc-common/pics/rvc-app-pics-values --endpoint 1 --trace-to json:out/trace_data/test-{SCRIPT_BASE_NAME}.json --trace-to perfetto:out/trace_data/test-{SCRIPT_BASE_NAME}.perfetto"'
561561
scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --app out/linux-x64-rvc-ipv6only-no-ble-no-wifi-tsan-clang-test/chip-rvc-app --factoryreset --app-args "--discriminator 1234 --KVS kvs1 --trace_file json:out/trace_data/app-{SCRIPT_BASE_NAME}.json" --script "src/python_testing/TC_RVCOPSTATE_2_4.py" --script-args "--storage-path admin_storage.json --commissioning-method on-network --discriminator 1234 --passcode 20202021 --PICS examples/rvc-app/rvc-common/pics/rvc-app-pics-values --endpoint 1 --trace-to json:out/trace_data/test-{SCRIPT_BASE_NAME}.json --trace-to perfetto:out/trace_data/test-{SCRIPT_BASE_NAME}.perfetto"'
562+
scripts/run_in_python_env.sh out/venv './src/python_testing/test_testing/test_TC_DA_1_2.py'
562563
- name: Uploading core files
563564
uses: actions/upload-artifact@v4
564565
if: ${{ failure() && !env.ACT }}

‎src/python_testing/TC_DA_1_2.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ def parse_single_vidpid_from_common_name(commonName: str, tag_str: str) -> str:
5757

5858
s = sp[1][:4]
5959
if not s.isupper() or len(s) != 4:
60+
asserts.fail(f"Improperly encoded PID or VID when using fallback encoding {tag_str}:{s}")
6061
return None
6162

6263
return s
@@ -132,6 +133,8 @@ def steps_TC_DA_1_2(self):
132133
TestStep("6.7", "Verify CD security_information", "security_information = 0"),
133134
TestStep("6.8", "Verify CD version_number", "version_number is an integer in range 0..65535"),
134135
TestStep("6.9", "Verify CD certification_type", "certification_type has a value between 1..2"),
136+
TestStep("7.0", "Extract the Vendor ID (VID) and Product ID (PID) from the DAC. Extract the VID from the PAI. Extract the PID from the PAI, if present",
137+
"VID and PID are present and properly encoded in the DAC. VID is present and properly encoded in the PAI. If the PID is present in the PAI, it is properly encoded"),
135138
TestStep("7.1", "", "If the dac_origin_vendor_id is present in the CD, confirm the dac_origin_product_id is also present. If the dac_origin_vendor_id is not present in the CD, confirm the dac_origin_product_id is also not present."),
136139
TestStep("7.2", "If the Certification Declaration has both the dac_origin_vendor_id and the dac_origin_product_id fields, verify dac_origin fields",
137140
("* The Vendor ID (VID) in the DAC subject and PAI subject are the same as the dac_origin_vendor_id field in the Certification Declaration.\n"
@@ -309,9 +312,10 @@ async def test_TC_DA_1_2(self):
309312
else:
310313
asserts.assert_in(certification_type, [1, 2], "Certification type is out of range")
311314

312-
self.step("7.1")
315+
self.step("7.0")
313316
dac_vid, dac_pid, pai_vid, pai_pid = parse_ids_from_certs(parsed_dac, parsed_pai)
314317

318+
self.step("7.1")
315319
has_origin_vid = 9 in cd.keys()
316320
has_origin_pid = 10 in cd.keys()
317321
if has_origin_pid != has_origin_vid:

‎src/python_testing/test_testing/test_TC_DA_1_2.py

+20-10
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,10 @@
1919
import json
2020
import os
2121
import subprocess
22+
import sys
2223

23-
CHIP_ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), '../../..'))
24+
CHIP_ROOT = os.path.abspath(os.path.join(
25+
os.path.dirname(__file__), '../../..'))
2426
RUNNER_SCRIPT_DIR = os.path.join(CHIP_ROOT, 'scripts/tests')
2527

2628

@@ -30,13 +32,15 @@ def run_single_test(dac_provider: str, product_id: int, factory_reset: bool = Fa
3032
if factory_reset:
3133
reset = ' --factoryreset'
3234

33-
app = os.path.join(CHIP_ROOT, 'out/linux-x64-all-clusters-ipv6only-no-ble-no-wifi-tsan-clang-test/chip-all-clusters-app')
35+
app = os.path.join(
36+
CHIP_ROOT, 'out/linux-x64-all-clusters-ipv6only-no-ble-no-wifi-tsan-clang-test/chip-all-clusters-app')
3437

3538
# Certs in the commissioner_dut directory use 0x8000 as the PID
3639
app_args = '--discriminator 1234 --KVS kvs1 --product-id ' + \
3740
str(product_id) + ' --vendor-id 65521 --dac_provider ' + dac_provider
3841

39-
ci_pics_values = os.path.abspath(os.path.join(CHIP_ROOT, 'src/app/tests/suites/certification/ci-pics-values'))
42+
ci_pics_values = os.path.abspath(os.path.join(
43+
CHIP_ROOT, 'src/app/tests/suites/certification/ci-pics-values'))
4044
script_args = '--storage-path admin_storage.json --discriminator 1234 --passcode 20202021 --dut-node-id 1 --PICS ' + \
4145
str(ci_pics_values)
4246

@@ -45,28 +49,34 @@ def run_single_test(dac_provider: str, product_id: int, factory_reset: bool = Fa
4549
if factory_reset:
4650
script_args = script_args + ' --commissioning-method on-network'
4751

48-
script = os.path.abspath(os.path.join(CHIP_ROOT, 'src/python_testing/TC_DA_1_2.py'))
52+
script = os.path.abspath(os.path.join(
53+
CHIP_ROOT, 'src/python_testing/TC_DA_1_2.py'))
4954

5055
# run_python_test uses click so call as a command
51-
run_python_test = os.path.abspath(os.path.join(RUNNER_SCRIPT_DIR, 'run_python_test.py'))
56+
run_python_test = os.path.abspath(os.path.join(
57+
RUNNER_SCRIPT_DIR, 'run_python_test.py'))
5258
cmd = str(run_python_test) + reset + ' --app ' + str(app) + ' --app-args "' + \
53-
app_args + '" --script ' + str(script) + ' --script-args "' + script_args + '"'
59+
app_args + '" --script ' + \
60+
str(script) + ' --script-args "' + script_args + '"'
5461

5562
return subprocess.call(cmd, shell=True)
5663

5764

5865
def main():
59-
cert_path = os.path.abspath(os.path.join(CHIP_ROOT, 'credentials/development/commissioner_dut'))
66+
cert_path = os.path.abspath(os.path.join(
67+
CHIP_ROOT, 'credentials/development/commissioner_dut'))
6068

6169
# Commission first using a known good set, then run the rest of the tests without recommissioning
62-
path = str(os.path.join(cert_path, "struct_cd_authorized_paa_list_count1_valid/test_case_vector.json"))
70+
path = str(os.path.join(
71+
cert_path, "struct_cd_authorized_paa_list_count1_valid/test_case_vector.json"))
6372
run_single_test(path, 32768, factory_reset=True)
6473

6574
test_cases = {'struct_cd': 32768, 'fallback_encoding': 177}
6675

6776
# struct_cd_version_number_wrong - excluded because this is a DCL test not covered by cert
6877
# struct_cd_cert_id_mismatch - excluded because this is a DCL test not covered by cert
69-
exclude_cases = ['struct_cd_version_number_wrong', 'struct_cd_cert_id_mismatch']
78+
exclude_cases = ['struct_cd_version_number_wrong',
79+
'struct_cd_cert_id_mismatch']
7080

7181
passes = []
7282
for p in os.listdir(cert_path):
@@ -92,7 +102,7 @@ def main():
92102
print('INCORRECT: ' + p[0])
93103
retval = 1
94104

95-
return retval
105+
sys.exit(retval)
96106

97107

98108
if __name__ == '__main__':

0 commit comments

Comments
 (0)