mirror of
https://github.com/nsacyber/HIRS.git
synced 2024-12-22 06:17:56 +00:00
Updated the component class to no longer use ints but instead use only Strings
This commit is contained in:
parent
a555fac716
commit
cac913af11
@ -6,6 +6,8 @@ import com.github.marandus.pciid.service.PciIdsDatabase;
|
|||||||
import com.google.common.base.Strings;
|
import com.google.common.base.Strings;
|
||||||
import hirs.data.persist.certificate.attributes.ComponentIdentifier;
|
import hirs.data.persist.certificate.attributes.ComponentIdentifier;
|
||||||
import hirs.data.persist.certificate.attributes.V2.ComponentIdentifierV2;
|
import hirs.data.persist.certificate.attributes.V2.ComponentIdentifierV2;
|
||||||
|
import org.bouncycastle.asn1.DERUTF8String;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@ -13,7 +15,6 @@ import java.io.InputStream;
|
|||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Vector;
|
import java.util.Vector;
|
||||||
import org.bouncycastle.asn1.DERUTF8String;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provide Java access to PCI IDs.
|
* Provide Java access to PCI IDs.
|
||||||
@ -84,11 +85,11 @@ public final class PciIds {
|
|||||||
/**
|
/**
|
||||||
* The Component Class Value mask for NICs.
|
* The Component Class Value mask for NICs.
|
||||||
*/
|
*/
|
||||||
public static final int COMPCLASS_TCG_CAT_NIC = 0x00090000;
|
public static final String COMPCLASS_TCG_CAT_NIC = "00090000";
|
||||||
/**
|
/**
|
||||||
* The Component Class Value mask for GFX cards.
|
* The Component Class Value mask for GFX cards.
|
||||||
*/
|
*/
|
||||||
public static final int COMPCLASS_TCG_CAT_GFX = 0x00050000;
|
public static final String COMPCLASS_TCG_CAT_GFX = "00050000";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Iterate through all components and translate PCI hardware IDs as necessary. It will only
|
* Iterate through all components and translate PCI hardware IDs as necessary. It will only
|
||||||
@ -125,9 +126,9 @@ public final class PciIds {
|
|||||||
newComponent = component;
|
newComponent = component;
|
||||||
// This can be updated as we get more accurate component class registries and values
|
// This can be updated as we get more accurate component class registries and values
|
||||||
// Component Class Registry not accessible: TCG assumed
|
// Component Class Registry not accessible: TCG assumed
|
||||||
final int compClassValue = component.getComponentClass().getValue();
|
final String compClassValue = component.getComponentClass().getCategoryValue();
|
||||||
if (((compClassValue & COMPCLASS_TCG_CAT_NIC)
|
if (compClassValue.equals(COMPCLASS_TCG_CAT_NIC)
|
||||||
| (compClassValue & COMPCLASS_TCG_CAT_GFX)) > 0) {
|
|| compClassValue.equals(COMPCLASS_TCG_CAT_GFX)) {
|
||||||
DERUTF8String manufacturer = translateVendor(component.getComponentManufacturer());
|
DERUTF8String manufacturer = translateVendor(component.getComponentManufacturer());
|
||||||
DERUTF8String model = translateDevice(component.getComponentManufacturer(),
|
DERUTF8String model = translateDevice(component.getComponentManufacturer(),
|
||||||
component.getComponentModel());
|
component.getComponentModel());
|
||||||
|
@ -22,6 +22,8 @@ import java.nio.file.Path;
|
|||||||
* componentClassRegistry ComponentClassRegistry,
|
* componentClassRegistry ComponentClassRegistry,
|
||||||
* componentClassValue OCTET STRING SIZE(4) ) }
|
* componentClassValue OCTET STRING SIZE(4) ) }
|
||||||
* </pre>
|
* </pre>
|
||||||
|
*
|
||||||
|
* A note for the future.
|
||||||
*/
|
*/
|
||||||
public class ComponentClass {
|
public class ComponentClass {
|
||||||
private static final String TCG_COMPONENT_REGISTRY = "2.23.133.18.3.1";
|
private static final String TCG_COMPONENT_REGISTRY = "2.23.133.18.3.1";
|
||||||
@ -33,24 +35,21 @@ public class ComponentClass {
|
|||||||
private static final String UNKNOWN_STRING = "Unknown";
|
private static final String UNKNOWN_STRING = "Unknown";
|
||||||
private static final String NONE_STRING = "None";
|
private static final String NONE_STRING = "None";
|
||||||
|
|
||||||
// Used to test bytes associated with just the component
|
|
||||||
private static final int COMPONENT_MASK = 0x0000FFFF;
|
|
||||||
// Used to test bytes associated with just the category
|
|
||||||
private static final int CATEGORY_MASK = 0xFFFF0000;
|
|
||||||
|
|
||||||
// Used to indicate that the component string value provided is erroneous
|
// Used to indicate that the component string value provided is erroneous
|
||||||
private static final int ERROR = -1;
|
private static final String ERROR = "-1";
|
||||||
|
private static final int MID_INDEX = 4;
|
||||||
/**
|
/**
|
||||||
* All categories have Other and Unknown as the first 2 values.
|
* All TCG categories have Other and Unknown as the first 2 values.
|
||||||
*/
|
*/
|
||||||
private static final int OTHER = 0;
|
private static final String OTHER = "0000";
|
||||||
private static final int UNKNOWN = 1;
|
private static final String UNKNOWN = "0001";
|
||||||
|
|
||||||
private String category;
|
private String category;
|
||||||
private String component;
|
private String component;
|
||||||
|
private String categoryStr;
|
||||||
|
private String componentStr;
|
||||||
private String registryType;
|
private String registryType;
|
||||||
private int componentIdentifier;
|
private String componentIdentifier;
|
||||||
private String classValueString;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Default class constructor.
|
* Default class constructor.
|
||||||
@ -59,15 +58,6 @@ public class ComponentClass {
|
|||||||
this("TCG", JSON_PATH, UNKNOWN);
|
this("TCG", JSON_PATH, UNKNOWN);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Class Constructor that takes a int representation of the component value.
|
|
||||||
*
|
|
||||||
* @param componentIdentifier component value
|
|
||||||
*/
|
|
||||||
public ComponentClass(final int componentIdentifier) {
|
|
||||||
this(TCG_COMPONENT_REGISTRY, JSON_PATH, componentIdentifier);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class Constructor that takes a String representation of the component
|
* Class Constructor that takes a String representation of the component
|
||||||
* value.
|
* value.
|
||||||
@ -76,21 +66,7 @@ public class ComponentClass {
|
|||||||
* @param componentIdentifier component value
|
* @param componentIdentifier component value
|
||||||
*/
|
*/
|
||||||
public ComponentClass(final String registryOid, final String componentIdentifier) {
|
public ComponentClass(final String registryOid, final String componentIdentifier) {
|
||||||
this(registryOid, JSON_PATH, getComponentIntValue(componentIdentifier));
|
this(registryOid, JSON_PATH, componentIdentifier);
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Class Constructor that takes a String representation of the component
|
|
||||||
* value.
|
|
||||||
*
|
|
||||||
* @param registryOid the decimal notation for the type of registry
|
|
||||||
* @param componentClassPath file path for the json
|
|
||||||
* @param componentIdentifier component value
|
|
||||||
*/
|
|
||||||
public ComponentClass(final String registryOid,
|
|
||||||
final Path componentClassPath,
|
|
||||||
final String componentIdentifier) {
|
|
||||||
this(registryOid, componentClassPath, getComponentIntValue(componentIdentifier));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -101,7 +77,7 @@ public class ComponentClass {
|
|||||||
* @param componentIdentifier component value
|
* @param componentIdentifier component value
|
||||||
*/
|
*/
|
||||||
public ComponentClass(final Path componentClassPath, final String componentIdentifier) {
|
public ComponentClass(final Path componentClassPath, final String componentIdentifier) {
|
||||||
this(TCG_COMPONENT_REGISTRY, componentClassPath, getComponentIntValue(componentIdentifier));
|
this(TCG_COMPONENT_REGISTRY, componentClassPath, componentIdentifier);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -115,10 +91,14 @@ public class ComponentClass {
|
|||||||
*/
|
*/
|
||||||
public ComponentClass(final String registryOid,
|
public ComponentClass(final String registryOid,
|
||||||
final Path componentClassPath,
|
final Path componentClassPath,
|
||||||
final int componentIdentifier) {
|
final String componentIdentifier) {
|
||||||
this.category = UNKNOWN_STRING;
|
this.category = OTHER;
|
||||||
this.component = NONE_STRING;
|
this.component = NONE_STRING;
|
||||||
this.componentIdentifier = componentIdentifier;
|
if (componentIdentifier == null || componentIdentifier.isEmpty()) {
|
||||||
|
this.componentIdentifier = "";
|
||||||
|
} else {
|
||||||
|
this.componentIdentifier = verifyComponentValue(componentIdentifier);
|
||||||
|
}
|
||||||
|
|
||||||
switch (registryOid) {
|
switch (registryOid) {
|
||||||
case TCG_COMPONENT_REGISTRY:
|
case TCG_COMPONENT_REGISTRY:
|
||||||
@ -131,24 +111,36 @@ public class ComponentClass {
|
|||||||
registryType = UNKNOWN_STRING;
|
registryType = UNKNOWN_STRING;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (componentIdentifier) {
|
switch (this.componentIdentifier) {
|
||||||
case OTHER:
|
case OTHER:
|
||||||
this.category = NONE_STRING;
|
this.categoryStr = NONE_STRING;
|
||||||
this.component = OTHER_STRING;
|
this.component = OTHER;
|
||||||
|
this.componentStr = OTHER_STRING;
|
||||||
break;
|
break;
|
||||||
case UNKNOWN:
|
case UNKNOWN:
|
||||||
this.category = NONE_STRING;
|
case "":
|
||||||
this.component = UNKNOWN_STRING;
|
this.categoryStr = NONE_STRING;
|
||||||
|
this.component = UNKNOWN;
|
||||||
|
this.componentStr = UNKNOWN_STRING;
|
||||||
break;
|
break;
|
||||||
case ERROR:
|
case ERROR:
|
||||||
// Number Format Exception
|
// Number Format Exception
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
getCategory(JsonUtils.getSpecificJsonObject(componentClassPath, registryType));
|
this.category = this.componentIdentifier.substring(0, MID_INDEX) + this.category;
|
||||||
|
this.component = OTHER + this.componentIdentifier.substring(MID_INDEX);
|
||||||
|
findStringValues(JsonUtils.getSpecificJsonObject(componentClassPath, registryType));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
this.classValueString = String.valueOf(componentIdentifier);
|
/**
|
||||||
|
* Getter for the Category complete value.
|
||||||
|
*
|
||||||
|
* @return string value of the category
|
||||||
|
*/
|
||||||
|
public final String getCategoryValue() {
|
||||||
|
return category;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -157,7 +149,7 @@ public class ComponentClass {
|
|||||||
* @return string value of the category
|
* @return string value of the category
|
||||||
*/
|
*/
|
||||||
public final String getCategory() {
|
public final String getCategory() {
|
||||||
return category;
|
return categoryStr;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -166,25 +158,17 @@ public class ComponentClass {
|
|||||||
* @return string value of the component
|
* @return string value of the component
|
||||||
*/
|
*/
|
||||||
public final String getComponent() {
|
public final String getComponent() {
|
||||||
return component;
|
return componentStr;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Getter for the Component Class Value.
|
* Getter for the Component Class Value.
|
||||||
* @return int value of the component class.
|
* @return int value of the component class.
|
||||||
*/
|
*/
|
||||||
public final int getValue() {
|
public final String getValue() {
|
||||||
return componentIdentifier;
|
return componentIdentifier;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Getter for the Component Class Value as a string.
|
|
||||||
* @return String representation of the class.
|
|
||||||
*/
|
|
||||||
public final String getClassValueString() {
|
|
||||||
return classValueString;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is the main way this class will be referenced and how it
|
* This is the main way this class will be referenced and how it
|
||||||
* will be displayed on the portal.
|
* will be displayed on the portal.
|
||||||
@ -193,10 +177,10 @@ public class ComponentClass {
|
|||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
String resultString;
|
String resultString;
|
||||||
if (component.equals(UNKNOWN_STRING) || component.equals(OTHER_STRING)) {
|
if (componentStr.equals(UNKNOWN_STRING) || component.equals(OTHER_STRING)) {
|
||||||
resultString = String.format("%s%n%s", registryType, category);
|
resultString = String.format("%s%n%s", registryType, categoryStr);
|
||||||
} else {
|
} else {
|
||||||
resultString = String.format("%s%n%s - %s", registryType, category, component);
|
resultString = String.format("%s%n%s - %s", registryType, categoryStr, componentStr);
|
||||||
}
|
}
|
||||||
return resultString;
|
return resultString;
|
||||||
}
|
}
|
||||||
@ -207,54 +191,72 @@ public class ComponentClass {
|
|||||||
* @param categories a JSON object associated with mapped categories in file
|
* @param categories a JSON object associated with mapped categories in file
|
||||||
* {}@link componentIdentifier}.
|
* {}@link componentIdentifier}.
|
||||||
*/
|
*/
|
||||||
private void getCategory(final JsonObject categories) {
|
private void findStringValues(final JsonObject categories) {
|
||||||
int componentID;
|
String categoryID;
|
||||||
|
String componentMask;
|
||||||
|
boolean found = false;
|
||||||
|
|
||||||
if (categories != null) {
|
if (categories != null) {
|
||||||
for (String name : categories.names()) {
|
for (String name : categories.names()) {
|
||||||
componentID = Integer.decode(categories.get(name).asObject().get("ID").asString());
|
categoryID = verifyComponentValue(categories.get(name)
|
||||||
|
.asObject().get("ID").asString());
|
||||||
|
componentMask = componentIdentifier.substring(MID_INDEX);
|
||||||
// check for the correct flag
|
// check for the correct flag
|
||||||
if ((componentIdentifier & CATEGORY_MASK) == componentID) {
|
if (categoryMatch(componentIdentifier.substring(0, MID_INDEX),
|
||||||
|
categoryID.substring(0, MID_INDEX))) {
|
||||||
|
found = true;
|
||||||
JsonObject componentTypes = categories.get(name)
|
JsonObject componentTypes = categories.get(name)
|
||||||
.asObject().get("Types").asObject();
|
.asObject().get("Types").asObject();
|
||||||
category = name;
|
categoryStr = name;
|
||||||
|
|
||||||
switch (componentIdentifier & COMPONENT_MASK) {
|
switch (componentMask) {
|
||||||
case OTHER:
|
case OTHER:
|
||||||
component = OTHER_STRING;
|
componentStr = OTHER_STRING;
|
||||||
break;
|
break;
|
||||||
case UNKNOWN:
|
case UNKNOWN:
|
||||||
component = UNKNOWN_STRING;
|
componentStr = UNKNOWN_STRING;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
getComponent(componentID, componentTypes);
|
getComponent(componentTypes);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!found) {
|
||||||
|
this.categoryStr = NONE_STRING;
|
||||||
|
this.componentStr = UNKNOWN_STRING;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the value of the comparison between a category and the what's in the id.
|
||||||
|
* @param category the category to compare
|
||||||
|
* @param componentId the id value to compare
|
||||||
|
* @return true if they match
|
||||||
|
*/
|
||||||
|
public boolean categoryMatch(final String category, final String componentId) {
|
||||||
|
return category.equals(componentId);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Getter for the component associated with the component JSON Object mapped
|
* Getter for the component associated with the component JSON Object mapped
|
||||||
* in the JSON file.
|
* in the JSON file.
|
||||||
*
|
*
|
||||||
* @param componentID the ID associated with the category
|
|
||||||
* @param components JSON Object for the categories components
|
* @param components JSON Object for the categories components
|
||||||
*/
|
*/
|
||||||
private void getComponent(final int componentID, final JsonObject components) {
|
private void getComponent(final JsonObject components) {
|
||||||
int typeID, testID;
|
String typeID;
|
||||||
|
|
||||||
if (components != null) {
|
if (components != null) {
|
||||||
for (Member member : components) {
|
for (Member member : components) {
|
||||||
typeID = Integer.decode(member.getName());
|
typeID = verifyComponentValue(member.getName());
|
||||||
testID = componentID + typeID;
|
|
||||||
|
|
||||||
if (componentIdentifier == testID) {
|
if (component.equals(typeID)) {
|
||||||
component = member.getValue().asString();
|
componentStr = member.getValue().asString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -264,20 +266,18 @@ public class ComponentClass {
|
|||||||
* @param component string representation of the component ID
|
* @param component string representation of the component ID
|
||||||
* @return the int representation of the component
|
* @return the int representation of the component
|
||||||
*/
|
*/
|
||||||
private static int getComponentIntValue(final String component) {
|
private static String verifyComponentValue(final String component) {
|
||||||
int componentValue = ERROR;
|
String componentValue = ERROR;
|
||||||
|
|
||||||
if (component != null) {
|
if (component != null) {
|
||||||
try {
|
try {
|
||||||
if (component.contains("x")) {
|
if (component.contains("x")) {
|
||||||
componentValue = Integer.decode(component);
|
componentValue = component.substring(component.indexOf("x") + 1);
|
||||||
} else {
|
} else {
|
||||||
if (component.contains("#")) {
|
if (component.contains("#")) {
|
||||||
componentValue = Integer.parseInt(
|
componentValue = component.replace("#", "");
|
||||||
component.replace("#", ""));
|
|
||||||
} else {
|
} else {
|
||||||
componentValue = Integer.parseInt(
|
return component;
|
||||||
component);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (NumberFormatException nfEx) {
|
} catch (NumberFormatException nfEx) {
|
||||||
|
@ -649,10 +649,10 @@ public final class SupplyChainCredentialValidator implements CredentialValidator
|
|||||||
boolean classFound;
|
boolean classFound;
|
||||||
|
|
||||||
for (ComponentIdentifier ci : absentSerialNum) {
|
for (ComponentIdentifier ci : absentSerialNum) {
|
||||||
classValue = ciV2.getComponentClass().getClassValueString();
|
classValue = ciV2.getComponentClass().getValue();
|
||||||
baseCiV2 = (ComponentIdentifierV2) ci;
|
baseCiV2 = (ComponentIdentifierV2) ci;
|
||||||
classFound = classValue.equals(baseCiV2.getComponentClass()
|
classFound = classValue.equals(baseCiV2.getComponentClass()
|
||||||
.getClassValueString());
|
.getValue());
|
||||||
if (classFound) {
|
if (classFound) {
|
||||||
if (isMatch(ciV2, baseCiV2)) {
|
if (isMatch(ciV2, baseCiV2)) {
|
||||||
if (ciV2.isAdded()) {
|
if (ciV2.isAdded()) {
|
||||||
@ -751,7 +751,7 @@ public final class SupplyChainCredentialValidator implements CredentialValidator
|
|||||||
for (ComponentIdentifier cId : fullDeltaChainComponents) {
|
for (ComponentIdentifier cId : fullDeltaChainComponents) {
|
||||||
ciV2 = (ComponentIdentifierV2) cId;
|
ciV2 = (ComponentIdentifierV2) cId;
|
||||||
if (cInfo.getComponentClass().contains(
|
if (cInfo.getComponentClass().contains(
|
||||||
ciV2.getComponentClass().getClassValueString())
|
ciV2.getComponentClass().getValue())
|
||||||
&& isMatch(cId, cInfo)) {
|
&& isMatch(cId, cInfo)) {
|
||||||
subCompIdList.remove(cId);
|
subCompIdList.remove(cId);
|
||||||
subCompInfoList.remove(cInfo);
|
subCompInfoList.remove(cInfo);
|
||||||
|
@ -19,13 +19,13 @@ public class ComponentClassTest {
|
|||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testGetComponentNoneUNK() throws URISyntaxException {
|
public void testGetComponentNoneUNK() throws URISyntaxException {
|
||||||
int componentIdentifier = 1;
|
String componentIdentifier = "00000001";
|
||||||
ComponentClass instance = new ComponentClass("TCG", Paths.get(this.getClass()
|
ComponentClass instance = new ComponentClass("TCG", Paths.get(this.getClass()
|
||||||
.getResource(JSON_FILE).toURI()), componentIdentifier);
|
.getResource(JSON_FILE).toURI()), componentIdentifier);
|
||||||
String resultCategory = instance.getCategory();
|
String resultCategory = instance.getCategory();
|
||||||
String resultComponent = instance.getComponent();
|
String resultComponent = instance.getComponent();
|
||||||
Assert.assertEquals("Unknown", resultComponent);
|
Assert.assertEquals(resultComponent, "Unknown");
|
||||||
Assert.assertEquals("None", resultCategory);
|
Assert.assertEquals(resultCategory, "None");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -34,13 +34,13 @@ public class ComponentClassTest {
|
|||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testGetComponentNoneOther() throws URISyntaxException {
|
public void testGetComponentNoneOther() throws URISyntaxException {
|
||||||
int componentIdentifier = 0;
|
String componentIdentifier = "00000000";
|
||||||
ComponentClass instance = new ComponentClass("TCG", Paths.get(this.getClass()
|
ComponentClass instance = new ComponentClass("TCG", Paths.get(this.getClass()
|
||||||
.getResource(JSON_FILE).toURI()), componentIdentifier);
|
.getResource(JSON_FILE).toURI()), componentIdentifier);
|
||||||
String resultCategory = instance.getCategory();
|
String resultCategory = instance.getCategory();
|
||||||
String resultComponent = instance.getComponent();
|
String resultComponent = instance.getComponent();
|
||||||
Assert.assertEquals("Other", resultComponent);
|
Assert.assertEquals(resultComponent, "Unknown");
|
||||||
Assert.assertEquals("None", resultCategory);
|
Assert.assertEquals(resultCategory, "None");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -54,8 +54,8 @@ public class ComponentClassTest {
|
|||||||
.getResource(JSON_FILE).toURI()), componentIdentifier);
|
.getResource(JSON_FILE).toURI()), componentIdentifier);
|
||||||
String resultCategory = instance.getCategory();
|
String resultCategory = instance.getCategory();
|
||||||
String resultComponent = instance.getComponent();
|
String resultComponent = instance.getComponent();
|
||||||
Assert.assertEquals("None", resultComponent);
|
Assert.assertEquals(resultComponent, "Unknown");
|
||||||
Assert.assertEquals("Unknown", resultCategory);
|
Assert.assertEquals(resultCategory, "None");
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Test of getComponent method, of class ComponentClass.
|
* Test of getComponent method, of class ComponentClass.
|
||||||
@ -63,13 +63,13 @@ public class ComponentClassTest {
|
|||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testGetComponentNFEx() throws URISyntaxException {
|
public void testGetComponentNFEx() throws URISyntaxException {
|
||||||
String componentIdentifier = "HIRS";
|
String componentIdentifier = "99999999";
|
||||||
ComponentClass instance = new ComponentClass(Paths.get(this.getClass()
|
ComponentClass instance = new ComponentClass(Paths.get(this.getClass()
|
||||||
.getResource(JSON_FILE).toURI()), componentIdentifier);
|
.getResource(JSON_FILE).toURI()), componentIdentifier);
|
||||||
String resultCategory = instance.getCategory();
|
String resultCategory = instance.getCategory();
|
||||||
String resultComponent = instance.getComponent();
|
String resultComponent = instance.getComponent();
|
||||||
Assert.assertEquals("None", resultComponent);
|
Assert.assertEquals(resultComponent, "Unknown");
|
||||||
Assert.assertEquals("Unknown", resultCategory);
|
Assert.assertEquals(resultCategory, "None");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -83,8 +83,8 @@ public class ComponentClassTest {
|
|||||||
.getResource(JSON_FILE).toURI()), componentIdentifier);
|
.getResource(JSON_FILE).toURI()), componentIdentifier);
|
||||||
String resultCategory = instance.getCategory();
|
String resultCategory = instance.getCategory();
|
||||||
String resultComponent = instance.getComponent();
|
String resultComponent = instance.getComponent();
|
||||||
Assert.assertEquals("None", resultComponent);
|
Assert.assertEquals(resultComponent, "Unknown");
|
||||||
Assert.assertEquals("Unknown", resultCategory);
|
Assert.assertEquals(resultCategory, "None");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -98,8 +98,8 @@ public class ComponentClassTest {
|
|||||||
.getResource(JSON_FILE).toURI()), componentIdentifier);
|
.getResource(JSON_FILE).toURI()), componentIdentifier);
|
||||||
String resultCategory = instance.getCategory();
|
String resultCategory = instance.getCategory();
|
||||||
String resultComponent = instance.getComponent();
|
String resultComponent = instance.getComponent();
|
||||||
Assert.assertEquals("SAS Bridgeboard", resultComponent);
|
Assert.assertEquals(resultComponent, "SAS Bridgeboard");
|
||||||
Assert.assertEquals("Modules", resultCategory);
|
Assert.assertEquals(resultCategory, "Modules");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -123,13 +123,13 @@ public class ComponentClassTest {
|
|||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testGetComponentStandardQueryIntTCG() throws URISyntaxException {
|
public void testGetComponentStandardQueryIntTCG() throws URISyntaxException {
|
||||||
int componentIdentifier = 0x00040002;
|
String componentIdentifier = "0x00040002";
|
||||||
ComponentClass instance = new ComponentClass("2.23.133.18.3.1", Paths.get(this.getClass()
|
ComponentClass instance = new ComponentClass("2.23.133.18.3.1", Paths.get(this.getClass()
|
||||||
.getResource(JSON_FILE).toURI()), componentIdentifier);
|
.getResource(JSON_FILE).toURI()), componentIdentifier);
|
||||||
String resultCategory = instance.getCategory();
|
String resultCategory = instance.getCategory();
|
||||||
String resultComponent = instance.getComponent();
|
String resultComponent = instance.getComponent();
|
||||||
Assert.assertEquals("SAS Bridgeboard", resultComponent);
|
Assert.assertEquals(resultComponent, "SAS Bridgeboard");
|
||||||
Assert.assertEquals("Modules", resultCategory);
|
Assert.assertEquals(resultCategory, "Modules");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -138,7 +138,7 @@ public class ComponentClassTest {
|
|||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testGetComponentStandardQueryIntSMBIOS() throws URISyntaxException {
|
public void testGetComponentStandardQueryIntSMBIOS() throws URISyntaxException {
|
||||||
int componentIdentifier = 0x00040003;
|
String componentIdentifier = "0x00040003";
|
||||||
ComponentClass instance = new ComponentClass("2.23.133.18.3.3", Paths.get(this.getClass()
|
ComponentClass instance = new ComponentClass("2.23.133.18.3.3", Paths.get(this.getClass()
|
||||||
.getResource(JSON_FILE).toURI()), componentIdentifier);
|
.getResource(JSON_FILE).toURI()), componentIdentifier);
|
||||||
String resultCategory = instance.getCategory();
|
String resultCategory = instance.getCategory();
|
||||||
@ -153,7 +153,7 @@ public class ComponentClassTest {
|
|||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testGetComponentStandardQueryIntOther() throws URISyntaxException {
|
public void testGetComponentStandardQueryIntOther() throws URISyntaxException {
|
||||||
int componentIdentifier = 0x00040000;
|
String componentIdentifier = "0x00040000";
|
||||||
ComponentClass instance = new ComponentClass("2.23.133.18.3.1", Paths.get(this.getClass()
|
ComponentClass instance = new ComponentClass("2.23.133.18.3.1", Paths.get(this.getClass()
|
||||||
.getResource(JSON_FILE).toURI()), componentIdentifier);
|
.getResource(JSON_FILE).toURI()), componentIdentifier);
|
||||||
String resultCategory = instance.getCategory();
|
String resultCategory = instance.getCategory();
|
||||||
@ -168,7 +168,7 @@ public class ComponentClassTest {
|
|||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testGetComponentStandardQueryIntUnk() throws URISyntaxException {
|
public void testGetComponentStandardQueryIntUnk() throws URISyntaxException {
|
||||||
int componentIdentifier = 0x00040001;
|
String componentIdentifier = "0x00040001";
|
||||||
ComponentClass instance = new ComponentClass("2.23.133.18.3.1", Paths.get(this.getClass()
|
ComponentClass instance = new ComponentClass("2.23.133.18.3.1", Paths.get(this.getClass()
|
||||||
.getResource(JSON_FILE).toURI()), componentIdentifier);
|
.getResource(JSON_FILE).toURI()), componentIdentifier);
|
||||||
String resultCategory = instance.getCategory();
|
String resultCategory = instance.getCategory();
|
||||||
@ -218,8 +218,8 @@ public class ComponentClassTest {
|
|||||||
.getResource(JSON_FILE).toURI()), componentIdentifier);
|
.getResource(JSON_FILE).toURI()), componentIdentifier);
|
||||||
String resultCategory = instance.getCategory();
|
String resultCategory = instance.getCategory();
|
||||||
String resultComponent = instance.getComponent();
|
String resultComponent = instance.getComponent();
|
||||||
Assert.assertEquals("SAS Bridgeboard", resultComponent);
|
Assert.assertEquals(resultComponent, "SAS Bridgeboard");
|
||||||
Assert.assertEquals("Modules", resultCategory);
|
Assert.assertEquals(resultCategory, "Modules");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -233,8 +233,8 @@ public class ComponentClassTest {
|
|||||||
.getResource(JSON_FILE).toURI()), componentIdentifier);
|
.getResource(JSON_FILE).toURI()), componentIdentifier);
|
||||||
String resultCategory = instance.getCategory();
|
String resultCategory = instance.getCategory();
|
||||||
String resultComponent = instance.getComponent();
|
String resultComponent = instance.getComponent();
|
||||||
Assert.assertEquals("SAS Bridgeboard", resultComponent);
|
Assert.assertEquals(resultComponent, "SAS Bridgeboard");
|
||||||
Assert.assertEquals("Modules", resultCategory);
|
Assert.assertEquals(resultCategory, "Modules");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -248,8 +248,8 @@ public class ComponentClassTest {
|
|||||||
.getResource(JSON_FILE).toURI()), componentIdentifier);
|
.getResource(JSON_FILE).toURI()), componentIdentifier);
|
||||||
String resultCategory = instance.getCategory();
|
String resultCategory = instance.getCategory();
|
||||||
String resultComponent = instance.getComponent();
|
String resultComponent = instance.getComponent();
|
||||||
Assert.assertEquals("None", resultComponent);
|
Assert.assertNull(resultComponent);
|
||||||
Assert.assertEquals("Modules", resultCategory);
|
Assert.assertEquals(resultCategory, "Modules");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -263,8 +263,8 @@ public class ComponentClassTest {
|
|||||||
.getResource(JSON_FILE).toURI()), componentIdentifier);
|
.getResource(JSON_FILE).toURI()), componentIdentifier);
|
||||||
String resultCategory = instance.getCategory();
|
String resultCategory = instance.getCategory();
|
||||||
String resultComponent = instance.getComponent();
|
String resultComponent = instance.getComponent();
|
||||||
Assert.assertEquals("None", resultComponent);
|
Assert.assertNull(resultComponent);
|
||||||
Assert.assertEquals("Modules", resultCategory);
|
Assert.assertEquals(resultCategory, "Modules");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -278,7 +278,7 @@ public class ComponentClassTest {
|
|||||||
.getResource(JSON_FILE).toURI()), componentIdentifier);
|
.getResource(JSON_FILE).toURI()), componentIdentifier);
|
||||||
String resultCategory = instance.getCategory();
|
String resultCategory = instance.getCategory();
|
||||||
String resultComponent = instance.getComponent();
|
String resultComponent = instance.getComponent();
|
||||||
Assert.assertEquals("None", resultComponent);
|
Assert.assertEquals(resultComponent, "Unknown");
|
||||||
Assert.assertEquals("Unknown", resultCategory);
|
Assert.assertEquals(resultCategory, "None");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user