Search in sources :

Example 1 with ActionProperties

use of org.sakuli.datamodel.properties.ActionProperties 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 ActionProperties

use of org.sakuli.datamodel.properties.ActionProperties 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 ActionProperties

use of org.sakuli.datamodel.properties.ActionProperties 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)

Example 4 with ActionProperties

use of org.sakuli.datamodel.properties.ActionProperties in project sakuli by ConSol.

the class ScreenBasedSettingsTest method testSetDefaults.

@Test(expectedExceptions = InvalidParameterException.class, expectedExceptionsMessageRegExp = "the property '" + ActionProperties.DEFAULT_HIGHLIGHT_SEC + "' has to be greater as 1, but was 0.6")
public void testSetDefaults() throws Exception {
    ActionProperties props = new ActionProperties();
    props.setDefaultHighlightSeconds(0.6f);
    SakuliProperties sakuliProps = new SakuliProperties();
    sakuliProps.setTessDataLibFolder(Paths.get("."));
    ScreenBasedSettings testling = new ScreenBasedSettings(props, sakuliProps);
    testling.setDefaults();
}
Also used : ActionProperties(org.sakuli.datamodel.properties.ActionProperties) ScreenBasedSettings(org.sakuli.actions.settings.ScreenBasedSettings) SakuliProperties(org.sakuli.datamodel.properties.SakuliProperties) Test(org.testng.annotations.Test)

Aggregations

ActionProperties (org.sakuli.datamodel.properties.ActionProperties)4 CipherUtil (org.sakuli.actions.environment.CipherUtil)3 Test (org.testng.annotations.Test)2 ScreenBasedSettings (org.sakuli.actions.settings.ScreenBasedSettings)1 SakuliProperties (org.sakuli.datamodel.properties.SakuliProperties)1 SakuliCipherException (org.sakuli.exceptions.SakuliCipherException)1 BeforeMethod (org.testng.annotations.BeforeMethod)1