use of com.emc.storageos.security.authentication.InternalApiSignatureKeyGenerator in project coprhd-controller by CoprHD.
the class DisasterRecoveryServiceTest method testPlannedFailover_noError.
@Test
public void testPlannedFailover_noError() throws Exception {
List<Site> sites = new ArrayList<>();
sites.add(primarySite);
sites.add(standbySite2);
SecretKey keyMock = mock(SecretKey.class);
InternalApiSignatureKeyGenerator apiSignatureGeneratorMock = mock(InternalApiSignatureKeyGenerator.class);
doReturn("SecreteKey".getBytes()).when(keyMock).getEncoded();
doReturn(keyMock).when(apiSignatureGeneratorMock).getSignatureKey(SignatureKeyType.INTERVDC_API);
doReturn(sites).when(drUtil).listSites();
doReturn(primarySite).when(drUtil).getActiveSite();
doReturn(true).when(drUtil).isSiteUp(standbySite2.getUuid());
doReturn(ClusterInfo.ClusterState.STABLE).when(coordinator).getControlNodesState(standbySite2.getUuid());
doReturn(mock(DistributedBarrier.class)).when(coordinator).getDistributedBarrier(any(String.class));
doNothing().when(drService).precheckForSwitchover(standbySite2.getUuid());
drService.setApiSignatureGenerator(apiSignatureGeneratorMock);
drService.doSwitchover(standbySite2.getUuid());
verify(coordinator, times(1)).persistServiceConfiguration(any(Configuration.class));
}
use of com.emc.storageos.security.authentication.InternalApiSignatureKeyGenerator 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