From e8814af9f7ea33bb8861313fb1fa29d2f4b6ad8e Mon Sep 17 00:00:00 2001 From: iadgovuser62 Date: Tue, 17 Oct 2023 12:10:51 -0400 Subject: [PATCH] Adding TPMSecurityAssertionsTest --- .../attributes/TPMSecurityAssertionsTest.java | 54 +++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 HIRS_AttestationCA/src/test/java/hirs/attestationca/persist/entity/userdefined/certificate/attributes/TPMSecurityAssertionsTest.java diff --git a/HIRS_AttestationCA/src/test/java/hirs/attestationca/persist/entity/userdefined/certificate/attributes/TPMSecurityAssertionsTest.java b/HIRS_AttestationCA/src/test/java/hirs/attestationca/persist/entity/userdefined/certificate/attributes/TPMSecurityAssertionsTest.java new file mode 100644 index 000000000..e389ca07d --- /dev/null +++ b/HIRS_AttestationCA/src/test/java/hirs/attestationca/persist/entity/userdefined/certificate/attributes/TPMSecurityAssertionsTest.java @@ -0,0 +1,54 @@ +package hirs.attestationca.persist.entity.userdefined.certificate.attributes; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.fail; +import org.junit.jupiter.api.Test; + +/** + * Tests for the TPMSecurityAssertions class. + */ +public class TPMSecurityAssertionsTest { + + /** + * Tests that enum integer association matches the TCG spec for the EK Generation + * Type enum. + */ + @Test + public void testEkGenTypeEnum() { + assertEquals(TPMSecurityAssertions.EkGenerationType.values()[0], + TPMSecurityAssertions.EkGenerationType.INTERNAL); + assertEquals(TPMSecurityAssertions.EkGenerationType.values()[1], + TPMSecurityAssertions.EkGenerationType.INJECTED); + assertEquals(TPMSecurityAssertions.EkGenerationType.values()[2], + TPMSecurityAssertions.EkGenerationType.INTERNAL_REVOCABLE); + assertEquals(TPMSecurityAssertions.EkGenerationType.values()[3], + TPMSecurityAssertions.EkGenerationType.INJECTED_REVOCABLE); + try { + assertNull(TPMSecurityAssertions.EkGenerationType.values()[4]); + fail(); + } catch (ArrayIndexOutOfBoundsException e) { + return; + } + } + + /** + * Tests that enum integer association matches the TCG spec for the Generation + * Location enum. + */ + @Test + public void testGenLocationEnum() { + assertEquals(TPMSecurityAssertions.EkGenerationLocation.values()[0], + TPMSecurityAssertions.EkGenerationLocation.TPM_MANUFACTURER); + assertEquals(TPMSecurityAssertions.EkGenerationLocation.values()[1], + TPMSecurityAssertions.EkGenerationLocation.PLATFORM_MANUFACTURER); + assertEquals(TPMSecurityAssertions.EkGenerationLocation.values()[2], + TPMSecurityAssertions.EkGenerationLocation.EK_CERT_SIGNER); + try { + assertNull(TPMSecurityAssertions.EkGenerationLocation.values()[3]); + fail(); + } catch (ArrayIndexOutOfBoundsException e) { + return; + } + } +} \ No newline at end of file