Finished merging main into PR branch
Some checks failed
Dotnet Provisioner Unit Tests / Restore and Run Unit Tests (ubuntu-20.04) (push) Has been cancelled
Dotnet Provisioner Unit Tests / Restore and Run Unit Tests (windows-2022) (push) Has been cancelled
HIRS Build and Unit Test / ACA_Provisioner_Unit_Tests (push) Has been cancelled
HIRS System Tests / DockerTests (push) Has been cancelled
Dotnet Provisioner Unit Tests / Evaluate Tests (push) Has been cancelled

This commit is contained in:
ThatSilentCoder 2025-03-17 15:10:11 -04:00
commit 051d5ac871
4 changed files with 68 additions and 119 deletions

View File

@ -229,7 +229,7 @@ ComponentClass {
} else if (componentMask.equals(UNKNOWN)) { } else if (componentMask.equals(UNKNOWN)) {
this.componentStr = UNKNOWN_STRING; this.componentStr = UNKNOWN_STRING;
} else { } else {
getComponent(componentTypes); setComponentString(componentTypes);
} }
} }
} }
@ -253,12 +253,11 @@ ComponentClass {
} }
/** /**
* Getter for the component associated with the component JSON Object mapped * Sets the component string value based on the provided JSON object's components.
* in the JSON file.
* *
* @param components JSON Object for the categories components * @param components JSON Object components
*/ */
private void getComponent(final JsonObject components) { private void setComponentString(final JsonObject components) {
String typeID; String typeID;
if (components != null) { if (components != null) {
@ -270,5 +269,10 @@ ComponentClass {
} }
} }
} }
// if the component string is still null after doing a lookup
if (componentStr == null) {
componentStr = UNKNOWN_STRING;
}
} }
} }

View File

