Skip to content

Commit

Permalink
And one more...
Browse files Browse the repository at this point in the history
  • Loading branch information
smira committed Sep 26, 2018
1 parent fd63725 commit c64aca4
Showing 1 changed file with 25 additions and 12 deletions.
37 changes: 25 additions & 12 deletions pgp/gnupg_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,19 +161,32 @@ func (s *Gnupg2SignerSuite) SetUpTest(c *C) {
}

// import private keys into gpg2, they're stored outside of keyring files
output, err := exec.Command(gpg, "--import", "keyrings/aptly2.sec.armor").CombinedOutput()
c.Log(string(output))
c.Check(err, IsNil)

args := []string{"--import", "--passphrase", "verysecret", "--no-tty", "--batch"}
if ver == GPG21xPlus {
args = append(args, "--pinentry-mode", "loopback")
for _, item := range []struct {
suffix string
key string
}{
{"", "751DF85C2B220D45"},
{"_passphrase", "6656CD181E92D2D5"},
} {
if _, err := exec.Command(gpg, "--list-secret-keys", item.key).CombinedOutput(); err == nil {
// key already exists
continue
}

args := []string{"--import", "--no-default-keyring"}

if item.suffix == "_passprhase" {
args = append(args, "--passphrase", "verysecret", "--no-tty", "--batch")
if ver == GPG21xPlus {
args = append(args, "--pinentry-mode", "loopback")
}
}
args = append(args, "keyrings/aptly2"+item.suffix+".sec.armor")

output, err := exec.Command(gpg, args...).CombinedOutput()
c.Log(string(output))
c.Check(err, IsNil)
}
args = append(args, "keyrings/aptly2_passphrase.sec.armor")

output, err = exec.Command(gpg, args...).CombinedOutput()
c.Log(string(output))
c.Check(err, IsNil)

// import public keys into gpg2
// we can't use pre-built keyrings as gpg 2.0.x and 2.1+ have different keyring formats
Expand Down

0 comments on commit c64aca4

Please sign in to comment.