Skip to content

Commit

Permalink
test: Use dummy pinentry program
Browse files Browse the repository at this point in the history
We can't simply use loopback pinentry in our CI, because the gpg2
command installed on travis is too old to support it.  Instead, import
the dummy pinentry hack from the GPGME test suite.
  • Loading branch information
ueno committed Nov 30, 2018
1 parent 2a9ba02 commit d311b2b
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ before_install:
- sudo mknod -m 0666 /dev/random c 1 9
- echo HRNGDEVICE=/dev/urandom | sudo tee /etc/default/rng-tools
- sudo /etc/init.d/rng-tools restart
- gpg --version
- gpg2 --version
- gpgconf --list-options gpg-agent

script: travis_wait bundle exec rake TESTOPTS="-v"

Expand Down
22 changes: 22 additions & 0 deletions test/pinentry
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#! /bin/bash
# Dummy pinentry
#
# Copyright 2008 g10 Code GmbH
#
# This file is free software; as a special exception the author gives
# unlimited permission to copy and/or distribute it, with or without
# modifications, as long as this notice is preserved.
#
# This file is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY, to the extent permitted by law; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
# PURPOSE.

echo OK Your orders please

while read cmd; do
case $cmd in
GETPIN) echo D gpgme; echo OK;;
*) echo OK;;
esac
done
5 changes: 5 additions & 0 deletions test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,16 @@ def ensure_keys(proto)
# We use a different home directory for the keys to not disturb current
# installation
require 'tmpdir'
require 'pathname'

if DIRS.empty?
dir = Dir.mktmpdir
GPGME::Engine.home_dir = dir
DIRS.push(dir)
pinentry = Pathname.new(__FILE__).dirname + 'pinentry'
gpg_agent_conf = Pathname.new(dir) + 'gpg-agent.conf'.open('w+') {|io|
io.write("pinentry-program #{pinentry}\n")
}
remove_all_keys
import_keys
end
Expand Down

0 comments on commit d311b2b

Please sign in to comment.