Search in sources :

Example 1 with VdcConfigHelper

use of com.emc.storageos.geo.service.impl.util.VdcConfigHelper in project coprhd-controller by CoprHD.

the class VdcControllerTest method setup.

@Before
public void setup() throws Exception {
    vdcController = new VdcControllerImpl();
    MockCoordinatorClient coordinator = new MockCoordinatorClient();
    // setup mock objects for vdc controller test
    dbClient = new MockDbClient();
    vdcController.setDbClient(dbClient);
    InternalApiSignatureKeyGenerator secretKeyGenerator = new InternalApiSignatureKeyGenerator() {

        public synchronized void loadKeys() {
        }

        public SecretKey getSignatureKey(SignatureKeyType type) {
            return SignatureHelper.createKey("test", InternalApiSignatureKeyGenerator.CURRENT_INTERVDC_API_SIGN_ALGO);
        }
    };
    clientManager = new MockGeoClientCacheManager(coordinator, secretKeyGenerator);
    vdcController.setGeoClientManager(clientManager);
    vdcController.setVdcOperationLockHelper(new MockVdcOperationLockHelper());
    keystore = KeyStore.getInstance(KeyStore.getDefaultType());
    password = "some password".toCharArray();
    keystore.load(null, password);
    KeyPairGenerator keyGen = KeyPairGenerator.getInstance("RSA");
    keyGen.initialize(512, new SecureRandom());
    CertAndKeyGen keypair = new CertAndKeyGen("RSA", "SHA1WithRSA", null);
    X500Name x500Name = new X500Name("EMC", "EMC", "EMC", "EMC", "MA", "US");
    keypair.generate(512);
    PrivateKey privKey = keypair.getPrivateKey();
    chain = new X509Certificate[1];
    chain[0] = keypair.getSelfCertificate(x500Name, new Date(), (long) 365 * 24 * 60 * 60);
    keystore.setKeyEntry(KeystoreEngine.ViPR_KEY_AND_CERTIFICATE_ALIAS, privKey, password, chain);
    vdcController.setKeystore(keystore);
    vdcController.setSignatureGenerator(secretKeyGenerator);
    BasePermissionsHelper permissionsHelper = new BasePermissionsHelper(dbClient);
    vdcController.setPermissionsHelper(permissionsHelper);
    // Setup helper based on mocked db client
    VdcConfigHelper helper = new VdcConfigHelper();
    helper.setDbClient(dbClient);
    helper.setGeoClientCacheManager(clientManager);
    helper.setCoordinatorClient(coordinator);
    vdcController.setVdcHelper(helper);
    VdcUtil.setDbClient(dbClient);
    dbClient.buildGeodbData();
}
Also used : PrivateKey(java.security.PrivateKey) SecureRandom(java.security.SecureRandom) VdcControllerImpl(com.emc.storageos.geo.vdccontroller.impl.VdcControllerImpl) KeyPairGenerator(java.security.KeyPairGenerator) X500Name(sun.security.x509.X500Name) Date(java.util.Date) CertAndKeyGen(sun.security.tools.keytool.CertAndKeyGen) InternalApiSignatureKeyGenerator(com.emc.storageos.security.authentication.InternalApiSignatureKeyGenerator) BasePermissionsHelper(com.emc.storageos.security.authorization.BasePermissionsHelper) VdcConfigHelper(com.emc.storageos.geo.service.impl.util.VdcConfigHelper) Before(org.junit.Before)

Aggregations

VdcConfigHelper (com.emc.storageos.geo.service.impl.util.VdcConfigHelper)1 VdcControllerImpl (com.emc.storageos.geo.vdccontroller.impl.VdcControllerImpl)1 InternalApiSignatureKeyGenerator (com.emc.storageos.security.authentication.InternalApiSignatureKeyGenerator)1 BasePermissionsHelper (com.emc.storageos.security.authorization.BasePermissionsHelper)1 KeyPairGenerator (java.security.KeyPairGenerator)1 PrivateKey (java.security.PrivateKey)1 SecureRandom (java.security.SecureRandom)1 Date (java.util.Date)1 Before (org.junit.Before)1 CertAndKeyGen (sun.security.tools.keytool.CertAndKeyGen)1 X500Name (sun.security.x509.X500Name)1