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();
}
Aggregations