Search in sources :

Example 6 with TblOs

use of com.intel.mtwilson.as.data.TblOs in project OpenAttestation by OpenAttestation.

the class OsBO method deleteOs.

/**
     * 
     * @param osName
     * @param osVersion
     * @return 
     */
public String deleteOs(String osName, String osVersion) {
    try {
        TblOs tblOs = tblOsJpaController.findTblOsByNameVersion(osName, osVersion);
        if (tblOs == null) {
            throw new ASException(ErrorCode.WS_OS_DOES_NOT_EXIST, osName, osVersion);
        }
        Collection<TblMle> tblMleCollection = tblOs.getTblMleCollection();
        if (tblMleCollection != null) {
            log.info("OS is currently associated with # MLEs: " + tblMleCollection.size());
            if (!tblMleCollection.isEmpty()) {
                throw new ASException(ErrorCode.WS_OS_ASSOCIATION_EXISTS, osName, osVersion, tblMleCollection.size());
            }
        }
        tblOsJpaController.destroy(tblOs.getId());
    } catch (ASException ase) {
        throw ase;
    } catch (Exception e) {
        throw new ASException(e);
    }
    return "true";
}
Also used : TblMle(com.intel.mtwilson.as.data.TblMle) ASException(com.intel.mountwilson.as.common.ASException) ASException(com.intel.mountwilson.as.common.ASException) TblOs(com.intel.mtwilson.as.data.TblOs)

Example 7 with TblOs

use of com.intel.mtwilson.as.data.TblOs in project OpenAttestation by OpenAttestation.

the class MleBOTest method mockFindVmmMle.

public TblMle mockFindVmmMle() {
    String vmmName = "XEN";
    String vmmVersion = "4.3";
    String osName = "Fedora";
    String osVersion = "20";
    TblMle vmmMle = new TblMle();
    vmmMle.setId(MLE_ID2);
    vmmMle.setName(vmmName);
    vmmMle.setVersion(vmmVersion);
    vmmMle.setOemId(new TblOem());
    TblOs os = new TblOs();
    os.setId(1);
    os.setName(osName);
    os.setVersion(osVersion);
    vmmMle.setOsId(os);
    Collection<TblPcrManifest> tblPcrManifestCollectionVMM = new ArrayList<TblPcrManifest>();
    TblPcrManifest tblPcrManifestVMM = new TblPcrManifest();
    tblPcrManifestVMM.setId(2);
    tblPcrManifestVMM.setName("18");
    tblPcrManifestVMM.setValue("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF");
    tblPcrManifestCollectionVMM.add(tblPcrManifestVMM);
    vmmMle.setTblPcrManifestCollection(tblPcrManifestCollectionVMM);
    return vmmMle;
}
Also used : TblMle(com.intel.mtwilson.as.data.TblMle) TblOem(com.intel.mtwilson.as.data.TblOem) ArrayList(java.util.ArrayList) Matchers.anyString(org.mockito.Matchers.anyString) TblPcrManifest(com.intel.mtwilson.as.data.TblPcrManifest) TblOs(com.intel.mtwilson.as.data.TblOs)

Example 8 with TblOs

use of com.intel.mtwilson.as.data.TblOs in project OpenAttestation by OpenAttestation.

the class MleBOTest method mockFindBiosMle.

public TblMle mockFindBiosMle() {
    String biosName = "DELL";
    String biosVersion = "A08";
    String oemName = "DELL";
    TblMle biosMle = new TblMle();
    biosMle.setId(MLE_ID1);
    biosMle.setName(biosName);
    biosMle.setVersion(biosVersion);
    TblOem oem = new TblOem();
    oem.setId(1);
    oem.setName(oemName);
    biosMle.setOemId(oem);
    biosMle.setOsId(new TblOs());
    Collection<TblPcrManifest> tblPcrManifestCollection = new ArrayList<TblPcrManifest>();
    TblPcrManifest tblPcrManifest = new TblPcrManifest();
    tblPcrManifest.setId(1);
    tblPcrManifest.setName("0");
    tblPcrManifest.setValue("31B97D97B4679917EC3C1D943635693FFBAB4143");
    tblPcrManifestCollection.add(tblPcrManifest);
    biosMle.setTblPcrManifestCollection(tblPcrManifestCollection);
    return biosMle;
}
Also used : TblMle(com.intel.mtwilson.as.data.TblMle) TblOem(com.intel.mtwilson.as.data.TblOem) ArrayList(java.util.ArrayList) Matchers.anyString(org.mockito.Matchers.anyString) TblPcrManifest(com.intel.mtwilson.as.data.TblPcrManifest) TblOs(com.intel.mtwilson.as.data.TblOs)

