99
99
"javax.security.auth.*" })
100
100
public class SupplyChainCredentialValidatorTest {
101
101
102
+ private static final String JSON_FILE = "/config/component-class.json" ;
102
103
private static final String SAMPLE_PACCOR_OUTPUT_TXT = "sample_paccor_output.txt" ;
103
104
private static final String SAMPLE_PACCOR_OUTPUT_NOT_SPECIFIED_TXT
104
105
= "sample_paccor_output_not_specified_values.txt" ;
@@ -2028,29 +2029,41 @@ public final void testValidateDeltaPlatformCredentialAttributes()
2028
2029
PlatformCredential delta1 = mock (PlatformCredential .class );
2029
2030
PlatformCredential delta2 = mock (PlatformCredential .class );
2030
2031
2031
- ComponentIdentifier compId1 = new ComponentIdentifier (new DERUTF8String ("Intel" ),
2032
+ ComponentIdentifierV2 compId1 = new ComponentIdentifierV2 (
2033
+ new ComponentClass (Paths .get (this .getClass ()
2034
+ .getResource (JSON_FILE ).toURI ()), "0x00010002" ),
2035
+ new DERUTF8String ("Intel" ),
2032
2036
new DERUTF8String ("Core i7" ), new DERUTF8String ("Not Specified" ),
2033
2037
new DERUTF8String ("Intel(R) Core(TM) i7-4790 CPU @ 3.60GHz" ), null ,
2034
- ASN1Boolean .TRUE , new ArrayList <>(0 ));
2035
- ComponentIdentifier compId2 = new ComponentIdentifier (
2038
+ ASN1Boolean .TRUE , new ArrayList <>(0 ), null , null ,
2039
+ null );
2040
+ ComponentIdentifierV2 compId2 = new ComponentIdentifierV2 (
2041
+ new ComponentClass (Paths .get (this .getClass ()
2042
+ .getResource (JSON_FILE ).toURI ()), "0x00050004" ),
2036
2043
new DERUTF8String ("Intel Corporation" ),
2037
2044
new DERUTF8String ("Ethernet Connection I217-V-faulty" ),
2038
2045
new DERUTF8String ("23:94:17:ba:86:5e" ), new DERUTF8String ("00" ), null ,
2039
- ASN1Boolean .FALSE , new ArrayList <>(0 ));
2040
- ComponentIdentifier compId3 = new ComponentIdentifier (
2046
+ ASN1Boolean .FALSE , new ArrayList <>(0 ), null , null ,
2047
+ null );
2048
+ ComponentIdentifierV2 compId3 = new ComponentIdentifierV2 (
2049
+ new ComponentClass (Paths .get (this .getClass ()
2050
+ .getResource (JSON_FILE ).toURI ()), "0x00090002" ),
2041
2051
new DERUTF8String ("Intel Corporation" ),
2042
2052
new DERUTF8String ("82580 Gigabit Network Connection-faulty" ),
2043
2053
new DERUTF8String ("90:e2:ba:31:83:10" ), new DERUTF8String ("" ), null ,
2044
- ASN1Boolean .FALSE , new ArrayList <>(0 ));
2054
+ ASN1Boolean .FALSE , new ArrayList <>(0 ), null , null ,
2055
+ null );
2045
2056
ComponentIdentifierV2 deltaCompId2 = new ComponentIdentifierV2 (
2046
- new ComponentClass (),
2057
+ new ComponentClass (Paths .get (this .getClass ()
2058
+ .getResource (JSON_FILE ).toURI ()), "0x00050004" ),
2047
2059
new DERUTF8String ("Intel Corporation" ),
2048
2060
new DERUTF8String ("Ethernet Connection I217-V" ),
2049
2061
new DERUTF8String ("23:94:17:ba:86:5e" ), new DERUTF8String ("00" ), null ,
2050
2062
ASN1Boolean .FALSE , new ArrayList <>(0 ), null , null ,
2051
2063
AttributeStatus .ADDED );
2052
2064
ComponentIdentifierV2 deltaCompId3 = new ComponentIdentifierV2 (
2053
- new ComponentClass (),
2065
+ new ComponentClass (Paths .get (this .getClass ()
2066
+ .getResource (JSON_FILE ).toURI ()), "0x00090002" ),
2054
2067
new DERUTF8String ("Intel Corporation" ),
2055
2068
new DERUTF8String ("82580 Gigabit Network Connection" ),
2056
2069
new DERUTF8String ("90:e2:ba:31:83:10" ), new DERUTF8String ("" ), null ,
@@ -2060,6 +2073,7 @@ public final void testValidateDeltaPlatformCredentialAttributes()
2060
2073
ComponentIdentifierV2 ciV21Faulty = new ComponentIdentifierV2 ();
2061
2074
ComponentIdentifierV2 ciV22Faulty = new ComponentIdentifierV2 ();
2062
2075
ciV21Faulty .setComponentManufacturer (compId2 .getComponentManufacturer ());
2076
+ ciV21Faulty .setComponentClass (compId2 .getComponentClass ());
2063
2077
ciV21Faulty .setComponentModel (compId2 .getComponentModel ());
2064
2078
ciV21Faulty .setComponentSerial (compId2 .getComponentSerial ());
2065
2079
ciV21Faulty .setComponentRevision (compId2 .getComponentRevision ());
@@ -2068,6 +2082,7 @@ public final void testValidateDeltaPlatformCredentialAttributes()
2068
2082
ciV21Faulty .setComponentAddress (compId2 .getComponentAddress ());
2069
2083
ciV21Faulty .setAttributeStatus (AttributeStatus .REMOVED );
2070
2084
ciV22Faulty .setComponentManufacturer (compId3 .getComponentManufacturer ());
2085
+ ciV22Faulty .setComponentClass (compId3 .getComponentClass ());
2071
2086
ciV22Faulty .setComponentModel (compId3 .getComponentModel ());
2072
2087
ciV22Faulty .setComponentSerial (compId3 .getComponentSerial ());
2073
2088
ciV22Faulty .setComponentRevision (compId3 .getComponentRevision ());
@@ -2094,17 +2109,17 @@ public final void testValidateDeltaPlatformCredentialAttributes()
2094
2109
when (base .getManufacturer ()).thenReturn ("innotek GmbH" );
2095
2110
when (base .getModel ()).thenReturn ("VirtualBox" );
2096
2111
when (base .getVersion ()).thenReturn ("1.2" );
2097
- when (base .getPlatformSerial ()).thenReturn ("0 " );
2098
- when (delta1 .getPlatformSerial ()).thenReturn ("0 " );
2099
- when (delta2 .getPlatformSerial ()).thenReturn ("0 " );
2112
+ when (base .getPlatformSerial ()).thenReturn ("62UIAE5 " );
2113
+ when (delta1 .getPlatformSerial ()).thenReturn ("62UIAE5 " );
2114
+ when (delta2 .getPlatformSerial ()).thenReturn ("62UIAE5 " );
2100
2115
when (base .getPlatformType ()).thenReturn ("base" );
2101
2116
when (delta1 .getPlatformType ()).thenReturn ("delta" );
2102
2117
when (delta2 .getPlatformType ()).thenReturn ("delta" );
2103
- when (base .getSerialNumber ()).thenReturn (BigInteger .ZERO );
2104
- when (delta1 .getSerialNumber ()).thenReturn (BigInteger .ONE );
2105
- when (delta2 .getSerialNumber ()).thenReturn (BigInteger .TEN );
2106
- when (delta1 .getHolderSerialNumber ()).thenReturn (BigInteger .ZERO );
2107
- when (delta2 .getHolderSerialNumber ()).thenReturn (BigInteger .ONE );
2118
+ when (base .getSerialNumber ()).thenReturn (BigInteger .valueOf ( 01 ) );
2119
+ when (delta1 .getSerialNumber ()).thenReturn (BigInteger .valueOf ( 39821 ) );
2120
+ when (delta2 .getSerialNumber ()).thenReturn (BigInteger .valueOf ( 39822 ) );
2121
+ when (delta1 .getHolderSerialNumber ()).thenReturn (BigInteger .valueOf ( 02 ) );
2122
+ when (delta2 .getHolderSerialNumber ()).thenReturn (BigInteger .valueOf ( 39821 ) );
2108
2123
when (base .getComponentIdentifiers ()).thenReturn (compList );
2109
2124
when (delta1 .getComponentIdentifiers ()).thenReturn (delta1List );
2110
2125
when (delta2 .getComponentIdentifiers ()).thenReturn (delta2List );
@@ -2129,9 +2144,9 @@ public final void testValidateDeltaPlatformCredentialAttributes()
2129
2144
AppraisalStatus result = supplyChainCredentialValidator
2130
2145
.validateDeltaPlatformCredentialAttributes (delta2 ,
2131
2146
deviceInfoReport , base , chainCredentials );
2132
- Assert .assertEquals (result .getAppStatus (), AppraisalStatus .Status .PASS );
2133
2147
Assert .assertEquals (result .getMessage (),
2134
2148
SupplyChainCredentialValidator .PLATFORM_ATTRIBUTES_VALID );
2149
+ Assert .assertEquals (result .getAppStatus (), AppraisalStatus .Status .PASS );
2135
2150
}
2136
2151
2137
2152
/**
@@ -2149,22 +2164,33 @@ public final void testValidateChainFailure()
2149
2164
PlatformCredential base = mock (PlatformCredential .class );
2150
2165
PlatformCredential delta1 = mock (PlatformCredential .class );
2151
2166
2152
- ComponentIdentifier compId1 = new ComponentIdentifier (new DERUTF8String ("Intel" ),
2167
+ ComponentIdentifierV2 compId1 = new ComponentIdentifierV2 (
2168
+ new ComponentClass (Paths .get (this .getClass ()
2169
+ .getResource (JSON_FILE ).toURI ()), "0x00010002" ),
2170
+ new DERUTF8String ("Intel" ),
2153
2171
new DERUTF8String ("Core i7" ), new DERUTF8String ("Not Specified" ),
2154
2172
new DERUTF8String ("Intel(R) Core(TM) i7-4790 CPU @ 3.60GHz" ), null ,
2155
- ASN1Boolean .TRUE , new ArrayList <>(0 ));
2156
- ComponentIdentifier compId2 = new ComponentIdentifier (
2173
+ ASN1Boolean .TRUE , new ArrayList <>(0 ), null , null ,
2174
+ null );
2175
+ ComponentIdentifierV2 compId2 = new ComponentIdentifierV2 (
2176
+ new ComponentClass (Paths .get (this .getClass ()
2177
+ .getResource (JSON_FILE ).toURI ()), "0x00050004" ),
2157
2178
new DERUTF8String ("Intel Corporation" ),
2158
2179
new DERUTF8String ("Ethernet Connection I217-V-faulty" ),
2159
2180
new DERUTF8String ("23:94:17:ba:86:5e" ), new DERUTF8String ("00" ), null ,
2160
- ASN1Boolean .FALSE , new ArrayList <>(0 ));
2161
- ComponentIdentifier compId3 = new ComponentIdentifier (
2181
+ ASN1Boolean .FALSE , new ArrayList <>(0 ), null , null ,
2182
+ null );
2183
+ ComponentIdentifierV2 compId3 = new ComponentIdentifierV2 (
2184
+ new ComponentClass (Paths .get (this .getClass ()
2185
+ .getResource (JSON_FILE ).toURI ()), "0x00090002" ),
2162
2186
new DERUTF8String ("Intel Corporation" ),
2163
2187
new DERUTF8String ("82580 Gigabit Network Connection-faulty" ),
2164
2188
new DERUTF8String ("90:e2:ba:31:83:10" ), new DERUTF8String ("" ), null ,
2165
- ASN1Boolean .FALSE , new ArrayList <>(0 ));
2189
+ ASN1Boolean .FALSE , new ArrayList <>(0 ), null , null ,
2190
+ null );
2166
2191
ComponentIdentifierV2 deltaCompId2 = new ComponentIdentifierV2 (
2167
- new ComponentClass (),
2192
+ new ComponentClass (Paths .get (this .getClass ()
2193
+ .getResource (JSON_FILE ).toURI ()), "0x00050004" ),
2168
2194
new DERUTF8String ("Intel Corporation" ),
2169
2195
new DERUTF8String ("Ethernet Connection I217-V" ),
2170
2196
new DERUTF8String ("23:94:17:ba:86:5e" ), new DERUTF8String ("00" ), null ,
@@ -2231,12 +2257,8 @@ public final void testValidateChainFailure()
2231
2257
deviceInfoReport , base , chainCredentials );
2232
2258
Assert .assertEquals (result .getAppStatus (), AppraisalStatus .Status .FAIL );
2233
2259
Assert .assertEquals (result .getMessage (),
2234
- "Delta Certificate with same serial number as base. (0)" );
2235
- // Assert.assertEquals(result.getMessage(),
2236
- // "There are unmatched components:\n"
2237
- // + "Manufacturer=Intel Corporation, Model=82580 "
2238
- // + "Gigabit Network Connection-faulty, "
2239
- // + "Serial=90:e2:ba:31:83:10, Revision=;\n");
2260
+ "There are 1 unmatched components on the Platform Certificate:\n "
2261
+ + "COMPID=370101885;1" );
2240
2262
}
2241
2263
2242
2264
/**
0 commit comments