Skip to content

Commit

Permalink
TC-DA-1.2: Make the CD certificate dir configurable (#28697)
Browse files Browse the repository at this point in the history
* Make the CD certificate dir configurable

* Restyled by autopep8

---------

Co-authored-by: Restyled.io <commits@restyled.io>
  • Loading branch information
2 people authored and pull[bot] committed Nov 14, 2023
1 parent 29d9515 commit 1744289
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/python_testing/TC_DA_1_2.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,11 @@ def parse_ids_from_certs(dac: x509.Certificate, pai: x509.Certificate) -> tuple(

return dac_vid, dac_pid, pai_vid, pai_pid

# To set the directory for the CD certificates use
# --string-arg cd_cert_dir:'your_directory_name'
# ex. --string-arg cd_cert_dir:'credentials/development/cd-certs'
# default is 'credentials/development/cd-certs'.


class TC_DA_1_2(MatterBaseTest):
@async_test_body
Expand All @@ -109,6 +114,8 @@ async def test_TC_DA_1_2(self):
if pics_origin_pid != pics_origin_vid:
asserts.fail("MCORE.DA.CERTDECL_ORIGIN_PRODUCTID and MCORE.DA.CERTDECL_ORIGIN_VENDORID PICS codes must match")

cd_cert_dir = self.user_params.get("cd_cert_dir", 'credentials/development/cd-certs')

self.print_step(0, "Commissioning, already done")

opcreds = Clusters.Objects.OperationalCredentials
Expand Down Expand Up @@ -319,13 +326,11 @@ async def test_TC_DA_1_2(self):

self.print_step("8.9", "Check signature")
signature_cd = bytes(signer_info['signature'])
# TODO: Cecille - this path needs to be set as an input
cert_dir = 'credentials/development/cd-certs'
certs = {}
for filename in os.listdir(cert_dir):
for filename in os.listdir(cd_cert_dir):
if '.der' not in filename:
continue
with open(os.path.join(cert_dir, filename), 'rb') as f:
with open(os.path.join(cd_cert_dir, filename), 'rb') as f:
cert = x509.load_der_x509_certificate(f.read())
pub = cert.public_key()
ski = x509.SubjectKeyIdentifier.from_public_key(pub).digest
Expand Down

0 comments on commit 1744289

Please sign in to comment.