Merge pull request #760 from nsacyber/v3_issue_759-unittest

Fixed issue in DeviceInfoReportTest
This commit is contained in:
D2B8CA1B27286366A8607B6858C0565962613D18D0546480078B520CD7AD705A 2024-04-26 17:52:20 +00:00 committed by GitHub
commit c2b2360689
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 6 additions and 18 deletions

View File

@ -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.

View File

@ -1 +0,0 @@
Test.Version

View File

@ -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);
}
}

View File

@ -1 +0,0 @@
Test.Version