From 939240d284ac0dc6435895456f385c8011033b8f Mon Sep 17 00:00:00 2001 From: iadgovuser58 <124906646+iadgovuser58@users.noreply.github.com> Date: Fri, 26 Apr 2024 12:54:56 -0400 Subject: [PATCH] fixed issue caused by change to version method --- .../report/DeviceInfoReportTest.java | 3 ++- HIRS_AttestationCA/src/test/resources/VERSION | 1 - .../java/hirs/utils/VersionHelperTest.java | 19 ++++--------------- HIRS_Utils/src/test/resources/VERSION | 1 - 4 files changed, 6 insertions(+), 18 deletions(-) delete mode 100644 HIRS_AttestationCA/src/test/resources/VERSION delete mode 100644 HIRS_Utils/src/test/resources/VERSION diff --git a/HIRS_AttestationCA/src/test/java/hirs/attestationca/persist/entity/userdefined/report/DeviceInfoReportTest.java b/HIRS_AttestationCA/src/test/java/hirs/attestationca/persist/entity/userdefined/report/DeviceInfoReportTest.java index 4e5db0ec..c00511eb 100644 --- a/HIRS_AttestationCA/src/test/java/hirs/attestationca/persist/entity/userdefined/report/DeviceInfoReportTest.java +++ b/HIRS_AttestationCA/src/test/java/hirs/attestationca/persist/entity/userdefined/report/DeviceInfoReportTest.java @@ -7,6 +7,7 @@ import hirs.attestationca.persist.entity.userdefined.info.NetworkInfo; import hirs.attestationca.persist.entity.userdefined.info.HardwareInfo; import hirs.attestationca.persist.entity.userdefined.info.FirmwareInfo; +import hirs.utils.VersionHelper; import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertThrows; @@ -21,7 +22,7 @@ public class DeviceInfoReportTest extends AbstractUserdefinedEntityTest { private final HardwareInfo hardwareInfo = createTestHardwareInfo(); private final TPMInfo tpmInfo = createTPMInfo(); - private static final String EXPECTED_CLIENT_VERSION = "Test.Version"; + private static final String EXPECTED_CLIENT_VERSION = VersionHelper.getVersion(); /** * Tests instantiation of a DeviceInfoReport. diff --git a/HIRS_AttestationCA/src/test/resources/VERSION b/HIRS_AttestationCA/src/test/resources/VERSION deleted file mode 100644 index b20b9417..00000000 --- a/HIRS_AttestationCA/src/test/resources/VERSION +++ /dev/null @@ -1 +0,0 @@ -Test.Version diff --git a/HIRS_Utils/src/test/java/hirs/utils/VersionHelperTest.java b/HIRS_Utils/src/test/java/hirs/utils/VersionHelperTest.java index f2cb4c34..bf46033e 100644 --- a/HIRS_Utils/src/test/java/hirs/utils/VersionHelperTest.java +++ b/HIRS_Utils/src/test/java/hirs/utils/VersionHelperTest.java @@ -2,8 +2,7 @@ package hirs.utils; import org.junit.jupiter.api.Test; -import static org.junit.jupiter.api.Assertions.assertTrue; -import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; /** * Tests for VersionHelper. @@ -11,21 +10,11 @@ import static org.junit.jupiter.api.Assertions.assertEquals; public class VersionHelperTest { /** - * Test that case where a version file does not exist. - */ - @Test - public void testGetVersionFail() { - String actual = VersionHelper.getVersion("somefile"); - assertTrue(actual.startsWith("")); - } - - /** - * Test that a version file exists and can be read properly. + * Test that a version file exists in /opt/hirs or /etc/hirs and is not empty. */ @Test public void testGetVersionDefault() { - String expected = "Test.Version"; - String actual = VersionHelper.getVersion("VERSION"); - assertEquals(expected, actual); + String actual = VersionHelper.getVersion(); + assertNotNull(actual); } } diff --git a/HIRS_Utils/src/test/resources/VERSION b/HIRS_Utils/src/test/resources/VERSION deleted file mode 100644 index b20b9417..00000000 --- a/HIRS_Utils/src/test/resources/VERSION +++ /dev/null @@ -1 +0,0 @@ -Test.Version