@ -7,7 +7,7 @@ import java.nio.file.Paths;
import java.util.Objects; import java.util.Objects;
import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNull; import static org.junit.jupiter.api.Assertions.assertNotNull;
/** /**
* Tests for the ComponentClassTest class. * Tests for the ComponentClassTest class.
@ -29,8 +29,8 @@ public class ComponentClassTest {
componentIdentifier); componentIdentifier);
final String resultCategory = instance.getCategoryStr(); final String resultCategory = instance.getCategoryStr();
final String resultComponent = instance.getComponentStr(); final String resultComponent = instance.getComponentStr();
assertEquals(resultComponent, "Unknown"); assertEquals("Unknown", resultComponent);
assertEquals(resultCategory, "None"); assertEquals("None", resultCategory);
} }
/** /**
@ -41,12 +41,12 @@ public class ComponentClassTest {
@Test @Test
public void testGetComponentNoneOther() throws URISyntaxException { public void testGetComponentNoneOther() throws URISyntaxException {
final String componentIdentifier = "00000000"; final String componentIdentifier = "00000000";
ComponentClass instance = new ComponentClass("TCG", Paths.get(Objects.requireNonNull(this.getClass() ComponentClass instance = new ComponentClass("TCG", Paths.get(this.getClass()
.getResource(JSON_FILE)).toURI()), componentIdentifier); .getResource(JSON_FILE).toURI()), componentIdentifier);
final String resultCategory = instance.getCategoryStr(); final String resultCategory = instance.getCategoryStr();
final String resultComponent = instance.getComponentStr(); final String resultComponent = instance.getComponentStr();
assertEquals(resultComponent, "Unknown"); assertEquals("Unknown", resultComponent);
assertEquals(resultCategory, "None"); assertEquals("None", resultCategory);
} }
/** /**
@ -57,12 +57,12 @@ public class ComponentClassTest {
@Test @Test
public void testGetComponentBlank() throws URISyntaxException { public void testGetComponentBlank() throws URISyntaxException {
final String componentIdentifier = ""; final String componentIdentifier = "";
ComponentClass instance = new ComponentClass(Paths.get(Objects.requireNonNull(this.getClass() ComponentClass instance = new ComponentClass(Paths.get(this.getClass()
.getResource(JSON_FILE)).toURI()), componentIdentifier); .getResource(JSON_FILE).toURI()), componentIdentifier);
final String resultCategory = instance.getCategoryStr(); final String resultCategory = instance.getCategoryStr();
final String resultComponent = instance.getComponentStr(); final String resultComponent = instance.getComponentStr();
assertEquals(resultComponent, "Unknown"); assertEquals("Unknown", resultComponent);
assertEquals(resultCategory, "None"); assertEquals("None", resultCategory);
} }
/** /**
@ -73,12 +73,12 @@ public class ComponentClassTest {
@Test @Test
public void testGetComponentNFEx() throws URISyntaxException { public void testGetComponentNFEx() throws URISyntaxException {
final String componentIdentifier = "99999999"; final String componentIdentifier = "99999999";
ComponentClass instance = new ComponentClass(Paths.get(Objects.requireNonNull(this.getClass() ComponentClass instance = new ComponentClass(Paths.get(this.getClass()
.getResource(JSON_FILE)).toURI()), componentIdentifier); .getResource(JSON_FILE).toURI()), componentIdentifier);
final String resultCategory = instance.getCategoryStr(); final String resultCategory = instance.getCategoryStr();
final String resultComponent = instance.getComponentStr(); final String resultComponent = instance.getComponentStr();
assertEquals(resultComponent, "Unknown"); assertEquals("Unknown", resultComponent);
assertEquals(resultCategory, "None"); assertEquals("None", resultCategory);
} }
/** /**
@ -89,12 +89,12 @@ public class ComponentClassTest {
@Test @Test
public void testGetComponentNull() throws URISyntaxException { public void testGetComponentNull() throws URISyntaxException {
final String componentIdentifier = null; final String componentIdentifier = null;
ComponentClass instance = new ComponentClass(Paths.get(Objects.requireNonNull(this.getClass() ComponentClass instance = new ComponentClass(Paths.get(this.getClass()
.getResource(JSON_FILE)).toURI()), componentIdentifier); .getResource(JSON_FILE).toURI()), componentIdentifier);
final String resultCategory = instance.getCategoryStr(); final String resultCategory = instance.getCategoryStr();
final String resultComponent = instance.getComponentStr(); final String resultComponent = instance.getComponentStr();
assertEquals(resultComponent, "Unknown"); assertEquals("Unknown", resultComponent);
assertEquals(resultCategory, "None"); assertEquals("None", resultCategory);
} }
/** /**
@ -106,12 +106,12 @@ public class ComponentClassTest {
@Test @Test
public void testGetComponentStandardQueryTCG() throws URISyntaxException { public void testGetComponentStandardQueryTCG() throws URISyntaxException {
final String componentIdentifier = "0x00040002"; final String componentIdentifier = "0x00040002";
ComponentClass instance = new ComponentClass(Paths.get(Objects.requireNonNull(this.getClass() ComponentClass instance = new ComponentClass(Paths.get(this.getClass()
.getResource(JSON_FILE)).toURI()), componentIdentifier); .getResource(JSON_FILE).toURI()), componentIdentifier);
final String resultCategory = instance.getCategoryStr(); final String resultCategory = instance.getCategoryStr();
final String resultComponent = instance.getComponentStr(); final String resultComponent = instance.getComponentStr();
assertEquals(resultComponent, "SAS Bridgeboard"); assertEquals("SAS Bridgeboard", resultComponent);
assertEquals(resultCategory, "Modules"); assertEquals("Modules", resultCategory);
} }
/** /**
@ -257,8 +257,8 @@ public class ComponentClassTest {
.getResource(JSON_FILE)).toURI()), componentIdentifier); .getResource(JSON_FILE)).toURI()), componentIdentifier);
final String resultCategory = instance.getCategoryStr(); final String resultCategory = instance.getCategoryStr();
final String resultComponent = instance.getComponentStr(); final String resultComponent = instance.getComponentStr();
assertEquals(resultComponent, "SAS Bridgeboard"); assertEquals("SAS Bridgeboard", resultComponent);
assertEquals(resultCategory, "Modules"); assertEquals("Modules", resultCategory);
} }
/** /**
@ -274,8 +274,8 @@ public class ComponentClassTest {
.getResource(JSON_FILE)).toURI()), componentIdentifier); .getResource(JSON_FILE)).toURI()), componentIdentifier);
final String resultCategory = instance.getCategoryStr(); final String resultCategory = instance.getCategoryStr();
final String resultComponent = instance.getComponentStr(); final String resultComponent = instance.getComponentStr();
assertEquals(resultComponent, "SAS Bridgeboard"); assertEquals("SAS Bridgeboard", resultComponent);
assertEquals(resultCategory, "Modules"); assertEquals("Modules", resultCategory);
} }
/** /**
@ -290,8 +290,9 @@ public class ComponentClassTest {
.getResource(JSON_FILE)).toURI()), componentIdentifier); .getResource(JSON_FILE)).toURI()), componentIdentifier);
final String resultCategory = instance.getCategoryStr(); final String resultCategory = instance.getCategoryStr();
final String resultComponent = instance.getComponentStr(); final String resultComponent = instance.getComponentStr();
assertNull(resultComponent); assertNotNull(resultComponent);
assertEquals(resultCategory, "Modules"); assertEquals("Unknown", resultComponent);
assertEquals("Modules", resultCategory);
} }
/** /**
@ -306,8 +307,9 @@ public class ComponentClassTest {
.getResource(JSON_FILE)).toURI()), componentIdentifier); .getResource(JSON_FILE)).toURI()), componentIdentifier);
final String resultCategory = instance.getCategoryStr(); final String resultCategory = instance.getCategoryStr();
final String resultComponent = instance.getComponentStr(); final String resultComponent = instance.getComponentStr();
assertNull(resultComponent); assertNotNull(resultComponent);
assertEquals(resultCategory, "Modules"); assertEquals("Unknown", resultComponent);
assertEquals("Modules", resultCategory);
} }
/** /**
@ -322,7 +324,7 @@ public class ComponentClassTest {
.getResource(JSON_FILE)).toURI()), componentIdentifier); .getResource(JSON_FILE)).toURI()), componentIdentifier);
final String resultCategory = instance.getCategoryStr(); final String resultCategory = instance.getCategoryStr();
final String resultComponent = instance.getComponentStr(); final String resultComponent = instance.getComponentStr();
assertEquals(resultComponent, "Unknown"); assertEquals("Unknown", resultComponent);
assertEquals(resultCategory, "None"); assertEquals("None", resultCategory);
} }
} }

View File

@ -1,10 +1,12 @@
package hirs.attestationca.portal.page; package hirs.attestationca.portal.page;
import hirs.utils.VersionHelper; import hirs.utils.VersionHelper;
import lombok.Getter;
/** /**
* Contains attributes required to display a portal page and its menu link. * Contains attributes required to display a portal page and its menu link.
*/ */
@Getter
public enum Page { public enum Page {
/** /**
@ -73,14 +75,25 @@ public enum Page {
HELP("Help", "ic_live_help"); HELP("Help", "ic_live_help");
private final String title; private final String title;
private final String subtitle; private final String subtitle;
private final String icon; private final String icon;
/**
* Boolean representation of whether the page should display the navigation menu.
*/
private final boolean hasMenu; private final boolean hasMenu;
private final String menuLinkClass; private final String menuLinkClass;
/**
* Boolean representation of whether the page should be displayed in the navigation menu.
*/
private final boolean inMenu; private final boolean inMenu;
private final String prefixPath; private final String prefixPath;
private final String viewName; private final String viewName;
/** /**
@ -150,80 +163,4 @@ public enum Page {
final String icon) { final String icon) {
this(title, null, icon, true, true, null, null); this(title, null, icon, true, true, null, null);
} }
/**
* Returns the title of the page.
*
* @return the title of the page.
*/
public String getTitle() {
return title;
}
/**
* Returns the subtitle of the page.
*
* @return the subtitle of the page.
*/
public String getSubtitle() {
return subtitle;
}
/**
* Returns the base filename of the icon for page. E.g. "ic_my_icon", which will be appended
* with appropriate size string (_24dp/_48dp) and file extension (.png) when used.
*
* @return the base filename of the icon for page.
*/
public String getIcon() {
return icon;
}
/**
* Returns true if the page should be displayed in the navigation menu.
*
* @return true if the page should be displayed in the navigation menu.
*/
public boolean getInMenu() {
return inMenu;
}
/**
* Returns the css class to add to the menu link to display it appropriately. E.g. "first" if
* the link is the first in a group to separate it visually from the previous group.
*
* @return he class to add to the menu link to display it appropriately.
*/
public String getMenuLinkClass() {
return menuLinkClass;
}
/**
* Returns true if the page should display the navigation menu.
*
* @return true if the page should display the navigation menu.
*/
public boolean getHasMenu() {
return hasMenu;
}
/**
* Return the page's view name.
*
* @return the page's view name
*/
public String getViewName() {
return viewName;
}
/**
* Return the page's view name.
*
* @return the page's view name
*/
public String getPrefixPath() {
return prefixPath;
}
} }

