Skip to content

Commit affaa0f

Browse files
committed
chore(external-ssh-signer): add tests
1 parent 5b2e9ed commit affaa0f

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

asyncgit/src/sync/sign.rs

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -447,10 +447,48 @@ mod tests {
447447
config.set_str("user.signingKey", "/tmp/key.pub")?;
448448
}
449449

450+
let sign =
451+
SignBuilder::from_gitconfig(&repo, &repo.config()?)?;
452+
453+
assert_eq!("ssh-keygen", sign.program());
454+
assert_eq!("/tmp/key.pub", sign.signing_key());
455+
456+
Ok(())
457+
}
458+
459+
#[test]
460+
fn test_ssh_keyliteral_config() -> Result<()> {
461+
let (_tmp_dir, repo) = repo_init_empty()?;
462+
463+
{
464+
let mut config = repo.config()?;
465+
config.set_str("gpg.program", "ssh")?;
466+
config.set_str("user.signingKey", "ssh-ed25519 test")?;
467+
}
468+
450469
let sign =
451470
SignBuilder::from_gitconfig(&repo, &repo.config()?)?;
452471

453472
assert_eq!("ssh", sign.program());
473+
assert_eq!(true, PathBuf::from(sign.signing_key()).is_file());
474+
475+
Ok(())
476+
}
477+
478+
#[test]
479+
fn test_ssh_external_bin_config() -> Result<()> {
480+
let (_tmp_dir, repo) = repo_init_empty()?;
481+
482+
{
483+
let mut config = repo.config()?;
484+
config.set_str("gpg.program", "/opt/ssh/signer")?;
485+
config.set_str("user.signingKey", "/tmp/key.pub")?;
486+
}
487+
488+
let sign =
489+
SignBuilder::from_gitconfig(&repo, &repo.config()?)?;
490+
491+
assert_eq!("/opt/ssh/signer", sign.program());
454492
assert_eq!("/tmp/key.pub", sign.signing_key());
455493

456494
Ok(())

0 commit comments

Comments
 (0)