forked from appium/appium-xcuitest-driver
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Align customSSLCert capability logic (appium#1334)
- Loading branch information
1 parent
35bc8b3
commit 8eca81c
Showing
4 changed files
with
87 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import _ from 'lodash'; | ||
import { installSSLCert, hasSSLCert } from 'appium-ios-simulator'; | ||
|
||
/** | ||
* Check whether the given Simulator device supports simctl keychain API. | ||
* | ||
* @param {object} device Simulator instance created by appium-ios-simulator module | ||
* @returns {boolean} `true` if the current Simulator SDK supports keychain commands. | ||
*/ | ||
const doesSupportKeychainApi = _.memoize(async function doesSupportKeychainApi (device) { | ||
try { | ||
await device.simctl.exec('help', { | ||
args: ['keychain'] | ||
}); | ||
return true; | ||
} catch (e) { | ||
return false; | ||
} | ||
}); | ||
|
||
/** | ||
* Adds a certificate to the trusted root store. | ||
* Simulator must be in BOOTED state for this API to work. | ||
* | ||
* @param {object} device Simulator instance created by appium-ios-simulator module | ||
* @param {string} payload Certificate payload | ||
*/ | ||
async function installCertificate (device, payload) { | ||
await device.simctl.addRootCertificate(payload, {raw: true}); | ||
} | ||
|
||
/** | ||
* Check whether the given certificate is already installed. | ||
* The function is using hacky calls to make certificate stuff working for older SDKs. | ||
* Simulator must be in SHUTDOWN state for this API to work. | ||
* | ||
* @param {object} device Simulator instance created by appium-ios-simulator module | ||
* @param {string} payload Certificate payload | ||
* @returns {boolean} `true` if the certificate is already present in the root store. | ||
*/ | ||
async function hasCertificateLegacy (device, payload) { | ||
return await hasSSLCert(payload, device.udid); | ||
} | ||
|
||
/** | ||
* Adds a certificate to the trusted root store. | ||
* The function is using hacky calls to make certificate stuff working for older SDKs. | ||
* Simulator must be in SHUTDOWN state for this API to work. | ||
* | ||
* @param {object} device Simulator instance created by appium-ios-simulator module | ||
* @param {string} payload Certificate payload | ||
*/ | ||
async function installCertificateLegacy (device, payload) { | ||
await installSSLCert(payload, device.udid); | ||
} | ||
|
||
|
||
export { | ||
doesSupportKeychainApi, installCertificate, installCertificateLegacy, | ||
hasCertificateLegacy | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters