• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

ssh-vault / ssh-vault / 20283327018

16 Dec 2025 09:29PM UTC coverage: 89.55% (+0.04%) from 89.512%
20283327018

push

github

nbari
1.2.0

253 of 277 new or added lines in 19 files covered. (91.34%)

1 existing line in 1 file now uncovered.

2168 of 2421 relevant lines covered (89.55%)

44.32 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

98.36
/src/cli/commands/edit.rs
1
use clap::{Arg, Command};
2

3
pub fn subcommand_edit() -> Command {
6✔
4
    Command::new("edit")
6✔
5
        .about("Edit an existing vault")
6✔
6
        .after_help(
6✔
7
            r"Examples:
8

9
Edit a secret:
10

11
    ssh-vault edit /path/to/secret.vault
12
",
13
        )
14
        .visible_alias("e")
6✔
15
        .arg(
6✔
16
            Arg::new("key")
6✔
17
                .short('k')
6✔
18
                .long("key")
6✔
19
                .help("Path to the private ssh key to use for decyrpting"),
6✔
20
        )
21
        .arg(
6✔
22
            Arg::new("passphrase")
6✔
23
                .short('p')
6✔
24
                .long("passphrase")
6✔
25
                .env("SSH_VAULT_PASSPHRASE")
6✔
26
                .help("Passphrase of the private ssh key"),
6✔
27
        )
28
        .arg(
6✔
29
            Arg::new("vault")
6✔
30
                .required(true)
6✔
31
                .help("Path of the vault to edit"),
6✔
32
        )
33
}
6✔
34

35
#[cfg(test)]
36
mod tests {
37
    use super::*;
38

39
    #[test]
40
    fn test_subcommand_edit() {
1✔
41
        let app = Command::new("ssh-vault").subcommand(subcommand_edit());
1✔
42
        let matches = app.try_get_matches_from(vec!["ssh-vault", "edit", "-k", "test"]);
1✔
43
        assert!(matches.is_err());
1✔
44
    }
1✔
45

46
    #[test]
47
    fn test_subcommand_edit_ok() -> Result<(), Box<dyn std::error::Error>> {
1✔
48
        let app = Command::new("ssh-vault").subcommand(subcommand_edit());
1✔
49
        let matches =
1✔
50
            app.try_get_matches_from(vec!["ssh-vault", "edit", "-k", "test", "/tmp/vault"])?;
1✔
51

52
        let m = matches
1✔
53
            .subcommand_matches("edit")
1✔
54
            .ok_or("No edit subcommand")?
1✔
55
            .to_owned();
1✔
56
        assert_eq!(m.get_one::<String>("key").ok_or("No key")?, "test");
1✔
57
        assert!(m.get_one::<String>("passphrase").is_none());
1✔
58
        assert_eq!(
1✔
59
            m.get_one::<String>("vault").ok_or("No vault")?,
1✔
60
            "/tmp/vault"
61
        );
62
        Ok(())
1✔
63
    }
1✔
64

65
    #[test]
66
    fn test_subcommand_edit_with_passphrase() -> Result<(), Box<dyn std::error::Error>> {
1✔
67
        let app = Command::new("ssh-vault").subcommand(subcommand_edit());
1✔
68
        let matches = app.try_get_matches_from(vec![
1✔
69
            "ssh-vault",
70
            "edit",
1✔
71
            "-k",
1✔
72
            "test",
1✔
73
            "-p",
1✔
74
            "passphrase",
1✔
75
            "/tmp/vault",
1✔
NEW
76
        ])?;
×
77

78
        let m = matches
1✔
79
            .subcommand_matches("edit")
1✔
80
            .ok_or("No edit subcommand")?
1✔
81
            .to_owned();
1✔
82
        assert_eq!(m.get_one::<String>("key").ok_or("No key")?, "test");
1✔
83
        assert_eq!(
1✔
84
            m.get_one::<String>("passphrase").ok_or("No passphrase")?,
1✔
85
            "passphrase"
86
        );
87
        assert_eq!(
1✔
88
            m.get_one::<String>("vault").ok_or("No vault")?,
1✔
89
            "/tmp/vault"
90
        );
91
        Ok(())
1✔
92
    }
1✔
93
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc