Skip to content

Fixed issue in DeviceInfoReportTest #760

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.

Loading