Search in sources :

Example 1 with CipherUtil

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));
    }
}
Also used : SakuliCipherException(org.sakuli.exceptions.SakuliCipherException) ActionProperties(org.sakuli.datamodel.properties.ActionProperties) CipherUtil(org.sakuli.actions.environment.CipherUtil) Test(org.testng.annotations.Test)

Example 2 with CipherUtil

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();
}
Also used : ActionProperties(org.sakuli.datamodel.properties.ActionProperties) CipherUtil(org.sakuli.actions.environment.CipherUtil) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 3 with CipherUtil

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));
}
Also used : ActionProperties(org.sakuli.datamodel.properties.ActionProperties) CipherUtil(org.sakuli.actions.environment.CipherUtil)

Aggregations

CipherUtil (org.sakuli.actions.environment.CipherUtil)3 ActionProperties (org.sakuli.datamodel.properties.ActionProperties)3 SakuliCipherException (org.sakuli.exceptions.SakuliCipherException)1 BeforeMethod (org.testng.annotations.BeforeMethod)1 Test (org.testng.annotations.Test)1