use of org.obiba.mica.micaConfig.domain.OpalCredential in project mica2 by obiba.
the class OpalCredentialServiceTests method testDeleteCertificateCredential.
@Test
public void testDeleteCertificateCredential() throws KeyStoreException {
OpalCredential credential = new OpalCredential("https://opal", AuthType.CERTIFICATE);
when(opalCredentialRepository.findOne("https://opal")).thenReturn(credential);
KeyStoreManager keyStore = mock(KeyStoreManager.class);
doNothing().when(keyStore).deleteKey("https://opal");
when(keyStoreService.getKeyStore("opal")).thenReturn(keyStore);
opalCredentialService.deleteOpalCredential("https://opal");
verify(opalCredentialRepository).delete(any(OpalCredential.class));
}
use of org.obiba.mica.micaConfig.domain.OpalCredential in project mica2 by obiba.
the class OpalCredentialServiceTests method testGetOpalCredential.
@Test
public void testGetOpalCredential() {
OpalCredential credential = new OpalCredential("https://opal", AuthType.USERNAME, "test", "encrypted");
when(opalCredentialRepository.findOne("https://opal")).thenReturn(credential);
when(micaConfigService.decrypt("encrypted")).thenReturn("password");
OpalCredential actual = opalCredentialService.getOpalCredential("https://opal");
assertThat(actual, is(credential));
}
use of org.obiba.mica.micaConfig.domain.OpalCredential in project mica2 by obiba.
the class OpalCredentialService method deleteOpalCredential.
public void deleteOpalCredential(String opalUrl) {
OpalCredential credential = repository.findOne(opalUrl);
if (credential == null)
return;
repository.delete(credential);
if (credential.getAuthType() == AuthType.CERTIFICATE) {
keyStoreService.deleteKeyPair(OpalService.OPAL_KEYSTORE, opalUrl);
}
}
Aggregations