Search in sources :

Example 11 with Hostname

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;
}
Also used : ArrayList(java.util.ArrayList) Hostname(com.intel.mtwilson.util.net.Hostname)

Example 12 with Hostname

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);
}
Also used : TblTaLog(com.intel.mtwilson.as.data.TblTaLog) HostsTrustReportType(com.intel.mountwilson.as.hosttrustreport.data.HostsTrustReportType) ArrayList(java.util.ArrayList) Hostname(com.intel.mtwilson.util.net.Hostname) Date(java.util.Date) Test(org.junit.Test)

Example 13 with Hostname

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);
}
Also used : TblTaLog(com.intel.mtwilson.as.data.TblTaLog) AttestationReport(com.intel.mtwilson.datatypes.AttestationReport) ArrayList(java.util.ArrayList) Hostname(com.intel.mtwilson.util.net.Hostname) Date(java.util.Date) Test(org.junit.Test)

Example 14 with Hostname

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);
}
Also used : TblTaLog(com.intel.mtwilson.as.data.TblTaLog) HashMap(java.util.HashMap) PcrManifest(com.intel.mountwilson.manifest.data.PcrManifest) TblPcrManifest(com.intel.mtwilson.as.data.TblPcrManifest) TblHosts(com.intel.mtwilson.as.data.TblHosts) Hostname(com.intel.mtwilson.util.net.Hostname) Matchers.anyString(org.mockito.Matchers.anyString) IManifest(com.intel.mountwilson.manifest.data.IManifest) HostTrustStatus(com.intel.mtwilson.datatypes.HostTrustStatus) Test(org.junit.Test)

Example 15 with Hostname

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));
}
Also used : HostTrustResponse(com.intel.mtwilson.datatypes.HostTrustResponse) Hostname(com.intel.mtwilson.util.net.Hostname) ApiClient(com.intel.mtwilson.ApiClient)

Aggregations

Hostname (com.intel.mtwilson.util.net.Hostname)30 Test (org.junit.Test)15 IOException (java.io.IOException)9 ArrayList (java.util.ArrayList)8 TblTaLog (com.intel.mtwilson.as.data.TblTaLog)7 ApiException (com.intel.mtwilson.ApiException)6 SignatureException (java.security.SignatureException)6 DemoPortalException (com.intel.mountwilson.common.DemoPortalException)5 TblHosts (com.intel.mtwilson.as.data.TblHosts)5 Date (java.util.Date)5 ASException (com.intel.mountwilson.as.common.ASException)4 HostsTrustReportType (com.intel.mountwilson.as.hosttrustreport.data.HostsTrustReportType)4 Matchers.anyString (org.mockito.Matchers.anyString)4 CryptographyException (com.intel.mtwilson.crypto.CryptographyException)3 UnknownHostException (java.net.UnknownHostException)3 HostType (com.intel.mountwilson.as.hosttrustreport.data.HostType)2 AttestationReport (com.intel.mtwilson.datatypes.AttestationReport)2 HostTrustResponse (com.intel.mtwilson.datatypes.HostTrustResponse)2 WebApplicationException (javax.ws.rs.WebApplicationException)2 ConfigurationException (org.apache.commons.configuration.ConfigurationException)2