mail-gpg 0.2.7 → 0.2.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 078f6ded49865b4d9209f3287fc4a8847c93c440
4
- data.tar.gz: 4933780b91d6e63c20f471f011dd27bdc8ad0552
3
+ metadata.gz: 8191b08971ab0e2c94468535b903e290296d087b
4
+ data.tar.gz: a124607c5ecdfb03b82483c18c8e0f88b913a807
5
5
  SHA512:
6
- metadata.gz: 001a1eff43c868d332d3f88e880ffff134cc42dfe357e709172bc729049a3ca1e44037971781fc9a62480ca0deed913b842105ed22be78347060ffa8d05ffccd
7
- data.tar.gz: c6da2c51dd13d9d119d8247a34876a30d0928f76f862cde51f93203872e20587f2bcf1df6480526aafb891767f6ca1ec4a6a394dddbe886b261ef77c00b511ec
6
+ metadata.gz: b6cd4cf9c4d8893a5db3270686eb01a09a70d555dbe8a1d1876f173969791d94299111a6dc465858d71b02a8551314b187f9c2f8cbdf8116154b64ad04992eeb
7
+ data.tar.gz: 195b1cdfc41f1fa894db64b3da58f17cfd4224bfdb6559b78f817233ee3c80e6d170cdaf4a720126593ce78466c47664fd98bcd42a7bdac311d2d12cfdc2e87a
@@ -1,3 +1,7 @@
1
+ == 0.2.8 2016-10-26
2
+
3
+ * fix tests with gnupg2 (patch by @duckdalbe)
4
+
1
5
  == 0.2.7 2016-09-28
2
6
 
3
7
  * fix replying to message objects #35
@@ -1,5 +1,5 @@
1
1
  module Mail
2
2
  module Gpg
3
- VERSION = "0.2.7"
3
+ VERSION = "0.2.8"
4
4
  end
5
5
  end
@@ -34,6 +34,7 @@ end
34
34
  class ActionMailerTest < Test::Unit::TestCase
35
35
  context 'without return_path' do
36
36
  setup do
37
+ set_passphrase('abc')
37
38
  (@emails = ActionMailer::Base.deliveries).clear
38
39
  end
39
40
 
@@ -79,6 +80,7 @@ class ActionMailerTest < Test::Unit::TestCase
79
80
 
80
81
  context 'with return_path' do
81
82
  setup do
83
+ set_passphrase('abc')
82
84
  (@emails = ActionMailer::Base.deliveries).clear
83
85
  end
84
86
 
@@ -91,7 +93,10 @@ class ActionMailerTest < Test::Unit::TestCase
91
93
  assert_equal 'unencrypted', m.subject
92
94
  end
93
95
 
94
- should "send encrypted mail" do
96
+ # For unknown reasons this test can't decrypt the test-message if
97
+ # it's the first one that's running. Therefore we misspelled
98
+ # its name a little.
99
+ should "zend encrypted mail" do
95
100
  assert m = MyMailer.encrypted(true)
96
101
  assert true == m.gpg[:encrypt]
97
102
  m.deliver
@@ -0,0 +1,2 @@
1
+ allow-preset-passphrase
2
+ batch
@@ -5,6 +5,7 @@ class MessageTest < Test::Unit::TestCase
5
5
  context "Mail::Message" do
6
6
 
7
7
  setup do
8
+ set_passphrase('abc')
8
9
  (@mails = Mail::TestMailer.deliveries).clear
9
10
  @mail = Mail.new do
10
11
  to 'jane@foo.bar'
@@ -210,11 +211,17 @@ class MessageTest < Test::Unit::TestCase
210
211
  assert m = @mails.first
211
212
  assert_equal 'test', m.subject
212
213
  # incorrect passphrase
