Module: Calabash::Cucumber::KeychainHelpers
- Included in:
- Operations
- Defined in:
- lib/calabash-cucumber/keychain_helpers.rb
Overview
KeychainHelpers provide a helpers to access the iOS keychain.
Simulator Note
When running on the simulator, the keychain is not sandboxed between applications like it is on a real device. These methods will return keychain records from all applications on the simulator, which may result in strange behavior if you aren't expecting it.
Instance Method Summary collapse
-
#keychain_accounts ⇒ Array<Hash>
Asks the keychain for all of the account records.
-
#keychain_accounts_for_service(service) ⇒ Array<Hash>
Returns an list of all account records saved in the iOS keychain filtered by
service. -
#keychain_clear ⇒ nil
On the iOS Simulator this clears all keychain entries for all applications.
-
#keychain_clear_accounts_for_service(service) ⇒ nil
Clear all entries in the keychain restricted to a single
service. -
#keychain_delete_password(service, account) ⇒ Object
Delete a single keychain record for the given
serviceandaccountpair. -
#keychain_password(service, account) ⇒ String, Array<Hash>
Ask the keychain for an account password.
-
#keychain_set_password(service, account, password) ⇒ Object
Set the password for a given service and account pair.
Instance Method Details
#keychain_accounts ⇒ Array<Hash>
Asks the keychain for all of the account records.
The hash keys are defined by the SSKeychain library.
The following keys are the most commonly useful:
svce #=> the service
acct #=> the account (often a username)
cdat #=> the creation date
mdat #=> the last-modified date
64 65 66 |
# File 'lib/calabash-cucumber/keychain_helpers.rb', line 64 def keychain_accounts _keychain_get end |
#keychain_accounts_for_service(service) ⇒ Array<Hash>
Returns an list of all account records saved in the iOS keychain
filtered by service.
76 77 78 |
# File 'lib/calabash-cucumber/keychain_helpers.rb', line 76 def keychain_accounts_for_service(service) _keychain_get({:service => service}) end |
#keychain_clear ⇒ nil
On the iOS Simulator this clears all keychain entries for all applications.
On a physical device, this will clear all entries for the target application.
134 135 136 |
# File 'lib/calabash-cucumber/keychain_helpers.rb', line 134 def keychain_clear _keychain_post end |
#keychain_clear_accounts_for_service(service) ⇒ nil
Clear all entries in the keychain restricted to a single service.
144 145 146 |
# File 'lib/calabash-cucumber/keychain_helpers.rb', line 144 def keychain_clear_accounts_for_service(service) _keychain_post({:service => service}) end |
#keychain_delete_password(service, account) ⇒ Object
Delete a single keychain record for the given service and account
pair.
155 156 157 |
# File 'lib/calabash-cucumber/keychain_helpers.rb', line 155 def keychain_delete_password(service, account) _keychain_post(:service => service, :account => account) end |
#keychain_password(service, account) ⇒ String, Array<Hash>
IMPORTANT
On the XTC, the password cannot returned as plain text.
When using this keychain_password in your steps you can condition on
the XTC environment using xamarin_test_cloud?
Ask the keychain for an account password.
96 97 98 |
# File 'lib/calabash-cucumber/keychain_helpers.rb', line 96 def keychain_password(service, account) _keychain_get({:service => service, :account => account}).first end |
#keychain_set_password(service, account, password) ⇒ Object
Set the password for a given service and account pair.
167 168 169 |
# File 'lib/calabash-cucumber/keychain_helpers.rb', line 167 def keychain_set_password(service, account, password) _keychain_post(:service => service, :account => account, :password => password) end |