commit e3b04a37bf28db7800b0e5bc7d0d7cd6d1ecbb21
parent 5a18265274b7789442c64e8b2d051ef3a68659a8
Author: Gaute Hope <eg@gaute.vetsj.com>
Date: Mon, 12 Aug 2013 12:36:30 +0200
Update patch for develop: Use test-keys and adapt tests for test-suite
Generated (and checked in) two test gpg keys (test/gnupg_test_home)
which are used for testing the crypto suite with gpgme 2.0. The keys
expire after 1 year today.
They were generated using gpg --gen-key, to create new keys:
0. Set the GNUPGHOME environment variable to: /full/path/test/gnupg_test_home/
1. Generate receiver keys for email: sup-test-2@foo.bar (no password)
2. Export key
3. Move keyrings to receiver_*.gpg
4. Generate sender keys for email: sup-test-1@foo.bar (no password)
5. Update test/gnupg_test_home/gpg.conf with deafult-key to represent
the new sender key.
Diffstat:
14 files changed, 54 insertions(+), 34 deletions(-)
diff --git a/.gitignore b/.gitignore
@@ -11,3 +11,7 @@ sup-exception-log.txt
# bundler stuff
Gemfile.lock
.bundle
+
+# generated file for gnupg test
+test/gnupg_test_home/random_seed
+
diff --git a/History.txt b/History.txt
@@ -6,6 +6,7 @@
* Thread safety
* No more Iconv, but using built in Ruby encodings. Better UTF-8
handling.
+* GPGME 2.0 support
== 0.13.2 / 2013-06-26
diff --git a/ReleaseNotes b/ReleaseNotes
@@ -1,7 +1,7 @@
Release 0.14.0:
-CJK-compatability, Psych usage, thread safety. Sup is now Ruby 1.9 based, and
-apart from RMail - ready for Ruby 2.0.0.
+CJK-compatability, Psych usage, thread safety, GPGME 2.0 support. Sup is now
+Ruby 1.9 based, and apart from RMail - ready for Ruby 2.0.0.
Sup now uses Psych as a YAML parser (default by Ruby) and your previous
configuration files (~/.sup/*.yaml) may need to be migrated or re-created for
diff --git a/bin/sup b/bin/sup
@@ -9,8 +9,6 @@ require 'ncursesw'
no_gpgme = false
begin
- # gpgme broke its API in 2.0, so make sure we have the old version for now.
- gem 'gpgme', '=1.0.8'
require 'gpgme'
rescue LoadError
no_gpgme = true
diff --git a/lib/sup/crypto.rb b/lib/sup/crypto.rb
@@ -1,6 +1,4 @@
begin
- # gpgme broke its API in 2.0, so make sure we have the old version for now.
- gem 'gpgme', '=1.0.8'
require 'gpgme'
rescue LoadError
end
diff --git a/test/gnupg_test_home/gpg.conf b/test/gnupg_test_home/gpg.conf
@@ -0,0 +1 @@
+default-key 789E7011
diff --git a/test/gnupg_test_home/pubring.gpg b/test/gnupg_test_home/pubring.gpg
Binary files differ.
diff --git a/test/gnupg_test_home/receiver_pubring.gpg b/test/gnupg_test_home/receiver_pubring.gpg
Binary files differ.
diff --git a/test/gnupg_test_home/receiver_secring.gpg b/test/gnupg_test_home/receiver_secring.gpg
Binary files differ.
diff --git a/test/gnupg_test_home/receiver_trustdb.gpg b/test/gnupg_test_home/receiver_trustdb.gpg
Binary files differ.
diff --git a/test/gnupg_test_home/secring.gpg b/test/gnupg_test_home/secring.gpg
Binary files differ.
diff --git a/test/gnupg_test_home/sup-test-2@foo.bar.asc b/test/gnupg_test_home/sup-test-2@foo.bar.asc
@@ -0,0 +1,20 @@
+-----BEGIN PGP PUBLIC KEY BLOCK-----
+Version: GnuPG v2.0.20 (GNU/Linux)
+
+mI0EUgi0fAEEAOLAcQW96NEUSB7YE/la8X56jGW5BMX3aAixOF8LvOwMBbUK1T+U
+0H2PGIrXVcYyHcPqWRpRahbsIAldBqzffPlzMa+aqJaB1xKkNruxSoIzwPdidZMe
+l0Dxz2FDsoXD0KPyWnAYhGmQyz2MFpZxu2tlYqvwWVW//XGnk/KHvIXbABEBAAG0
+PlN1cCBUZXN0IFJlY2VpdmVyIChUZXN0IHJlY2VpdmVyIGZvciBTdXApIDxzdXAt
+dGVzdC0yQGZvby5iYXI+iL8EEwECACkFAlIItHwCGwMFCQHhM4AHCwkIBwMCAQYV
+CAIJCgsEFgIDAQIeAQIXgAAKCRAsABl+cWpykMMVBADHkQPgTz0CqKKp3k+z3dbm
+ocmI4tYNn1dOkDQqyfoBTfs6L3g4j5OE2UrguntRYyg5oon+uO5d18CQ5dY0sCw/
+o5IwyzTrxI8IocbtZvBdSb+XjLndynGuIQoqaJq9i6n1V4klFHVOna8Q9JstLfRX
+H1d4xPhnvKcaDDx/NV3X/biNBFIItHwBBADBpb43MpkrUWlg7HWJ1ZfOlxnOxrJ3
+Gz9WFNV06UbcZEuFKA/vHRjM6gWzUn5903FLuCWu3eBrq5xQfWipbp187PmocpoG
+skJ6gosLs1fMYRBjv2VbG9xJVKdKJMjqZw5FUpXKAaHr8P9jN6g2STQrbeQ8CVUK
+h7zOWRXAXSKUgwARAQABiKUEGAECAA8FAlIItHwCGwwFCQHhM4AACgkQLAAZfnFq
+cpDV1QQAzcxFXznEX92DjWxWRC7gRHgIsQk9WJnDzjtnDjSWCp3H85qeTZGZrn9W
+NoneV/S5Y7K3Mkceh4rFaANQ3zx4b05y1LFt5N/lPwIe5VB0vcPumtZum2fSGfpK
+nTXvzelcWcm2aGyUSaWvOkntWKEEt1kB5Oq6EtZoRZLMzAxLd7s=
+=aKsV
+-----END PGP PUBLIC KEY BLOCK-----
diff --git a/test/gnupg_test_home/trustdb.gpg b/test/gnupg_test_home/trustdb.gpg
Binary files differ.
diff --git a/test/test_crypto.rb b/test/test_crypto.rb
@@ -1,56 +1,55 @@
-#!/usr/bin/ruby
-
# tests for sup's crypto libs
#
# Copyright Clint Byrum <clint@ubuntu.com> 2011. All Rights Reserved.
+# Copyright Sup Developers 2013.
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
-#
+#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
-#
+#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
# 02110-1301, USA.
-require 'tmpdir'
-require 'test/unit'
-require 'rmail/message'
-require 'rmail/parser'
-require 'sup/util'
-require 'sup/hook'
-require 'sup/contact'
-require 'sup/person'
-require 'sup/account'
-require 'sup/message-chunks'
-require 'sup/crypto'
+require 'test_helper'
+require 'sup'
require 'stringio'
+require 'tmpdir'
module Redwood
-# These are all singletons
-CryptoManager.init
-Dir.mktmpdir('sup-test') do|f|
- HookManager.init f
-end
-am = {:default=> {:name => "", :email=>ENV['EMAIL']}}
-AccountManager.init am
-
-class TestCryptoManager < Test::Unit::TestCase
+class TestCryptoManager < ::Minitest::Unit::TestCase
def setup
- @from_email = ENV['EMAIL']
- # Change this or import my public key to make these tests work.
- @to_email = 'clint@ubuntu.com'
+ @from_email = 'sup-test-1@foo.bar'
+ @to_email = 'sup-test-2@foo.bar'
+ # Use test gnupg setup
+ @orig_gnupghome = ENV['GNUPGHOME']
+ ENV['GNUPGHOME'] = File.join(File.dirname(__FILE__), 'gnupg_test_home')
+
+ @path = Dir.mktmpdir
+ Redwood::HookManager.init File.join(@path, 'hooks')
+
+ am = {:default=> {:name => "test", :email=> 'sup-test-1@foo.bar'}}
+ Redwood::AccountManager.init am
+
+ Redwood::CryptoManager.init
end
def teardown
+ CryptoManager.deinstantiate!
+ AccountManager.deinstantiate!
+ HookManager.deinstantiate!
+ FileUtils.rm_r @path
+
+ ENV['GNUPGHOME'] = @orig_gnupghome
end
def test_sign
@@ -101,7 +100,6 @@ class TestCryptoManager < Test::Unit::TestCase
CryptoManager.verify signed.body[0], signed.body[1], true
end
end
-
end
end