From 3fbc6bd30194f1f5d921106b28f1c229031d62ff Mon Sep 17 00:00:00 2001 From: iadgovuser58 <124906646+iadgovuser58@users.noreply.github.com> Date: Wed, 27 Mar 2024 16:13:07 -0400 Subject: [PATCH] fixed error in DeviceInfoReportTest --- .../report/DeviceInfoReportTest.java | 3 ++- HIRS_AttestationCA/src/test/resources/VERSION | 1 - .../src/main/resources/application.properties | 2 +- .../IssuedCertificatesPageControllerTest.java | 9 ++++----- .../test/java/hirs/utils/VersionHelperTest.java | 17 ++++------------- HIRS_Utils/src/test/resources/VERSION | 1 - 6 files changed, 11 insertions(+), 22 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_AttestationCAPortal/src/main/resources/application.properties b/HIRS_AttestationCAPortal/src/main/resources/application.properties index 1f574315..af89b948 100644 --- a/HIRS_AttestationCAPortal/src/main/resources/application.properties +++ b/HIRS_AttestationCAPortal/src/main/resources/application.properties @@ -26,7 +26,7 @@ server.tomcat.accesslog.suffix=.log server.tomcat.accesslog.rotate=true # Tomcat TLS support -server.port=8443 +server.port=8449 server.ssl.enabled=true server.ssl.trust-store-type=JKS server.ssl.trust-store=/etc/hirs/certificates/HIRS/TrustStore.jks diff --git a/HIRS_AttestationCAPortal/src/test/java/hirs/attestationca/portal/page/controllers/IssuedCertificatesPageControllerTest.java b/HIRS_AttestationCAPortal/src/test/java/hirs/attestationca/portal/page/controllers/IssuedCertificatesPageControllerTest.java index d3fd2cbc..127ff91e 100644 --- a/HIRS_AttestationCAPortal/src/test/java/hirs/attestationca/portal/page/controllers/IssuedCertificatesPageControllerTest.java +++ b/HIRS_AttestationCAPortal/src/test/java/hirs/attestationca/portal/page/controllers/IssuedCertificatesPageControllerTest.java @@ -12,6 +12,7 @@ import hirs.attestationca.portal.page.PageControllerTest; import java.io.IOException; import java.util.LinkedList; import java.util.List; + import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; @@ -20,12 +21,9 @@ import org.springframework.test.annotation.Rollback; import org.springframework.test.web.servlet.request.MockMvcRequestBuilders; import static hirs.attestationca.portal.page.Page.ISSUED_CERTIFICATES; import static org.hamcrest.Matchers.hasSize; -//import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content; -//import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.header; -//import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; -//import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*; + /** * Integration tests that test the URL End Points of IssuedCertificatesPageController. */ @@ -135,7 +133,7 @@ public class IssuedCertificatesPageControllerTest extends PageControllerTest { */ @Test @Rollback - public void getDeviceList() throws Exception { + public void getIssuedCertsList() throws Exception { // perform test getMockMvc().perform(MockMvcRequestBuilders.get(pagePath + "/list")) @@ -144,6 +142,7 @@ public class IssuedCertificatesPageControllerTest extends PageControllerTest { .andExpect(jsonPath("$.data[0].platformCredentials", hasSize(platformCredentialList.size()))) .andReturn(); + } /** diff --git a/HIRS_Utils/src/test/java/hirs/utils/VersionHelperTest.java b/HIRS_Utils/src/test/java/hirs/utils/VersionHelperTest.java index f2cb4c34..ce567c46 100644 --- a/HIRS_Utils/src/test/java/hirs/utils/VersionHelperTest.java +++ b/HIRS_Utils/src/test/java/hirs/utils/VersionHelperTest.java @@ -2,6 +2,7 @@ package hirs.utils; import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertTrue; import static org.junit.jupiter.api.Assertions.assertEquals; @@ -11,21 +12,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