How to use setKeystoreConfig method of io.appium.java_client.android.options.signing.SupportsKeystoreOptions class

Best io.appium code snippet using io.appium.java_client.android.options.signing.SupportsKeystoreOptions.setKeystoreConfig

Run io.appium automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

SupportsKeystoreOptions.java

Source: SupportsKeystoreOptions.java Github

copy
1/*
2 * Licensed under the Apache License, Version 2.0 (the "License");
3 * you may not use this file except in compliance with the License.
4 * See the NOTICE file distributed with this work for additional
5 * information regarding copyright ownership.
6 * You may obtain a copy of the License at
7 *
8 *     http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package io.appium.java_client.android.options.signing;
18
19import io.appium.java_client.remote.options.BaseOptions;
20import io.appium.java_client.remote.options.CanSetCapability;
21import org.openqa.selenium.Capabilities;
22
23import java.util.Optional;
24
25import static io.appium.java_client.internal.CapabilityHelpers.toSafeBoolean;
26
27public interface SupportsKeystoreOptions<T extends BaseOptions<T>> extends
28        Capabilities, CanSetCapability<T> {
29    String USE_KEYSTORE_OPTION = "useKeystore";
30    String KEYSTORE_PATH_OPTION = "keystorePath";
31    String KEYSTORE_PASSWORD_OPTION = "keystorePassword";
32    String KEY_ALIAS_OPTION = "keyAlias";
33    String KEY_PASSWORD_OPTION = "keyPassword";
34
35    /**
36     * Use a custom keystore to sign the app under test.
37     *
38     * @param keystoreConfig The keystore config to use.
39     * @return self instance for chaining.
40     */
41    default T setKeystoreConfig(KeystoreConfig keystoreConfig) {
42        return amend(USE_KEYSTORE_OPTION, true)
43                .amend(KEYSTORE_PATH_OPTION, keystoreConfig.getPath())
44                .amend(KEYSTORE_PASSWORD_OPTION, keystoreConfig.getPassword())
45                .amend(KEY_ALIAS_OPTION, keystoreConfig.getKeyAlias())
46                .amend(KEY_PASSWORD_OPTION, keystoreConfig.getKeyPassword());
47    }
48
49    /**
50     * Get whether to use a custom keystore.
51     *
52     * @return True or false.
53     */
54    default Optional<Boolean> doesUseKeystore() {
55        return Optional.ofNullable(toSafeBoolean(getCapability(USE_KEYSTORE_OPTION)));
56    }
57
58    /**
59     * Get the custom keystore config.
60     *
61     * @return The keystore config.
62     */
63    default Optional<KeystoreConfig> getKeystoreConfig() {
64        if (!doesUseKeystore().orElse(false)) {
65            return Optional.empty();
66        }
67        return Optional.of(new KeystoreConfig(
68                (String) getCapability(KEYSTORE_PATH_OPTION),
69                (String) getCapability(KEYSTORE_PASSWORD_OPTION),
70                (String) getCapability(KEY_ALIAS_OPTION),
71                (String) getCapability(KEY_PASSWORD_OPTION)
72        ));
73    }
74}
75
Full Screen

Accelerate Your Automation Test Cycles With LambdaTest

Leverage LambdaTest’s cloud-based platform to execute your automation tests in parallel and trim down your test execution time significantly. Your first 100 automation testing minutes are on us.

Try LambdaTest

Most used method in SupportsKeystoreOptions

Trigger setKeystoreConfig code on LambdaTest Cloud Grid

Execute automation tests with setKeystoreConfig on a cloud-based Grid of 3000+ real browsers and operating systems for both web and mobile applications.

Test now for Free
LambdaTestX

We use cookies to give you the best experience. Cookies help to provide a more personalized experience and relevant advertising for you, and web analytics for us. Learn More in our Cookies policy, Privacy & Terms of service

Allow Cookie
Sarah

I hope you find the best code examples for your project.

If you want to accelerate automated browser testing, try LambdaTest. Your first 100 automation testing minutes are FREE.

Sarah Elson (Product & Growth Lead)