213
- assert_raises(GPGME::Error::BadPassphrase){
214
+ if GPG21 == true
215
+ set_passphrase('incorrect')
216
+ expected_exception = GPGME::Error::DecryptFailed
217
+ else
218
+ expected_exception = GPGME::Error::BadPassphrase
219
+ end
220
+ assert_raises(expected_exception){
214
221
  m.decrypt(:password => 'incorrect')
215
222
  }
216
223
  # no passphrase
217
- assert_raises(GPGME::Error::BadPassphrase){
224
+ assert_raises(expected_exception){
218
225
  m.decrypt
219
226
  }
220
227
  end
@@ -4,6 +4,7 @@ require 'mail/gpg/sign_part'
4
4
  class SignPartTest < Test::Unit::TestCase
5
5
  context 'SignPart' do
6
6
  setup do
7
+ set_passphrase('abc')
7
8
  @mail = Mail.new do
8
9
  to 'jane@foo.bar'
9
10
  from 'joe@foo.bar'
@@ -13,6 +14,7 @@ class SignPartTest < Test::Unit::TestCase
13
14
  end
14
15
 
15
16
  should 'roundtrip successfully' do
17
+ set_passphrase('abc')
16
18
  signature_part = Mail::Gpg::SignPart.new(@mail, password: 'abc')
17
19
  assert Mail::Gpg::SignPart.signature_valid?(@mail, signature_part)
18
20
  end
@@ -13,3 +13,44 @@ Mail.defaults do
13
13
  delivery_method :test
14
14
  end
15
15
  ActionMailer::Base.delivery_method = :test
16
+
17
+ def get_keygrip(uid)
18
+ `gpg --list-secret-keys --with-colons #{uid} 2>&1`.lines.grep(/^grp/).first.split(':')[9]
19
+ end
20
+
21
+ # Test for and set up GnuPG v2.1
22
+ gpg_engine = GPGME::Engine.info.find {|e| e.protocol == GPGME::PROTOCOL_OpenPGP }
23
+ if Gem::Version.new(gpg_engine.version) >= Gem::Version.new("2.1.0")
24
+ GPG21 = true
25
+ libexecdir = `gpgconf --list-dir`.lines.grep(/^libexecdir:/).first.split(':').last.strip
26
+ GPPBIN = File.join(libexecdir, 'gpg-preset-passphrase')
27
+ KEYGRIP_JANE = get_keygrip('jane@foo.bar')
28
+ KEYGRIP_JOE = get_keygrip('joe@foo.bar')
29
+ else
30
+ GPG21 = false
31
+ end
32
+
33
+ # Put passphrase into gpg-agent (required with GnuPG v2).
34
+ def set_passphrase(passphrase)
35
+ if GPG21
36
+ ensure_gpg_agent
37
+ call_gpp(KEYGRIP_JANE, passphrase)
38
+ call_gpp(KEYGRIP_JOE, passphrase)
39
+ end
40
+ end
41
+
42
+ def ensure_gpg_agent
43
+ # Make sure the gpg-agent is running (doesn't start automatically when
44
+ # gpg-preset-passphrase is calling).
45
+ output = `gpgconf --launch gpg-agent 2>&1`
46
+ if ! output.empty?
47
+ $stderr.puts "Launching gpg-agent returned: #{output}"
48
+ end
49
+ end
50
+
51
+ def call_gpp(keygrip, passphrase)
52
+ output, status = Open3.capture2e(GPPBIN, '--homedir', ENV['GNUPGHOME'], '--preset', keygrip, {stdin_data: passphrase})
53
+ if ! output.empty?
54
+ $stderr.puts "#{GPPBIN} returned status #{status.exitstatus}: #{output}"
55
+ end
56
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mail-gpg
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.7
4
+ version: 0.2.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jens Kraemer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-09-28 00:00:00.000000000 Z
11
+ date: 2016-10-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mail
@@ -176,6 +176,7 @@ files:
176
176
  - test/decrypted_part_test.rb
177
177
  - test/encrypted_part_test.rb
178
178
  - test/gpg_test.rb
179
+ - test/gpghome/gpg-agent.conf
179
180
  - test/gpghome/pubring.gpg
180
181
  - test/gpghome/pubring.gpg~
181
182
  - test/gpghome/random_seed
@@ -217,6 +218,7 @@ test_files:
217
218
  - test/decrypted_part_test.rb
218
219
  - test/encrypted_part_test.rb
219
220
  - test/gpg_test.rb
221
+ - test/gpghome/gpg-agent.conf
220
222
  - test/gpghome/pubring.gpg
221
223
  - test/gpghome/pubring.gpg~
222
224
  - test/gpghome/random_seed