Example 9 with TblOs

use of com.intel.mtwilson.as.data.TblOs in project OpenAttestation by OpenAttestation.

the class MleBOTest method testAddMLe.

@Test
public void testAddMLe() {
    TblMle biosMle = null;
    TblMle vmmMle = null;
    TblOem tblOem = new TblOem();
    tblOem.setId(OEM_ID);
    tblOem.setName("DELL");
    TblOs tblOs = new TblOs(OS_ID, "Fedora", "20");
    doReturn(tblOem).when(tblOemJpaController).findTblOemByName(anyString());
    doReturn(tblOs).when(tblOsJpaController).findTblOsByNameVersion(anyString(), anyString());
    doReturn(biosMle).when(tblMleJpaController).findBiosMle(anyString(), anyString(), anyString());
    doReturn(vmmMle).when(tblMleJpaController).findVmmMle(anyString(), anyString(), anyString(), anyString());
    List<ManifestData> biosManifestList = new ArrayList<ManifestData>();
    biosManifestList.add(new ManifestData("0", "31B97D97B4679917EC3C1D943635693FFBAB4143"));
    MleData biosMleData = new MleData("DELL", "A08", MleType.BIOS, AttestationType.PCR, biosManifestList, "", "", "", "DELL");
    List<ManifestData> vmmManifestList = new ArrayList<ManifestData>();
    vmmManifestList.add(new ManifestData("18", "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"));
    MleData vmmMleData = new MleData("XEN", "4.3", MleType.VMM, AttestationType.PCR, vmmManifestList, "", "Fedora", "20", "");
    String biosResult = mleBO.addMLe(biosMleData);
    assertEquals("true", biosResult);
    String vmmResult = mleBO.addMLe(vmmMleData);
    assertEquals("true", vmmResult);
}
Also used : TblMle(com.intel.mtwilson.as.data.TblMle) TblOem(com.intel.mtwilson.as.data.TblOem) ArrayList(java.util.ArrayList) MleData(com.intel.mtwilson.datatypes.MleData) Matchers.anyString(org.mockito.Matchers.anyString) ManifestData(com.intel.mtwilson.datatypes.ManifestData) TblOs(com.intel.mtwilson.as.data.TblOs) Test(org.junit.Test)

Example 10 with TblOs

use of com.intel.mtwilson.as.data.TblOs in project OpenAttestation by OpenAttestation.

the class OsBOTest method testUpdateOs.

@Test
public void testUpdateOs() {
    TblOs tblOs = new TblOs(OS_ID1, "Fedora", "20");
    doReturn(tblOs).when(tblOsJpaController).findTblOsByNameVersion(anyString(), anyString());
    OsData osData = new OsData("Fedora", "20", "");
    String result = osBO.updateOs(osData);
    assertEquals("true", result);
}
Also used : Matchers.anyString(org.mockito.Matchers.anyString) OsData(com.intel.mtwilson.datatypes.OsData) TblOs(com.intel.mtwilson.as.data.TblOs) Test(org.junit.Test)

Aggregations

TblOs (com.intel.mtwilson.as.data.TblOs)23 Matchers.anyString (org.mockito.Matchers.anyString)10 TblMle (com.intel.mtwilson.as.data.TblMle)9 ArrayList (java.util.ArrayList)9 Test (org.junit.Test)8 TblOem (com.intel.mtwilson.as.data.TblOem)7 TblPcrManifest (com.intel.mtwilson.as.data.TblPcrManifest)6 ASException (com.intel.mountwilson.as.common.ASException)5 OsData (com.intel.mtwilson.datatypes.OsData)4 EntityManager (javax.persistence.EntityManager)4 TblHosts (com.intel.mtwilson.as.data.TblHosts)3 Query (javax.persistence.Query)3 CriteriaQuery (javax.persistence.criteria.CriteriaQuery)3 NonexistentEntityException (com.intel.mtwilson.as.controller.exceptions.NonexistentEntityException)2 NoResultException (javax.persistence.NoResultException)2 TblOemJpaController (com.intel.mtwilson.as.controller.TblOemJpaController)1 TblOsJpaController (com.intel.mtwilson.as.controller.TblOsJpaController)1 ASDataException (com.intel.mtwilson.as.controller.exceptions.ASDataException)1 IllegalOrphanException (com.intel.mtwilson.as.controller.exceptions.IllegalOrphanException)1 ManifestData (com.intel.mtwilson.datatypes.ManifestData)1