use of org.sakuli.actions.environment.CipherUtil in project sakuli by ConSol.
the class CipherUtilsTest method testChipherException.
@Test
public void testChipherException() throws Throwable {
try {
ActionProperties props = new ActionProperties();
props.setEncryptionInterfaceAutodetect(false);
props.setEncryptionInterface("etNOVALID");
testling = new CipherUtil(props);
testling.scanNetworkInterfaces();
Assert.assertTrue(false, "Error, no exception is thrown");
} catch (SakuliCipherException e) {
Assert.assertNotNull(e.interfaceLog);
Assert.assertTrue(e.getMessage().contains(e.interfaceLog));
}
}
use of org.sakuli.actions.environment.CipherUtil in project sakuli by ConSol.
the class CipherUtilsTest method setUp.
@BeforeMethod
public void setUp() throws Throwable {
MockitoAnnotations.initMocks(this);
ActionProperties props = new ActionProperties();
props.setEncryptionInterfaceAutodetect(true);
testling = new CipherUtil(props);
testling.scanNetworkInterfaces();
}
use of org.sakuli.actions.environment.CipherUtil in project sakuli by ConSol.
the class SakuliStarter method encryptSecret.
/**
* Encrypt a secret based on the assigned interface.
*
* @param strToEncrypt secret to encrypt
* @param ethInterface name of network interface, if NULL use the auto-detection
* @return a Key-Value Pair of used interface for the encryption and the encrypted secret as strings.
* @throws SakuliCipherException
*/
public static Entry<String, String> encryptSecret(String strToEncrypt, String ethInterface) throws SakuliCipherException {
ActionProperties cipherProps = new ActionProperties();
if (isNotEmpty(ethInterface)) {
cipherProps.setEncryptionInterface(ethInterface);
cipherProps.setEncryptionInterfaceAutodetect(false);
} else {
cipherProps.setEncryptionInterfaceAutodetect(true);
}
CipherUtil cipher = new CipherUtil(cipherProps);
cipher.scanNetworkInterfaces();
return new AbstractMap.SimpleEntry<>(cipher.getInterfaceName(), cipher.encrypt(strToEncrypt));
}
Aggregations