View File

@ -349,7 +349,7 @@ public class CertificatePageController extends PageController<NoPageParams> {
records.setRecordsFiltered(caCredentialRepository.findByArchiveFlag(false).size()); records.setRecordsFiltered(caCredentialRepository.findByArchiveFlag(false).size());
log.debug("Returning the size of the list of certificate trust chains: {}", records.size()); log.debug("Returning the size of the list of trust chain certificates: {}", records.size());
return new DataTableResponse<>(records, input); return new DataTableResponse<>(records, input);
} }
case ISSUEDCERTIFICATES -> { case ISSUEDCERTIFICATES -> {
@ -1039,8 +1039,11 @@ public class CertificatePageController extends PageController<NoPageParams> {
ComponentResult componentResult; ComponentResult componentResult;
if (platformCredential.getPlatformConfigurationV1() != null) { if (platformCredential.getPlatformConfigurationV1() != null) {
for (ComponentIdentifier componentIdentifier : platformCredential
.getComponentIdentifiers()) { List<ComponentIdentifier> componentIdentifiers =
platformCredential.getComponentIdentifiers();
for (ComponentIdentifier componentIdentifier : componentIdentifiers) {
componentResult = new ComponentResult(platformCredential.getPlatformSerial(), componentResult = new ComponentResult(platformCredential.getPlatformSerial(),
platformCredential.getSerialNumber().toString(), platformCredential.getSerialNumber().toString(),
platformCredential.getPlatformChainType(), platformCredential.getPlatformChainType(),
@ -1050,8 +1053,11 @@ public class CertificatePageController extends PageController<NoPageParams> {
componentResultRepository.save(componentResult); componentResultRepository.save(componentResult);
} }
} else if (platformCredential.getPlatformConfigurationV2() != null) { } else if (platformCredential.getPlatformConfigurationV2() != null) {
for (ComponentIdentifierV2 componentIdentifierV2 : platformCredential
.getComponentIdentifiersV2()) { List<ComponentIdentifierV2> componentIdentifiersV2 =
platformCredential.getComponentIdentifiersV2();
for (ComponentIdentifierV2 componentIdentifierV2 : componentIdentifiersV2) {
componentResult = new ComponentResult(platformCredential.getPlatformSerial(), componentResult = new ComponentResult(platformCredential.getPlatformSerial(),
platformCredential.getSerialNumber().toString(), platformCredential.getSerialNumber().toString(),
platformCredential.getPlatformChainType(), platformCredential.getPlatformChainType(),