Skip to content

Commit

Permalink
Add unit test for no defined notAfter time.
Browse files Browse the repository at this point in the history
  • Loading branch information
bzbarsky-apple committed May 6, 2023
1 parent e3f8d23 commit 2cfe987
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/credentials/tests/TestChipCert.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1345,6 +1345,23 @@ static void TestChipCert_GenerateRootCert(nlTestSuite * inSuite, void * inContex
NL_TEST_ASSERT(inSuite, ConvertX509CertToChipCert(signed_cert_span2, outCert) == CHIP_NO_ERROR);
NL_TEST_ASSERT(inSuite, DecodeChipCert(outCert, certData) == CHIP_NO_ERROR);

// Test with no defined notAfter time.
{
X509CertRequestParams root_params3 = { .SerialNumber = 1234,
.ValidityStart = 631161876,
.ValidityEnd = kNullCertTime,
.SubjectDN = root_dn,
.IssuerDN = root_dn };
MutableByteSpan signed_cert_span_no_expiry(signed_cert);

NL_TEST_ASSERT(inSuite, NewRootX509Cert(root_params3, keypair, signed_cert_span_no_expiry) == CHIP_NO_ERROR);
outCert = MutableByteSpan(outCertBuf);

NL_TEST_ASSERT(inSuite, ConvertX509CertToChipCert(signed_cert_span_no_expiry, outCert) == CHIP_NO_ERROR);
NL_TEST_ASSERT(inSuite, DecodeChipCert(outCert, certData) == CHIP_NO_ERROR);
NL_TEST_ASSERT(inSuite, certData.mNotAfterTime == kNullCertTime);
}

// Test error case: root cert subject provided ICA OID Attribute.
root_params.SubjectDN.Clear();
NL_TEST_ASSERT(inSuite, root_params.SubjectDN.AddAttribute_MatterICACId(0xabcdabcd) == CHIP_NO_ERROR);
Expand Down

0 comments on commit 2cfe987

Please sign in to comment.