use of com.intel.mtwilson.util.net.Hostname in project OpenAttestation by OpenAttestation.
the class Reports method hostnameListFromCSV.
private List<Hostname> hostnameListFromCSV(String hostnameCSV) {
ArrayList<Hostname> list = new ArrayList<Hostname>();
String[] stringArray = hostnameCSV.split(",");
for (String hostname : stringArray) {
list.add(new Hostname(hostname));
}
return list;
}
use of com.intel.mtwilson.util.net.Hostname in project OpenAttestation by OpenAttestation.
the class ReportsBOTest method testGetTrustReportWithError.
@Test
public void testGetTrustReportWithError() {
Collection<Hostname> hostNames = new ArrayList<Hostname>();
hostNames.add(new Hostname(SERVER_NAME));
when(tblHostsJpaController.findByName(anyString())).thenReturn(mockFindByName());
List<TblTaLog> taLogs = new ArrayList<TblTaLog>();
TblTaLog taLog1 = new TblTaLog(Integer.valueOf(1), 1, 1, "0", "31B97D97B4679917EC3C1D943635693FFBAB4143", false, new Date());
TblTaLog taLog2 = new TblTaLog(Integer.valueOf(2), 1, 2, "18", "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF", false, new Date());
taLog1.setError("BIOS:1,VMM:1");
taLog2.setError("BIOS:1,VMM:1");
taLogs.add(taLog1);
taLogs.add(taLog2);
when(tblTaLogJpaController.findTrustStatusByHostId(anyInt(), anyInt())).thenReturn(taLogs);
HostsTrustReportType hostsTrustReportType = reportsBO.getTrustReport(hostNames);
assertNotNull(hostsTrustReportType);
assertTrue(hostsTrustReportType.getHost().size() > 0);
}
use of com.intel.mtwilson.util.net.Hostname in project OpenAttestation by OpenAttestation.
the class ReportsBOTest method testGetAttestationReport.
@Test
public void testGetAttestationReport() throws NumberFormatException, IOException {
when(tblHostsJpaController.findByName(anyString())).thenReturn(mockFindByName());
when(tblTaLogJpaController.findLastStatusTs(any(Integer.class))).thenReturn(new Date());
List<TblTaLog> taLogs = new ArrayList<TblTaLog>();
taLogs.add(new TblTaLog(Integer.valueOf(1), 1, 1, "18", "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF", true, new Date()));
when(tblTaLogJpaController.findLogsByHostId(anyInt(), any(Date.class))).thenReturn(taLogs);
AttestationReport attestationReport = reportsBO.getAttestationReport(new Hostname(SERVER_NAME), false);
assertNotNull(attestationReport);
assertTrue(attestationReport.getPcrLogs().size() > 0);
}
use of com.intel.mtwilson.util.net.Hostname in project OpenAttestation by OpenAttestation.
the class HostTrustBOTest method testGetTrustStatus.
@Test
public void testGetTrustStatus() throws Exception {
TblHosts tblHosts = mockGetHostByIpAddress();
doReturn(tblHosts).when(hostTrustBO).getHostByIpAddress(SERVER_NAME);
//get pcrMap
HashMap<String, IManifest> pcrManifestMap = new HashMap<String, IManifest>();
pcrManifestMap.put("0", new PcrManifest(0, "31B97D97B4679917EC3C1D943635693FFBAB4143"));
pcrManifestMap.put("18", new PcrManifest(18, "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"));
doReturn(pcrManifestMap).when(manifestStrategy).getManifest(tblHosts);
//get gkv for given host
HashMap<String, IManifest> gkvBiosPcrManifestMap = new HashMap<String, IManifest>();
HashMap<String, IManifest> gkvVmmPcrManifestMap = new HashMap<String, IManifest>();
gkvBiosPcrManifestMap.put("0", new PcrManifest(0, "31B97D97B4679917EC3C1D943635693FFBAB4143"));
gkvVmmPcrManifestMap.put("18", new PcrManifest(18, "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"));
doReturn(gkvBiosPcrManifestMap).when(gkvStrategy).getBiosGoodKnownManifest(anyString(), anyString(), anyString());
doReturn(gkvVmmPcrManifestMap).when(gkvStrategy).getVmmGoodKnownManifest(anyString(), anyString(), anyString(), anyString(), any(Integer.class));
doNothing().when(taLogJpaController).create(any(TblTaLog.class));
HostTrustStatus trustStatus = hostTrustBO.getTrustStatus(new Hostname(SERVER_NAME));
assertNotNull(trustStatus);
assertTrue(trustStatus.bios);
assertTrue(trustStatus.vmm);
}
use of com.intel.mtwilson.util.net.Hostname in project OpenAttestation by OpenAttestation.
the class GetHostTrust method execute.
@Override
public void execute(String[] args) throws Exception {
ApiClient api = getClient();
HostTrustResponse response = api.getHostTrust(new Hostname(args[0]));
System.out.println(toJson(response));
}
Aggregations