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 +4 -4
- data/History.txt +4 -0
- data/lib/mail/gpg/version.rb +1 -1
- data/test/action_mailer_test.rb +6 -1
- data/test/gpghome/gpg-agent.conf +2 -0
- data/test/message_test.rb +9 -2
- data/test/sign_part_test.rb +2 -0
- data/test/test_helper.rb +41 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8191b08971ab0e2c94468535b903e290296d087b
|
4
|
+
data.tar.gz: a124607c5ecdfb03b82483c18c8e0f88b913a807
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b6cd4cf9c4d8893a5db3270686eb01a09a70d555dbe8a1d1876f173969791d94299111a6dc465858d71b02a8551314b187f9c2f8cbdf8116154b64ad04992eeb
|
7
|
+
data.tar.gz: 195b1cdfc41f1fa894db64b3da58f17cfd4224bfdb6559b78f817233ee3c80e6d170cdaf4a720126593ce78466c47664fd98bcd42a7bdac311d2d12cfdc2e87a
|
data/History.txt
CHANGED
data/lib/mail/gpg/version.rb
CHANGED
data/test/action_mailer_test.rb
CHANGED
@@ -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
|
-
|
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
|
data/test/message_test.rb
CHANGED
@@ -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
|
-
|
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(
|
224
|
+
assert_raises(expected_exception){
|
218
225
|
m.decrypt
|
219
226
|
}
|
220
227
|
end
|
data/test/sign_part_test.rb
CHANGED
@@ -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
|
data/test/test_helper.rb
CHANGED
@@ -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.
|
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-
|
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
|