Skip to content

Commit

Permalink
vault multi get
Browse files Browse the repository at this point in the history
  • Loading branch information
timglabisch committed Jan 10, 2024
1 parent 95d53dd commit f5c1ed5
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/commands/get_multi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,9 @@ pub fn get_multi(input: &str, keymap: &KeyMap) -> Result<(), Error> {

if errors.len() != 0 {
eprintln!("could not decrypt some keys.");
for error in errors {
eprintln!("\t{}", error);
}
::std::process::exit(1);
}

Expand Down
13 changes: 13 additions & 0 deletions src/test_integration/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,19 @@ mod tests {
assert_eq!("VERSION_1_0_0_SECRET_CONTENT", String::from_utf8_lossy(&cmd(VAULT_INTEGRATION_TEST_DIR, "./vault", &["get", "VERSION_1_0_0_SECRET"], true)))
}

#[test]
#[serial]
fn test_integration_multi_key() {
test_prepare();

let content = cmd(VAULT_INTEGRATION_TEST_DIR, "./vault", &["get_multi", r#"{"secrets": [{"secret": "VERSION_1_0_0_SECRET"}], "templates": [{"template": "{vault{ VERSION_1_0_0_SECRET }vault}TEST"}]}"#], true);

assert_eq!(
String::from_utf8(content).expect("must be valid utf8"),
r#"{"secrets":{"VERSION_1_0_0_SECRET":{"name":"VERSION_1_0_0_SECRET","value":"VERSION_1_0_0_SECRET_CONTENT"}},"templates":{"{vault{ VERSION_1_0_0_SECRET }vault}TEST":{"name":"{vault{ VERSION_1_0_0_SECRET }vault}TEST","value":"VERSION_1_0_0_SECRET_CONTENTTEST"}}}"#
);
}

#[test]
#[serial]
fn test_integration_rotate_key_and_decode_content() {
Expand Down

0 comments on commit f5c1ed5

Please sign in to comment.