Skip to content

Commit

Permalink
Merge pull request #760 from nsacyber/v3_issue_759-unittest
Browse files Browse the repository at this point in the history
Fixed issue in DeviceInfoReportTest
  • Loading branch information
iadgovuser58 authored Apr 26, 2024
2 parents 49e53e9 + cf6019d commit c2b2360
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
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;
Expand All @@ -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.
Expand Down
1 change: 0 additions & 1 deletion HIRS_AttestationCA/src/test/resources/VERSION

This file was deleted.

19 changes: 4 additions & 15 deletions HIRS_Utils/src/test/java/hirs/utils/VersionHelperTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,19 @@

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.
*/
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);
}
}
1 change: 0 additions & 1 deletion HIRS_Utils/src/test/resources/VERSION

This file was deleted.

0 comments on commit c2b2360

Please sign in to comment.