creator_simctl/
keychain.rs

1//! Supporting types for the `simctl keychain` subcommand.
2
3use super::{Device, Result, Validate};
4
5/// Wrapper around the `simctl keychain` subcommand.
6pub struct Keychain {
7    device: Device,
8}
9
10impl Device {
11    /// Returns an instance of the `keychain` subcommand.
12    pub fn keychain(&self) -> Keychain {
13        Keychain {
14            device: self.clone(),
15        }
16    }
17}
18
19impl Keychain {
20    /// Resets the device's keychain.
21    pub fn reset(&self) -> Result<()> {
22        self.device
23            .simctl()
24            .command("keychain")
25            .arg(&self.device.udid)
26            .arg("reset")
27            .output()?
28            .validate()
29    }
30}
31
32#[cfg(test)]
33mod tests {
34    use serial_test::serial;
35
36    use super::*;
37    use crate::mock;
38
39    #[test]
40    #[serial]
41    fn test_keychain_reset() -> Result<()> {
42        mock::device()?.boot()?;
43        mock::device()?.keychain().reset()?;
44        mock::device()?.shutdown()?;
45
46        Ok(())
47    }
48}