From 314204608caa526d4238090c23367a30b8f41d10 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miloslav=20Trma=C4=8D?= Date: Thu, 6 Nov 2025 20:29:33 +0100 Subject: [PATCH] Update from very old GnuPG 1.4 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The last release was 1.4.23 in Jun 2018; it's not very relevant in modern environments. More importantly, the unit tests have been consistently failing on macOS recently, and per https://github.com/proglottis/gpgme/pull/48 it seems that the underlying GnuPG does not provide the expected output, and updating GnuPG fixes that. We've been pinned to 1.x for ctx.SetCallback, but that feature now exists in 2.x as well, as long as callers opt in. So, do so. Signed-off-by: Miloslav Trmač --- .github/workflows/go.yml | 2 +- gpgme_test.go | 45 ++-------------------------------------- 2 files changed, 3 insertions(+), 44 deletions(-) diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 20096c81c..ebe0f2d03 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -38,7 +38,7 @@ jobs: runs-on: macos-latest steps: - uses: actions/checkout@v3 - - run: brew install gpgme gnupg@1.4 + - run: brew install gpgme gnupg - uses: actions/setup-go@v3 with: go-version: '1.17.12' diff --git a/gpgme_test.go b/gpgme_test.go index 49ea5bdf3..1e1cd0865 100644 --- a/gpgme_test.go +++ b/gpgme_test.go @@ -8,7 +8,6 @@ import ( "os" "os/exec" "path/filepath" - "strings" "testing" ) @@ -118,10 +117,10 @@ func TestGetDirInfo(t *testing.T) { } func ctxWithCallback(t *testing.T) *Context { - ensureVersion(t, "1.", "can only set password callback for GPG v1.x") - ctx, err := New() checkError(t, err) + err = ctx.SetPinEntryMode(PinEntryLoopback) + checkError(t, err) checkError(t, ctx.SetCallback(func(uid_hint string, prev_was_bad bool, f *os.File) error { if prev_was_bad { @@ -395,46 +394,6 @@ func TestContext_AssuanSend(t *testing.T) { checkError(t, err) } -func isVersion(t testing.TB, version string) bool { - t.Helper() - var info *EngineInfo - info, err := GetEngineInfo() - checkError(t, err) - for info != nil { - if info.Protocol() == ProtocolOpenPGP { - if strings.Contains(info.FileName(), "gpg") && strings.HasPrefix(info.Version(), version) { - return true - } - return false - } - info = info.Next() - } - return false -} - -var gpgBins = []string{"gpg2", "gpg1", "gpg"} - -// ensureVersion tries to setup gpgme with a specific version or skip -func ensureVersion(t testing.TB, version, msg string) { - t.Helper() - if isVersion(t, version) { - return - } - for _, bin := range gpgBins { - path, err := exec.LookPath(bin) - if err != nil { - continue - } - if err := SetEngineInfo(ProtocolOpenPGP, path, absTestGPGHome()); err != nil { - continue - } - if isVersion(t, version) { - return - } - } - t.Skip(msg) -} - func diff(t testing.TB, dst, src []byte) { t.Helper() line := 1