[DRE-commits] [schleuder] 21/52: New upstream version 3.0.0~beta14

Georg Faerber georg-alioth-guest at moszumanska.debian.org
Mon Feb 6 11:21:20 UTC 2017


This is an automated email from the git hooks/post-receive script.

georg-alioth-guest pushed a commit to branch master
in repository schleuder.

commit de6939b3b1de07fd4f53354faf4aa6e210e50c71
Author: Georg Faerber <georg at riseup.net>
Date:   Thu Dec 29 19:06:38 2016 +0100

    New upstream version 3.0.0~beta14
---
 CHANGELOG.md                                       |  13 ++
 CONTRIBUTING.md                                    |   5 +-
 Gemfile.lock                                       |   8 +-
 README.md                                          |  14 ++-
 lib/schleuder/cli.rb                               |   8 +-
 lib/schleuder/list.rb                              |   8 +-
 lib/schleuder/mail/message.rb                      |   8 +-
 lib/schleuder/runner.rb                            |   1 -
 lib/schleuder/version.rb                           |   2 +-
 schleuder.gemspec                                  |   2 +-
 spec/factories/lists.rb                            |   5 +
 .../mails/encrypted+signed-inline/thunderbird.eml  |  68 +++++++++++
 .../mails/encrypted+signed-mime/thunderbird.eml    |  90 ++++++++++++++
 .../mails/encrypted-inline/thunderbird.eml         |  56 +++++++++
 spec/fixtures/mails/encrypted-mime/thunderbird.eml |  76 ++++++++++++
 spec/fixtures/mails/plain/thunderbird.eml          |  53 ++++++++
 spec/fixtures/mails/signed-inline/thunderbird.eml  |  39 ++++++
 spec/fixtures/mails/signed-mime/thunderbird.eml    |  61 ++++++++++
 spec/fixtures/schleuder_at_example_public_key.txt  |  49 ++++++++
 spec/schleuder.yml                                 |   4 +
 spec/schleuder/integration/send_encrypted_spec.rb  |  19 +++
 spec/schleuder/integration/send_plain_spec.rb      |  19 +++
 spec/schleuder/runner_spec.rb                      | 134 +++++++++++++++++++-
 spec/schleuder/{ => unit}/list_spec.rb             | 135 +++++++++++++++++++--
 spec/schleuder/{ => unit}/subscription_spec.rb     |   0
 spec/smtp-daemon.rb                                |  72 +++++++++++
 spec/spec_helper.rb                                |  59 +++++----
 27 files changed, 939 insertions(+), 69 deletions(-)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index de5b16a..b38955e 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -5,6 +5,19 @@ This project adheres to [Semantic Versioning](http://semver.org/).
 
 The format of this file is based on [Keep a Changelog](http://keepachangelog.com/).
 
+## [3.0.0.beta14] / 2016-12-29
+
+### Fixed
+
+* Fix key expiry check
+* Fix link to schleuder.nadir.org in List-Help header
+* Fix deleting listdir
+
+### Added
+
+ * Runner and integration tests
+ * More fixtures
+
 ## [3.0.0.beta13] / 2016-12-22
 
 ### Fixed
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index f2d2a03..91e5727 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -6,8 +6,9 @@ To contribute please follow this workflow:
 1. Talk to us! E.g. create an issue about your idea or problem.
 2. Fork the repository and work in a meaningful named branch that is based off of our "master".
 3. Commit in rather small chunks but don't split depending code across commits. Please write sensible commit messages.
-4. If in doubt request feedback from us!
-5. When finished create a merge request.
+4. Please add tests for your feature or bugfix.
+5. If in doubt request feedback from us!
+6. When finished create a merge request.
 
 
 Thank you for your interest!
diff --git a/Gemfile.lock b/Gemfile.lock
index 3ff4b46..1f8a77f 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -1,9 +1,9 @@
 PATH
   remote: .
   specs:
-    schleuder (3.0.0.beta13)
+    schleuder (3.0.0.beta14)
       activerecord (~> 4.1)
-      mail-gpg (~> 0.2.7)
+      mail-gpg (~> 0.3.0)
       rake (~> 10)
       sinatra (~> 1)
       sinatra-contrib (~> 1)
@@ -43,7 +43,7 @@ GEM
     json (1.8.3)
     mail (2.6.4)
       mime-types (>= 1.16, < 4)
-    mail-gpg (0.2.9)
+    mail-gpg (0.3.0)
       gpgme (~> 2.0, >= 2.0.2)
       mail (~> 2.5, >= 2.5.3)
     mime-types (3.1)
@@ -52,7 +52,7 @@ GEM
     mini_portile2 (2.1.0)
     minitest (5.9.1)
     multi_json (1.12.1)
-    rack (1.6.4)
+    rack (1.6.5)
     rack-protection (1.5.3)
       rack
     rack-test (0.6.3)
diff --git a/README.md b/README.md
index dc282b9..e5d642c 100644
--- a/README.md
+++ b/README.md
@@ -42,15 +42,15 @@ Additionally these **rubygems** are required (will be installed automatically un
 Installing Schleuder
 ------------
 
-1. Download [the gem](https://git.codecoop.org/schleuder/schleuder3/raw/master/gems/schleuder-3.0.0.beta13.gem) and [the OpenPGP-signature](https://git.codecoop.org/schleuder/schleuder3/raw/master/gems/schleuder-3.0.0.beta13.gem.sig) and verify:
+1. Download [the gem](https://git.codecoop.org/schleuder/schleuder3/raw/master/gems/schleuder-3.0.0.beta14.gem) and [the OpenPGP-signature](https://git.codecoop.org/schleuder/schleuder3/raw/master/gems/schleuder-3.0.0.beta14.gem.sig) and verify:
    ```
    gpg --recv-key 0xB3D190D5235C74E1907EACFE898F2C91E2E6E1F3
-   gpg --verify schleuder-3.0.0.beta13.gem.sig
+   gpg --verify schleuder-3.0.0.beta14.gem.sig
    ```
 
 2. If all went well install the gem:
    ```
-   gem install schleuder-3.0.0.beta13.gem
+   gem install schleuder-3.0.0.beta14.gem
    ```
 
 3. Set up schleuder:
@@ -98,10 +98,16 @@ See <https://git.codecoop.org/schleuder/schleuder3/issues>.
 
 Testing
 -------
+We use rspec to test our code. To setup the test environment run:
+
 
     SCHLEUDER_ENV=test SCHLEUDER_CONFIG=spec/schleuder.yml bundle exec rake db:create db:schema:load
+
+To execute the test suite run:
+
     bundle exec rspec
 
+We are working on extendig the test coverage.
 
 Contributing
 ------------
@@ -118,4 +124,4 @@ GNU GPL 3.0. Please see [LICENSE.txt](LICENSE.txt).
 Alternative Download
 --------------------
 
-Alternatively to the gem-files you can download the latest release as [a tarball](https://git.codecoop.org/schleuder/schleuder3/raw/master/gems/schleuder-3.0.0.beta13.tar.gz) and [its OpenPGP-signature](https://git.codecoop.org/schleuder/schleuder3/raw/master/gems/schleuder-3.0.0.beta13.tar.gz.sig).
+Alternatively to the gem-files you can download the latest release as [a tarball](https://git.codecoop.org/schleuder/schleuder3/raw/master/gems/schleuder-3.0.0.beta14.tar.gz) and [its OpenPGP-signature](https://git.codecoop.org/schleuder/schleuder3/raw/master/gems/schleuder-3.0.0.beta14.tar.gz.sig).
diff --git a/lib/schleuder/cli.rb b/lib/schleuder/cli.rb
index 6ec91d0..b172603 100644
--- a/lib/schleuder/cli.rb
+++ b/lib/schleuder/cli.rb
@@ -50,8 +50,8 @@ module Schleuder
     end
 
     desc 'check_keys', 'Check all lists for unusable or expiring keys and send the results to the list-admins. (This is supposed to be run from cron weekly.)'
-    def check_keys(listname=nil)
-      Schleuder::List.all.each do |list|
+    def check_keys
+      List.all.each do |list|
         I18n.locale = list.language
 
         text = list.check_keys
@@ -252,10 +252,6 @@ Please notify the users and admins of this list of these changes.
           KEYWORDS[keyword.downcase]
         end.compact
       end
-
-      def chmod(file)
-        FileUtils.chmod_R('o-rwx', file)
-      end
     end
   end
 end
diff --git a/lib/schleuder/list.rb b/lib/schleuder/list.rb
index 21c6ccf..4c9fffa 100644
--- a/lib/schleuder/list.rb
+++ b/lib/schleuder/list.rb
@@ -136,7 +136,7 @@ module Schleuder
         expiry = key.subkeys.first.expires
         if expiry && expiry > now && expiry < checkdate
           # key expires in the near future
-          expdays = ((exp - now)/86400).to_i
+          expdays = ((expiry - now)/86400).to_i
           expiring << [key, expdays]
         end
 
@@ -282,14 +282,12 @@ module Schleuder
     private
 
     def set_gnupg_home
-      if ENV["SCHLEUDER_ENV"] != "test"
-        ENV['GNUPGHOME'] = listdir
-      end
+      ENV['GNUPGHOME'] = listdir
     end
 
     def delete_listdir
       if File.exists?(self.listdir)
-        FileUtils.rm_r(self.listdir, secure: true)
+        FileUtils.rm_rf(self.listdir, secure: true)
         Schleuder.logger.info "Deleted listdir"
       else
         # Don't use list-logger here — if the list-dir isn't present we can't log to it!
diff --git a/lib/schleuder/mail/message.rb b/lib/schleuder/mail/message.rb
index cd76934..8b9aa86 100644
--- a/lib/schleuder/mail/message.rb
+++ b/lib/schleuder/mail/message.rb
@@ -11,9 +11,9 @@ module Mail
     def setup(recipient, list)
       if self.encrypted?
         new = self.decrypt(verify: true)
-        # Work around a bug in mail-gpg: when decrypting pgp/mime the
-        # Date-header is not copied.
-        new.date ||= self.date
+        ## Work around a bug in mail-gpg: when decrypting pgp/mime the
+        ## Date-header is not copied.
+        #new.date ||= self.date
         # Test if there's a signed multipart inside the ciphertext
         # ("encapsulated" format of pgp/mime).
         if new.signed?
@@ -248,7 +248,7 @@ module Mail
       if list.include_list_headers
         self['List-Id'] = "<#{list.email.gsub('@', '.')}>"
         self['List-Owner'] = "<mailto:#{list.owner_address}> (Use list's public key)"
-        self['List-Help'] = '<https://schleuder2.nadir.org/>'
+        self['List-Help'] = '<https://schleuder.nadir.org/>'
 
         postmsg = if list.receive_admin_only
                     "NO (Admins only)"
diff --git a/lib/schleuder/runner.rb b/lib/schleuder/runner.rb
index a4fae83..530ceb2 100644
--- a/lib/schleuder/runner.rb
+++ b/lib/schleuder/runner.rb
@@ -127,6 +127,5 @@ module Schleuder
       ENV['GNUPGHOME'] = @list.listdir
       nil
     end
-
   end
 end
diff --git a/lib/schleuder/version.rb b/lib/schleuder/version.rb
index 1a2c453..4b62400 100644
--- a/lib/schleuder/version.rb
+++ b/lib/schleuder/version.rb
@@ -1,3 +1,3 @@
 module Schleuder
-  VERSION = '3.0.0.beta13'
+  VERSION = '3.0.0.beta14'
 end
diff --git a/schleuder.gemspec b/schleuder.gemspec
index ec1b7d8..f9b5844 100644
--- a/schleuder.gemspec
+++ b/schleuder.gemspec
@@ -20,7 +20,7 @@ Gem::Specification.new do |s|
   #s.signing_key = "#{ENV['HOME']}/.gem/schleuder-gem-private_key.pem"
   #s.cert_chain  = ['gem-public_cert.pem']
   s.license = 'GPL-3.0'
-  s.add_runtime_dependency 'mail-gpg', '~> 0.2.7'
+  s.add_runtime_dependency 'mail-gpg', '~> 0.3.0'
   s.add_runtime_dependency 'activerecord', '~> 4.1'
   s.add_runtime_dependency 'rake', '~> 10'
   s.add_runtime_dependency 'sqlite3', '~> 1'
diff --git a/spec/factories/lists.rb b/spec/factories/lists.rb
index 0c26d5f..2555ddc 100644
--- a/spec/factories/lists.rb
+++ b/spec/factories/lists.rb
@@ -27,6 +27,11 @@ FactoryGirl.define do
     language "en"
     forward_all_incoming_to_admins false
     logfiles_to_keep 2
+    after(:build) do |list|
+      FileUtils.mkdir_p(list.listdir)
+      gpghome_upstream = File.join ENV["SCHLEUDER_ROOT"], "spec", "gnupg"
+      FileUtils.cp_r Dir["#{gpghome_upstream}/{private*,*.gpg,.*migrated}"], list.listdir
+    end
 
     trait :with_one_subscription do
       after(:build) do |list|
diff --git a/spec/fixtures/mails/encrypted+signed-inline/thunderbird.eml b/spec/fixtures/mails/encrypted+signed-inline/thunderbird.eml
new file mode 100644
index 0000000..281a751
--- /dev/null
+++ b/spec/fixtures/mails/encrypted+signed-inline/thunderbird.eml
@@ -0,0 +1,68 @@
+Received: from [IPv6:::1] (localhost.localdomain [IPv6:::1])
+	by flutsch.local (Postfix) with ESMTP id 63585801DD
+	for <schleuder at example.org>; Thu, 29 Dec 2016 15:17:07 +0100 (CET)
+To: schleuder at example.org
+From: paz <paz at nadir.org>
+Subject: encrypted+signed-inline test
+Openpgp: id=52507B0163A8D9F0094FFE03B1A36F08069E55DE
+Message-ID: <216c8188-a773-fa94-d2e1-b2db4a309fed at nadir.org>
+Date: Thu, 29 Dec 2016 15:17:07 +0100
+User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
+ Thunderbird/45.5.1
+MIME-Version: 1.0
+Content-Type: text/plain; charset=utf-8
+Content-Transfer-Encoding: 8bit
+
+-----BEGIN PGP MESSAGE-----
+Charset: utf-8
+
+hQIMA691X8Gl2MArAQ//U47/ExT/T15q05GxT4HWcStkrzrjnRFOPs4x49YZRSaq
+10oPuHxEId+WdYQpiN+ffBqsf2Wozb/fBTi/TJ/Q7eXaSr2soRHbR4WxtJbZhgtf
+o9w6g/3EGurx2hj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+xryXXR6S
+ZM36HFcyeNFF7C8Py89we00gOAT2wNS3897F3T2+Zq6V7dhNIz0XiYPRtnkLmsUx
+W+JPq+zfzYz9kJ18rE1k0HsjvCrEDSMeOkpl4bkJhlmYLSvarUevGe42b6nWU9mm
+4CuM8DhL564OBvUpYCyqTJIDIGJjPtLQ2P/uDo4GdYnSpStIMmycsvpVlFytlbNp
+FWc4PF7uWEOu7p3zpbPYenJFETqIIGKmkKHBHyNseZfD67ceAoOBxr6yVZ6W0u0P
+EM8KgROhcQzP22Ob3aOc1LsrxqPEGuAkWq0vajmhPO8cCVfaOAbbD3dGYgmZu8Ol
+mZE7noGrA7vT/jB6PTZknl+b3X2Q1JITr01rfIeHfdZrderYVskhbzS3zqAGH/LL
+Qtc2oPRi5giZJb/9qmjld774Z8uDQ3P9WXW5G9LE+Nw29HPUrAJ4fMlDi09fiDP0
+1XDcws+WT86LkvAy2yE/wj6Mdad7hwhceshDR4aOBHJKsdgiwUIj8cN6yRQuslr/
+t7gyeFlu4haAH0hy5U0kxX8UzID3UlSWdJwlNLc54bL2qcpiFRHu5HI3j+W0PYFz
+/UIbVfgKBC2uf3PZ2lfV5oZsKDBOhiJnnqPHjC95fMxxlS/+03FvTZ7+Vr6OVBgi
+qEUnwdBfiIQJ/njT0TZKYajXyA2F7u+2Rq2O2Wz1fZ+oeN6Ep7eIPYAnfRyyDAhT
+p+8zpD4ibl6AILhpO30EwD8W/ntYXlD8hCNxIEcwPil2M/2IryN+H9aTdwENyl1J
+IRNo4dJ6xTzOYXQD0Wo+z5kV
+=gl5b
+-----END PGP MESSAGE-----
diff --git a/spec/fixtures/mails/encrypted+signed-mime/thunderbird.eml b/spec/fixtures/mails/encrypted+signed-mime/thunderbird.eml
new file mode 100644
index 0000000..d44aee8
--- /dev/null
+++ b/spec/fixtures/mails/encrypted+signed-mime/thunderbird.eml
@@ -0,0 +1,90 @@
+Received: from [IPv6:::1] (localhost.localdomain [IPv6:::1])
+	by flutsch.local (Postfix) with ESMTP id 1DCDC801DD
+	for <schleuder at example.org>; Thu, 29 Dec 2016 15:09:43 +0100 (CET)
+To: schleuder at example.org
+From: paz <paz at nadir.org>
+Subject: encrypted+signed-mime test
+Openpgp: id=52507B0163A8D9F0094FFE03B1A36F08069E55DE
+Message-ID: <ef1bb457-c90c-7773-219c-3cb9365dc7bf at nadir.org>
+Date: Thu, 29 Dec 2016 15:09:29 +0100
+User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
+ Thunderbird/45.5.1
+MIME-Version: 1.0
+Content-Type: multipart/encrypted;
+ protocol="application/pgp-encrypted";
+ boundary="V4nVnp5nddnPgg4bACDcs1kSu5wBuHpL9"
+
+This is an OpenPGP/MIME encrypted message (RFC 4880 and 3156)
+--V4nVnp5nddnPgg4bACDcs1kSu5wBuHpL9
+Content-Type: application/pgp-encrypted
+Content-Description: PGP/MIME version identification
+
+Version: 1
+
+--V4nVnp5nddnPgg4bACDcs1kSu5wBuHpL9
+Content-Type: application/octet-stream; name="encrypted.asc"
+Content-Description: OpenPGP encrypted message
+Content-Disposition: inline; filename="encrypted.asc"
+
+-----BEGIN PGP MESSAGE-----
+
+hQIMA691X8Gl2MArAQ//WH7ld2syFOvYU0l0s5Mx+FyT74166+s1i5UK37HkzVTq
+/BPZcvB4IZ6KnKF/Gs67hs5n0I1r4o5ZgECLEso9Wpciw5uu9ES3nXm3x0C+tCZ1
+aI0JgCnpq2kdY06/Zc7Tr3rvsn+xZxHo1SGiaS6sFt2dyFCFZpX8xidlOe13+vG7
+29IMKoW2eZeF62W60MXy7HHoohWj0/bp3jB50G/kYcpka/10NYQkBWLm+DQ74Hxa
+CvN/WHO6W8srnJy+KnzJ3BsRTr4Js5sYIPnqao6UcGfr6iZQF1fDGUTlypKIoBkR
+DyuFXBGs+XW+Mk9S9X7DNTAPvTedciPSR3+TM0kjQmsam5e2Sm5k4W+wtdlFYlOP
+BqpYigAwMylQfQsTJ+M9Ds/0TtMWmPURzw15MI5a9fXGFT8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--V4nVnp5nddnPgg4bACDcs1kSu5wBuHpL9--
diff --git a/spec/fixtures/mails/encrypted-inline/thunderbird.eml b/spec/fixtures/mails/encrypted-inline/thunderbird.eml
new file mode 100644
index 0000000..daa212a
--- /dev/null
+++ b/spec/fixtures/mails/encrypted-inline/thunderbird.eml
@@ -0,0 +1,56 @@
+Received: from [IPv6:::1] (localhost.localdomain [IPv6:::1])
+	by flutsch.local (Postfix) with ESMTP id C4826801DD
+	for <schleuder at example.org>; Thu, 29 Dec 2016 15:19:35 +0100 (CET)
+To: schleuder at example.org
+From: paz <paz at nadir.org>
+Subject: encrypted-inline test
+Openpgp: id=52507B0163A8D9F0094FFE03B1A36F08069E55DE
+Message-ID: <af8bee67-3837-10e6-cfc0-7c0d8be9c654 at nadir.org>
+Date: Thu, 29 Dec 2016 15:19:35 +0100
+User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
+ Thunderbird/45.5.1
+MIME-Version: 1.0
+Content-Type: text/plain; charset=utf-8
+Content-Transfer-Encoding: 8bit
+
+-----BEGIN PGP MESSAGE-----
+Charset: utf-8
+
+hQIMA691X8Gl2MArAQ/+OQczLE7CgyUgZAg3dRWeTrNIkqlo7KMWxCyVfH310vKz
+rrTVFWbBeS0sOmMpN4cJSvJns2W+hJ9FnAdNtCPLC2zWhnN/4/hlWOSoE5A7cgHQ
+oqKcddbyCeOk0um869zL+O7GavQd3GhjwmFb9gOQVPUVGzNjkvlS/wMLGCM2287/
+Fkh7TsFgmOWIY6hxZ1xI7wsk9CV33CVu4KnTUh/u+R76E1EROoPN/E5N6MYOGN0k
+DZ4i/qZHrnVnauFM4CfZnszY7JE6nY3QNIQohg/bMuZBeFIzacDruluIJQAhVGGf
+Le7W6uKPCUbvyQbJscq4wQiOA3fbdlCeScIVuR+pligZQHyCW6CVCLPlgxYnQUE+
+vGOKFRsMXpjRfk/laSg+6v9r1WqaxleOW7XMUhvoQ0bya5DNnEPMhufSTCGZUv1y
+z11PFK+eeY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ex9UNJrLXiYKEYKD9hIIBFRuMIWuTmp9eU4QW0E9
+/kjXCJxfN8gpDlnKzV6uK77JHuI4qr/ZpMLIYdJBJcRKLB3ufP5ryKTbZ50MjnZn
+YYvjIM/28hB0MIhw8y0WC4LFt2B8uCCdw6YmC0rchVyn4ByX9UJa+lOtxecHYps+
+wH0FgncjRJF5KhmDYEIJhZ96R1fWfm6SC2jjWBxJzu0SYd9AX/6nnYV2mbH7WxB5
+F0uDlm8MTx9I2dIypfhdkcPMXnuS8t4UY/RSA2JiGMIfTcZ31POIIXl2dmH+/74z
+jjq0qYyHrzF+U7uX1LN2EJBtDQVI19wcgGRUUB2ouJjIKv/iZYOIvg2YC46hBV9G
+7W8k7yAUdW1sPDAQMSjLmaQIqK0Ou/UQJyxhuiy21BJAQWTFk+ikweoIWclYziKa
+Zlnkl4IywPmUB2TywUnNh9H9yWW+OQDWFaWEPRVpSY2SiBZpfzq5AQKy3rOVUS91
+JwiQAW6WGobtHG+84IxblfGxFSGuDOzCcN5FTkMRK/H/6evYTioKTh9XrvnaKwkf
+HHuk6WF8sNP0GjxdYgi6C9iTK4ZzLfrVb9XQ/cuBxhmtR3ahGxgX7BG7AfNk0mcB
+hUiZoD55KEYRkCLEa3OTcg8HCDiqGn9TeLqL0Q5ZqSYydxlLxhFAOc57SmznzWRD
+wuW2uo0nN6EgrKrWe8MvKXyE2/0tbKqersCXEV0SnozBlom/zCs0zZ4AKChN1fYc
+gIXCntFc
+=7wno
+-----END PGP MESSAGE-----
diff --git a/spec/fixtures/mails/encrypted-mime/thunderbird.eml b/spec/fixtures/mails/encrypted-mime/thunderbird.eml
new file mode 100644
index 0000000..091a3ae
--- /dev/null
+++ b/spec/fixtures/mails/encrypted-mime/thunderbird.eml
@@ -0,0 +1,76 @@
+Received: from [IPv6:::1] (localhost.localdomain [IPv6:::1])
+	by flutsch.local (Postfix) with ESMTP id DAFE5801DD
+	for <schleuder at example.org>; Thu, 29 Dec 2016 15:13:34 +0100 (CET)
+To: schleuder at example.org
+From: paz <paz at nadir.org>
+Subject: encrypted-mime test
+Openpgp: id=52507B0163A8D9F0094FFE03B1A36F08069E55DE
+Message-ID: <51db1a44-b9b7-1390-b8ce-a0980101842d at nadir.org>
+Date: Thu, 29 Dec 2016 15:13:34 +0100
+User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
+ Thunderbird/45.5.1
+MIME-Version: 1.0
+Content-Type: multipart/encrypted;
+ protocol="application/pgp-encrypted";
+ boundary="9JN8w93dvNGWNV5ifxvV0OtHWs5PxOc8A"
+
+This is an OpenPGP/MIME encrypted message (RFC 4880 and 3156)
+--9JN8w93dvNGWNV5ifxvV0OtHWs5PxOc8A
+Content-Type: application/pgp-encrypted
+Content-Description: PGP/MIME version identification
+
+Version: 1
+
+--9JN8w93dvNGWNV5ifxvV0OtHWs5PxOc8A
+Content-Type: application/octet-stream; name="encrypted.asc"
+Content-Description: OpenPGP encrypted message
+Content-Disposition: inline; filename="encrypted.asc"
+
+-----BEGIN PGP MESSAGE-----
+
+hQIMA691X8Gl2MArAQ//cRgrJgxEfj5+bld6ygNpf2COjffzI21YfhDUnR2WZTZ8
+EqG22c0DMaLZ6SdQWhWHxRWKYs7y8chYWgoEb18FyLGYwGhalgAIccCta3PAjShJ
+loiw/Xjj2/x4crtJn1poXwVieZbmRp6Qf2QumAgtmTbBKphXH6ANSzzIQ0UyAcrg
+vbStsM3BzIdc4Ls+z9AYK06se1TU+Nf/MKrCaWoSVv538aUByr03GGtVDmmI9x5l
+GF7Di/AJBLUKNCJ0XCV/9j/QWY+mDo2xETlPemES2urXbSIY3uqIM5zsJERWvLck
+MPLb2p7Y472ZLnbzHSG/u/bhVBej7ngma5TkWbMfFNuP+u3FxsGTQYH+jchpSysj
+a/XsPrVVH8EvOSLG6yMH+1OERQ8YfVXbe+CwWQ6SsW4+61dRd3hzfFq0/9kkBOfM
+Zj9j7SsAdWgFB6jZPNsyGuf8BWwHSr2SGDH4QQL/yL6yC1MdREe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T/+vTHyKyeK/YuDBBSnH3FaO6lhxsRA6Y
+SCO58jLsro2Pyaf/TsdwPzl/dqmbz90YU6QYa/Jm4DRa6jQDFPc=
+=jj1e
+-----END PGP MESSAGE-----
+
+--9JN8w93dvNGWNV5ifxvV0OtHWs5PxOc8A--
diff --git a/spec/fixtures/mails/plain/thunderbird.eml b/spec/fixtures/mails/plain/thunderbird.eml
new file mode 100644
index 0000000..508b430
--- /dev/null
+++ b/spec/fixtures/mails/plain/thunderbird.eml
@@ -0,0 +1,53 @@
+Return-Path: <schleuder at example.org>
+Delivered-To: n.siessegger at zeromail.org
+Received: from smtpin.nadir.org (smtpin.nadir.org [217.114.68.218])
+    (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
+    (No client certificate requested)
+    by snail.zeromail.org (Postfix) with ESMTPS id D7C8EC001D
+    for <n.siessegger at zeromail.org>; Tue, 27 Dec 2016 17:18:59 +0100 (CET)
+Received: from localhost (localhost [127.0.0.1])
+    by smtpin.nadir.org (Postfix) with ESMTP id AB2BDE60C1
+    for <n.siessegger at zeromail.org>; Tue, 27 Dec 2016 17:18:59 +0100 (CET)
+Received: from smtpin.nadir.org ([127.0.0.1])
+    by localhost (smtpin-na.nadir.org [127.0.0.1]) (amavisd-new, port 10024)
+    with ESMTP id GbNqpozJuesw for <n.siessegger at zeromail.org>;
+    Tue, 27 Dec 2016 17:18:57 +0100 (CET)
+Received: from mout.web.de (mout.web.de [212.227.15.4])
+    (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits))
+    (No client certificate requested)
+    by smtpin.nadir.org (Postfix) with ESMTPS id A91EAE604F
+    for <n.siessegger at zeromail.org>; Tue, 27 Dec 2016 17:18:57 +0100 (CET)
+Received: from nna.local ([80.187.107.60]) by smtp.web.de (mrweb004
+ [213.165.67.108]) with ESMTPSA (Nemesis) id 0McT8i-1c4NZw3xE8-00Hgam for
+ <n.siessegger at zeromail.org>; Tue, 27 Dec 2016 17:18:57 +0100
+To: n.siessegger at zeromail.org
+From: Nina Siessegger <schleuder at example.org>
+Subject: Test
+Message-ID: <8db04406-e2ab-fd06-d4c5-c19b5765c52b at web.de>
+Date: Tue, 27 Dec 2016 17:18:57 +0100
+User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:45.0)
+ Gecko/20100101 Thunderbird/45.5.1
+MIME-Version: 1.0
+Content-Type: text/plain; charset=utf-8
+Content-Transfer-Encoding: 7bit
+X-Provags-ID: V03:K0:q07lv8kyV5vZ2Bkz3y99DthdSlg2NU0SQbMMZtb6PkyKzuO3TqS
+ O2/qixJf4THt+J1OEiMuWOG71sYXBENA7fUZzy25Xy3mpDLgOJj55qE8+KOFuLfWPyb2OeI
+ 39NYZ0+mLzIuJEiq4JnfYnF7s1SN5jv3CadFuO206MV7recIxXOjpxHPDvoyfzLMyxqRb5b
+ jM6SATIl6pRdymPUNFsjQ==
+X-UI-Out-Filterresults: notjunk:1;V01:K0:9gbmm2iZtw4=:psOpZ/aY5zv6agYRXPOnce
+ fJ6S+HVb03oKnQICo4EZZxwCuxBpd1xUHzJFid+KUGgvVNXPwpi5Z0hg57WQQYwhopWhY2eCm
+ o9nJ6xMVS8CV8uX0lEXsoNM/JRt5oM1OvIIQuuuAzUDw7F1nnmGQPOMleAMAQ7GyvfirSZfx4
+ VrLOsF0vIZJOwoP5rZusgqrCteOJn5TC+Wy5UDb0w3ogzJQRsNLTN2Q6f5b7mzuT1zEVPdpU2
+ HMHvoRTVQpMYtfTjoVJlVKfh5Zf6eurPDFa980+/h5xQKf0+W+u1Z1JCe8zI45628TPPzQNN9
+ VvugURsiPDP3h3zxj/joo6O2l4Vk/30Mxr7k+PVhSLno4GNjS5oL52o+AG0ZRjD3fKWrnArXr
+ j0emey1AI1EZij+FwwWyf0JF7ubRvN2qXRovU+ZYZ3fV1x56S5ZXdiuOqImHzgYcCdKQ1Mbj3
+ HX+jleuL6Gkgv2hdHcq++zErqiSbBhJKxPfDGAIwRpb/kAf3/sEGGhdLAlzlagXbbNgScVNsa
+ PQIRuXvDim+eTk8Wb0Wh17flIzpgtz/bU8ZA61WLN8yt1v3aGevuwbMbO75dO/QOU4s4Yaaln
+ 2LUsTYwtLKuqOY+reg6J3dZYyRwMTIl8961GcGXI3xHyHlKORKPk36b0/H0kHRi337qNl5mKF
+ Z4WiQdpohcsGg0plEuZRLdxJ7knXQX3kZxO2FlTAhfPdWN1MDuQ+CiWi8MRwApOTQeR0nzRuR
+ 2RAcnGeDuEgC3L/e6jkVJTvg45eulIeiIQPtEmx7eC3xs+wnifTCXqI4Mi9SDWtQxnPmWPPrh
+ QAox8QKjkrSq/JyqvmWV7fCOJur8Wmms+oyr8g/MpOBqTMGbZumCNBa4UaGnSDTFon8Qg8djv
+ c4C7eaiiU7Z6bS9xU/qA==
+
+Test
+
diff --git a/spec/fixtures/mails/signed-inline/thunderbird.eml b/spec/fixtures/mails/signed-inline/thunderbird.eml
new file mode 100644
index 0000000..9cf5969
--- /dev/null
+++ b/spec/fixtures/mails/signed-inline/thunderbird.eml
@@ -0,0 +1,39 @@
+Received: from [IPv6:::1] (localhost.localdomain [IPv6:::1])
+	by flutsch.local (Postfix) with ESMTP id 777D3801DD
+	for <schleuder at example.org>; Thu, 29 Dec 2016 15:21:42 +0100 (CET)
+To: schleuder at example.org
+From: paz <paz at nadir.org>
+Subject: signed-inline
+Openpgp: id=52507B0163A8D9F0094FFE03B1A36F08069E55DE
+Message-ID: <dbd54295-d467-d704-5c32-89377161b9db at nadir.org>
+Date: Thu, 29 Dec 2016 15:21:42 +0100
+User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
+ Thunderbird/45.5.1
+MIME-Version: 1.0
+Content-Type: text/plain; charset=utf-8
+Content-Transfer-Encoding: 8bit
+
+-----BEGIN PGP SIGNED MESSAGE-----
+Hash: SHA512
+
+This is a test.
+
+Umlauts: öäß.
+
+♥★
+-----BEGIN PGP SIGNATURE-----
+
+iQIzBAEBCgAdFiEEUlB7AWOo2fAJT/4DsaNvCAaeVd4FAlhlG/YACgkQsaNvCAae
+Vd4g5A/+Joc1sst26EGHhYL/MrYICBljcvFHWYHo81sr6ED1ek18eWiHtHGFhWvO
+HyJ0Ccu1ktdcyay7K70gpRNrjvs2d3l5sAAfgMyDPsvBrvWHKYUpiypcVG/7FRrD
+1RVsQroh4xTo2wzWOjn47dT0EMhVZtg4jITSQn25dj8/D9viUeE3fiGFLtG5KLhU
+B1l+3A5cYrzaSRy9p6VoCPSEOCToZ34LJd9RkG/QKMD9JT/HcZN89sRVL0e4qI8e
+wQWsI6Oi7WNGiUA+p8Q5un90KNCqqumjkVxIiiFk5wSB4egba6JIBW43pKYrklRz
+wIXrNCk/RWcPJMTqIH9n+2IrDlKeYO/u+h/uh1y0SOTnImkmpfcgYsG3ggPnVask
+T2J8CCQ5Xy0HecyEFt5GO9pYG73vG9bX/YQ3cGN6yUJxmXzlQ02iS6UVx5g8Ypy2
+NuZwQKFUGUeFta2mRlkKn8VZfqXrWv3VtKoaa1Zm0gZydTDA/37W5A2xrGk9IvjZ
+CUGx4jLqXbOFJ+zOthI9JJmaPP4sc7hUmegAjV1PJP6AaIZ+6TLwn+gY1z7SaRd2
+59bA6Bnm4S7p8nV7oPwW/WaOUu3mF7y5w4Yd8DAS5BKC5UiBexrhY6mH71jXb+J9
+VZOIwSEI9QvBKQM/7wULApVGq1kPR3K6XKAMvWiez3ayqsYUflk=
+=TSUJ
+-----END PGP SIGNATURE-----
diff --git a/spec/fixtures/mails/signed-mime/thunderbird.eml b/spec/fixtures/mails/signed-mime/thunderbird.eml
new file mode 100644
index 0000000..1332e0b
--- /dev/null
+++ b/spec/fixtures/mails/signed-mime/thunderbird.eml
@@ -0,0 +1,61 @@
+Received: from [IPv6:::1] (localhost.localdomain [IPv6:::1])
+	by flutsch.local (Postfix) with ESMTP id E276680329
+	for <schleuder at example.org>; Thu, 29 Dec 2016 15:14:42 +0100 (CET)
+To: schleuder at example.org
+From: paz <paz at nadir.org>
+Subject: signed-mime test
+Openpgp: id=52507B0163A8D9F0094FFE03B1A36F08069E55DE
+Message-ID: <f1cb40c3-2576-4649-34d3-6a75c6d2ac89 at nadir.org>
+Date: Thu, 29 Dec 2016 15:14:42 +0100
+User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
+ Thunderbird/45.5.1
+MIME-Version: 1.0
+Content-Type: multipart/signed; micalg=pgp-sha512;
+ protocol="application/pgp-signature";
+ boundary="DnUG3PvpPDcqa5kwpXHvXR1RjOgf17M3b"
+
+This is an OpenPGP/MIME signed message (RFC 4880 and 3156)
+--DnUG3PvpPDcqa5kwpXHvXR1RjOgf17M3b
+Content-Type: multipart/mixed; boundary="L98FCUdRgUPMMRg5CUqPXDjjv0kGAXPf0";
+ protected-headers="v1"
+From: paz <paz at nadir.org>
+To: schleuder at example.org
+Message-ID: <f1cb40c3-2576-4649-34d3-6a75c6d2ac89 at nadir.org>
+Subject: signed-mime test
+
+--L98FCUdRgUPMMRg5CUqPXDjjv0kGAXPf0
+Content-Type: text/plain; charset=utf-8
+Content-Transfer-Encoding: quoted-printable
+
+This is a test
+
+Umlauts: =C3=B6=C3=A4=C3=9F
+
+=E2=99=A5=E2=98=85
+
+
+--L98FCUdRgUPMMRg5CUqPXDjjv0kGAXPf0--
+
+--DnUG3PvpPDcqa5kwpXHvXR1RjOgf17M3b
+Content-Type: application/pgp-signature; name="signature.asc"
+Content-Description: OpenPGP digital signature
+Content-Disposition: attachment; filename="signature.asc"
+
+-----BEGIN PGP SIGNATURE-----
+
+iQIzBAEBCgAdFiEEUlB7AWOo2fAJT/4DsaNvCAaeVd4FAlhlGlIACgkQsaNvCAae
+Vd5VQQ/7BfL7kQA30QfQMoOLqnww/jX2aCeOIAisuPE0CU1oqxn00ntSIl7vMYIl
+Gu16gfwXrftbNxLfEwlLN6xZbzPJg+JefumOZglAqP9zHONxuwhO3QkaN0+K2Gfl
+ECDVAOxVZX52APoFkkgJjkUcHmCa2GeFROhgmDtCxeGjBTQlRg6WNu+xeJmR9GUG
+MQSaaMxHHSFxTmXQonRa5C1ATw9ZXekDOHK8LEO5hq04WEus0zio0a6fi+/xgTUS
+rJb+9el+pSOa9pZ5ZFfWWqFYuG5d4GNQpNeZQZjnUKKt0PvSw8g6Sqe0UvAeyjyg
+HRjDAsCijMaMql4+w6Ko7T8vl/C2By0bBeJfpZ1YkR+wa28+v2u3G8l2Mk7azkzT
+a8QHMzyTITv3D3MunpXSrp6Blh9X2u5PmkD9BkxHduuz/J7kgvufini8oqc3WP4U
+zZ8ZfU3ruon2le4UCRE/kWtDgCEK8+ppYqF/GSJZ6j1lO+tOfuWjwhotdtdG88/x
+bRS2GXecp7Jy8aosC0c0MHqZEMRUCKfN9lQLFf3oi+7f1AhDZbTzVnI+KGduZU3h
+/gk3kwLHFUd2epIjiWOygQyfpMQCqNvaskz8md3uH9P2F1mfHi1CaUB5Nq1gLegP
+GNmgErDQLDCoBnEW3aNsEM/BzPy2JRMi9k/sPXQ0GsTZhH62MV0=
+=CSzt
+-----END PGP SIGNATURE-----
+
+--DnUG3PvpPDcqa5kwpXHvXR1RjOgf17M3b--
diff --git a/spec/fixtures/schleuder_at_example_public_key.txt b/spec/fixtures/schleuder_at_example_public_key.txt
new file mode 100644
index 0000000..211da08
--- /dev/null
+++ b/spec/fixtures/schleuder_at_example_public_key.txt
@@ -0,0 +1,49 @@
+mQINBFhGvz0BEADXbbTWo/PStyTznAo/f1UobY0EiVPNKNERvYua2Pnq8BwOQ5bS
+qvmWTb+9Fe9PRpmmqqKKeKjMX9yNjYZweqZ2Tda6C9B6shLme/bWotoXYCEjmP4t
+g9uWJmu2x+UHH+SSH752eDlTOtz9mZqNjcKlwvZtHcfu3FwvPQ7xqYt3f2Q/e8ES
+T2f02oI6uEuiBbuO0ZtLX2IMeygPc8ErBY+EAqJ9Q41SpO9rwGf3vKs7NZnE1Jjz
+6myvVGf+NTdzpuk0tWxNSgESBeL86nhoKxwKSoCT12vcprMhZ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wSW0gi7YITghHwVJ1AoK0yw3wD5N+Eq/xMUYw7tyGyipoQML5keauw4u
+sU/TMwFcGYQLrQ5c4CSDmfORHC34h0nNnG3olNWAkAloXTSOys5P6BZAr1B5WnFX
+2wdxj0HkodBrE6OG8ZtDm7EE50iKKUO5sJMbfamesPVfWQFM4Rx08OdqnV/mmcy1
+IcJFf4xsrC5u9fZsG3ovtTDWKyGVrST/g3JeVmvVWfMJfdwb838rp9fhAgqfO4lF
+L2kCGlZB0iW16DpAs22HOsJgUTtkf7TTvr/DXdGoamuTfckrcJESC7HBi8QDZL8S
+9iNjgjr8zwmO35evJ/0JgoVhOjknwFzUAR9RGtYCT+IdZqmVcxIkeULjMzJkIwt5
+J3W4uxiy6E9uAsZC9srg9sUZvYd1vavRZ/r55jFA8PdyzpITNPmZ3XrceGoV8T4N
+Qs7Zp5WOthe7oLoPP+UU17lDXHuH9rIUhzKl5QL2Z59H214VDRi5VcQLkn6OpzqW
+6T/ikr8tewq5VLEY1G35G9XH1VHTS5VNpuoi/imJKl187AYCzA+EZQlnLvmk6WE6
+/J2/tBYro55u
+=lep5
+-----END PGP PUBLIC KEY BLOCK-----
diff --git a/spec/schleuder.yml b/spec/schleuder.yml
index 6ddf437..6fc619b 100644
--- a/spec/schleuder.yml
+++ b/spec/schleuder.yml
@@ -2,3 +2,7 @@ database:
   test:
     adapter: sqlite3
     database: db/test.sqlite3
+lists_dir: /tmp/schleuder-test/
+listlogs_dir: /tmp/schleuder-test/
+smtp_settings:
+  port: 2523
diff --git a/spec/schleuder/integration/send_encrypted_spec.rb b/spec/schleuder/integration/send_encrypted_spec.rb
new file mode 100644
index 0000000..84e8ed0
--- /dev/null
+++ b/spec/schleuder/integration/send_encrypted_spec.rb
@@ -0,0 +1,19 @@
+require "spec_helper"
+
+describe "user sends an encrypted message" do
+  it "from thunderbird" do
+    start_smtp_daemon
+    list = create(:list)
+    list.subscribe("admin at example.org", nil, true)
+    message_path = 'spec/fixtures/mails/encrypted-mime/thunderbird.eml'
+
+    error = run_schleuder(:work, list.email, message_path)
+    mails = Dir.glob("#{smtp_daemon_outputdir}/mail-*")
+
+    expect(error).to be_empty
+    expect(mails.size).to eq 1
+
+    stop_smtp_daemon
+  end
+end
+
diff --git a/spec/schleuder/integration/send_plain_spec.rb b/spec/schleuder/integration/send_plain_spec.rb
new file mode 100644
index 0000000..c08011a
--- /dev/null
+++ b/spec/schleuder/integration/send_plain_spec.rb
@@ -0,0 +1,19 @@
+require "spec_helper"
+
+describe "user sends a plain text message" do
+  it "from thunderbird" do
+    start_smtp_daemon
+    list = create(:list)
+    list.subscribe("admin at example.org", nil, true)
+    message_path = 'spec/fixtures/mails/plain/thunderbird.eml'
+
+    error = run_schleuder(:work, list.email, message_path)
+    mails = Dir.glob("#{smtp_daemon_outputdir}/mail-*")
+
+    expect(error).to be_empty
+    expect(mails.size).to eq 1
+
+    stop_smtp_daemon
+  end
+end
+
diff --git a/spec/schleuder/runner_spec.rb b/spec/schleuder/runner_spec.rb
index 09c3adf..45db7d9 100644
--- a/spec/schleuder/runner_spec.rb
+++ b/spec/schleuder/runner_spec.rb
@@ -1,8 +1,136 @@
-require 'spec_helper'
+require "spec_helper"
 
 describe Schleuder::Runner do
+  describe "#run" do
+    context "with a plain text message" do
+      it "delivers the incoming message" do
+        list = create(:list, send_encrypted_only: false)
+        list.subscribe("admin at example.org", nil, true)
+        mail = File.read("spec/fixtures/mails/plain/thunderbird.eml")
 
-  describe '#run' do
-    it 'should parses mail'
+        error = Schleuder::Runner.new().run(mail, list.email)
+
+        expect(Mail::TestMailer.deliveries.length).to eq 1
+        expect(error).to be_blank
+
+        teardown_list_and_mailer(list)
+      end
+
+      it "has the correct headerlines" do
+        list = create(:list, send_encrypted_only: false)
+        list.subscribe("admin at example.org", nil, true)
+        mail = File.read("spec/fixtures/mails/plain/thunderbird.eml")
+
+        Schleuder::Runner.new().run(mail, list.email)
+        message = Mail::TestMailer.deliveries.first
+
+        expect(message.to).to eq ["admin at example.org"]
+        expect(message.header.to_s.scan("admin at example.org").size).to eq 1
+        expect(message.from).to eq [list.email]
+
+        teardown_list_and_mailer(list)
+      end
+
+      it "doesn't have unwanted headerlines from the original message" do
+        list = create(:list, send_encrypted_only: false)
+        list.subscribe("admin at example.org", nil, true)
+        mail = File.read("spec/fixtures/mails/plain/thunderbird.eml")
+
+        Schleuder::Runner.new().run(mail, list.email)
+        message = Mail::TestMailer.deliveries.first
+
+        expect(message.to).to eq ["admin at example.org"]
+        expect(message.header.to_s.scan("zeromail").size).to eq 0
+        expect(message.header.to_s.scan("nna.local").size).to eq 0
+        expect(message.header.to_s.scan("80.187.107.60").size).to eq 0
+        expect(message.header.to_s.scan("User-Agent:").size).to eq 0
+
+        teardown_list_and_mailer(list)
+      end
+
+      it "doesn't leak the Message-Id as configured" do
+        list = create(:list, send_encrypted_only: false, keep_msgid: false)
+        list.subscribe("admin at example.org", nil, true)
+        mail = File.read("spec/fixtures/mails/plain/thunderbird.eml")
+
+        Schleuder::Runner.new().run(mail, list.email)
+        message = Mail::TestMailer.deliveries.first
+
+        expect(message.header.to_s.scan("8db04406-e2ab-fd06-d4c5-c19b5765c52b at web.de").size).to eq 0
+
+        teardown_list_and_mailer(list)
+      end
+
+      it "does keep the Message-Id as configured" do
+        list = create(:list, send_encrypted_only: false, keep_msgid: true)
+        list.subscribe("admin at example.org", nil, true)
+        mail = File.read("spec/fixtures/mails/plain/thunderbird.eml")
+
+        Schleuder::Runner.new().run(mail, list.email)
+        message = Mail::TestMailer.deliveries.first
+
+        expect(message.header.to_s.scan("8db04406-e2ab-fd06-d4c5-c19b5765c52b at web.de").size).to eq 1
+
+        teardown_list_and_mailer(list)
+      end
+
+      it "contains the list headers if include_list_headers is set to true" do
+        list = create(
+          :list,
+          email: "superlist at example.org",
+          send_encrypted_only: false,
+          include_list_headers: true,
+        )
+        list.subscribe("admin at example.org", nil, true)
+        mail = File.read("spec/fixtures/mails/plain/thunderbird.eml")
+
+        Schleuder::Runner.new().run(mail, list.email)
+        message = Mail::TestMailer.deliveries.first
+
+        expect(message.header["List-Id"].to_s).to eq "<superlist.example.org>"
+        expect(message.header["List-Owner"].to_s).to eq "<mailto:superlist-owner at example.org> (Use list's public key)"
+        expect(message.header["List-Help"].to_s).to eq "<https://schleuder.nadir.org/>"
+
+        teardown_list_and_mailer(list)
+      end
+
+      it "contains the open pgp header if include_openpgp_header is set to true" do
+        list = create(
+          :list,
+          send_encrypted_only: false,
+          include_openpgp_header: true,
+        )
+        list.subscribe("admin at example.org", nil, true)
+        mail = File.read("spec/fixtures/mails/plain/thunderbird.eml")
+
+        Schleuder::Runner.new().run(mail, list.email)
+        message = Mail::TestMailer.deliveries.first
+
+        expect(message.header["Openpgp"].to_s).to include list.fingerprint
+
+        teardown_list_and_mailer(list)
+      end
+
+      it "does not deliver content if send_encrypted_only is set to true" do
+        list = create(:list, send_encrypted_only: true)
+        list.subscribe("admin at example.org", nil, true)
+        mail = File.read("spec/fixtures/mails/plain/thunderbird.eml")
+
+        Schleuder::Runner.new().run(mail, list.email)
+        message = Mail::TestMailer.deliveries.first
+
+        expect(message.body).to eq ""
+        expect(message.parts.first.body.to_s).to include "You missed an email from "\
+          "#{list.email} because your subscription isn't associated with a "\
+          "(usable) OpenPGP key. Please fix this."
+
+        teardown_list_and_mailer(list)
+      end
+    end
+
+    def teardown_list_and_mailer(list)
+      FileUtils.rm_rf(list.listdir)
+      Mail::TestMailer.deliveries.clear
+    end
   end
 end
diff --git a/spec/schleuder/list_spec.rb b/spec/schleuder/unit/list_spec.rb
similarity index 73%
rename from spec/schleuder/list_spec.rb
rename to spec/schleuder/unit/list_spec.rb
index 0610904..7fe1c74 100644
--- a/spec/schleuder/list_spec.rb
+++ b/spec/schleuder/unit/list_spec.rb
@@ -46,7 +46,8 @@ describe Schleuder::List do
   it { is_expected.to respond_to :logfiles_to_keep }
 
   it "is invalid when email is nil" do
-    list = build(:list, email: nil)
+    # Don't use factory here because we'd run into List.listdir expecting email to not be nil.
+    list = Schleuder::List.new(email: nil)
 
     expect(list).not_to be_valid
     expect(list.errors.messages[:email]).to include("can't be blank")
@@ -238,16 +239,15 @@ describe Schleuder::List do
 
   describe "#admins" do
     it "returns subscriptions of admin users" do
-      list = Schleuder::List.create(
-        email: "foo at bar.org",
-        fingerprint: "aaaadddd0000999",
-      )
-      admin_subscription = Schleuder::Subscription.create(
+      list = create(:list)
+      admin_subscription = create(
+        :subscription,
         email: "admin at foo.org",
         admin: true,
         list_id: list.id,
       )
-      _user_subscription = Schleuder::Subscription.create(
+      _user_subscription = create(
+        :subscription,
         email: "user at foo.org",
         admin: false,
         list_id: list.id,
@@ -259,9 +259,9 @@ describe Schleuder::List do
 
   describe "#key" do
     it "returns the key with the fingerprint of the list" do
-      list = Schleuder::List.create(
-        email: "foo at bar.org",
-        fingerprint: "59C7 1FB3 8AEE 22E0 91C7  8259 D063 5044 0F75 9BD3",
+      list = create(
+        :list,
+        fingerprint: "59C7 1FB3 8AEE 22E0 91C7  8259 D063 5044 0F75 9BD3"
       )
 
       expect(list.key.fingerprint()).to eq "59C71FB38AEE22E091C78259D06350440F759BD3"
@@ -312,7 +312,6 @@ describe Schleuder::List do
 
   describe "#import_key" do
     it "imports a given key" do
-      set_test_gnupg_home
       list = create(:list)
       key = File.read("spec/fixtures/example_key.txt")
 
@@ -324,7 +323,6 @@ describe Schleuder::List do
 
   describe "#delete_key" do
     it "deletes the key with the given fingerprint" do
-      set_test_gnupg_home
       list = create(:list)
       key = File.read("spec/fixtures/example_key.txt")
       list.import_key(key)
@@ -335,10 +333,121 @@ describe Schleuder::List do
     end
 
     it "returns false if no key with the fingerprint was found" do
-      set_test_gnupg_home
       list = create(:list)
 
       expect(list.delete_key("A4C60C8833789C7CAA44496FD3FFA6611AB10CEC")).to eq false
     end
   end
+
+  describe "#export_key" do
+    it "exports the key with the fingerprint of the list if no argument is given" do
+      list = create(:list, email: "schleuder at example.org")
+      expected_public_key = File.read("spec/fixtures/schleuder_at_example_public_key.txt")
+
+      expect(list.export_key()).to include expected_public_key
+    end
+  end
+
+  it "exports the key with the given fingerprint" do
+    list = create(:list, email: "schleuder at example.org")
+    expected_public_key = File.read("spec/fixtures/schleuder_at_example_public_key.txt")
+
+    expect(
+      list.export_key("59C71FB38AEE22E091C78259D06350440F759BD3")
+    ).to include expected_public_key
+  end
+
+  describe "#check_keys" do
+    it "adds a mesage if a key expires in two weeks or less" do
+      list = create(:list)
+      key = double("key")
+      allow_any_instance_of(GPGME::Key).to receive(:subkeys).and_return(key)
+      allow(key).to receive(:first).and_return(key)
+      allow(key).to receive(:expires).and_return(Time.now + 7.days)
+      allow(key).to receive(:fingerprint).and_return("59C71FB38AEE22E091C78259D06350440F759BD3")
+
+      expect(list.check_keys).to eq "Expires in 6 days:"\
+        "\n0x59C71FB38AEE22E091C78259D06350440F759BD3 schleuder at example.org"
+    end
+
+    it "adds a message if a key is revoked" do
+      list = create(:list)
+      allow_any_instance_of(GPGME::Key).to receive(:trust).and_return(:revoked)
+
+      expect(list.check_keys).to eq "Is revoked:"\
+        "\n0x59C71FB38AEE22E091C78259D06350440F759BD3 schleuder at example.org"
+    end
+
+    it "adds a message if a key is disabled" do
+      list = create(:list)
+      allow_any_instance_of(GPGME::Key).to receive(:trust).and_return(:disabled)
+
+      expect(list.check_keys).to eq "Is disabled:"\
+        "\n0x59C71FB38AEE22E091C78259D06350440F759BD3 schleuder at example.org"
+    end
+
+    it "adds a message if a key is invalid" do
+      list = create(:list)
+      allow_any_instance_of(GPGME::Key).to receive(:trust).and_return(:invalid)
+
+      expect(list.check_keys).to eq "Is invalid:"\
+        "\n0x59C71FB38AEE22E091C78259D06350440F759BD3 schleuder at example.org"
+    end
+  end
+
+  describe ".by_recipient" do
+    it "returns the list for a given address" do
+      list = create(:list, email: "list at example.org")
+
+      expect(Schleuder::List.by_recipient("list-owner at example.org")).to eq list
+    end
+  end
+
+  describe "#sendkey_address" do
+    it "adds the sendkey keyword to the email address" do
+      list = create(:list, email: "list at example.org")
+
+      expect(list.sendkey_address).to eq "list-sendkey at example.org"
+    end
+  end
+
+  describe "#request_address" do
+    it "adds the request keyword to the email address" do
+      list = create(:list, email: "list at example.org")
+
+      expect(list.request_address).to eq "list-request at example.org"
+    end
+  end
+
+  describe "#owner_address" do
+    it "adds the owner keyword to the email address" do
+      list = create(:list, email: "list at example.org")
+
+      expect(list.owner_address).to eq "list-owner at example.org"
+    end
+  end
+
+  describe "#bounce_address" do
+    it "adds the bounce keyword to the email address" do
+      list = create(:list, email: "list at example.org")
+
+      expect(list.bounce_address).to eq "list-bounce at example.org"
+    end
+  end
+
+  describe "#gpg" do
+    it "returns an instance of GPGME::Ctx" do
+      list = create(:list)
+
+      expect(list.gpg).to be_an_instance_of GPGME::Ctx
+    end
+
+    it "sets the GNUPGHOME environment variable to the listdir" do
+      list = create(:list)
+
+      list.gpg
+
+      expect(ENV["GNUPGHOME"]).to eq list.listdir
+    end
+  end
 end
diff --git a/spec/schleuder/subscription_spec.rb b/spec/schleuder/unit/subscription_spec.rb
similarity index 100%
rename from spec/schleuder/subscription_spec.rb
rename to spec/schleuder/unit/subscription_spec.rb
diff --git a/spec/smtp-daemon.rb b/spec/smtp-daemon.rb
new file mode 100755
index 0000000..54f1a82
--- /dev/null
+++ b/spec/smtp-daemon.rb
@@ -0,0 +1,72 @@
+#!/usr/bin/env ruby
+require 'socket'
+require 'open3'
+
+trap ("INT") { exit 0 }
+
+def usage
+  puts "Usage: #{File.basename(__FILE__)} portnum output-directory"
+  exit 1
+end
+
+# get args
+if ARGV.first.to_s.match('(-h|--help|help)') || ARGV.empty?
+  usage
+end
+
+port = ARGV.first.to_i
+if port == 0
+  usage
+end
+
+outputdir = ARGV[1].to_s
+if outputdir.empty?
+  usage
+elsif ! File.directory?(outputdir)
+  puts "Not a directory: #{outputdir}"
+  exit 1
+end
+
+begin
+  # run the server
+  server = TCPServer.new("127.0.0.1", port)
+
+  # receive input
+  while (connection = server.accept)
+    input = ''
+    recipient = ''
+    connection.puts "220 localhost SMTP"
+    begin
+      while line = connection.gets
+        line.chomp!
+        case line[0..3].downcase
+        when 'ehlo', 'helo'
+          connection.puts "250 localhost"
+        when 'mail', 'rset'
+          connection.puts "250 ok"
+        when 'rcpt'
+          recipient = line.split(':').last.gsub(/[<>\s]*/, '')
+          connection.puts "250 ok"
+        when 'data'
+          connection.puts "354 go ahead"
+        when 'quit'
+          connection.puts "221 localhost"
+        when '.'
+          filename = File.join(outputdir, "mail-#{Time.now.to_f}")
+          # puts "New message to #{recipient} written to #{filename}"
+          IO.write(filename, input)
+          connection.puts "250 ok"
+        else
+          input << line + "\n"
+        end
+      end
+    rescue IOError
+    end
+    connection.close
+  end
+
+
+rescue => exc
+  $stderr.puts exc
+  exit 1
+end
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index 4e76173..067938f 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -8,13 +8,6 @@ require 'factory_girl'
 
 RSpec.configure do |config|
   config.expect_with :rspec do |expectations|
-    # This option will default to `true` in RSpec 4. It makes the `description`
-    # and `failure_message` of custom matchers include text for helper methods
-    # defined using `chain`, e.g.:
-    # be_bigger_than(2).and_smaller_than(4).description
-    #   # => "be bigger than 2 and smaller than 4"
-    # ...rather than:
-    #   # => "be bigger than 2"
     expectations.include_chain_clauses_in_custom_matcher_descriptions = true
   end
 
@@ -26,7 +19,7 @@ RSpec.configure do |config|
   end
 
   config.before(:suite) do
-    DatabaseCleaner.strategy = :transaction
+    DatabaseCleaner.strategy = :deletion
     DatabaseCleaner.clean_with(:truncation)
   end
 
@@ -40,34 +33,50 @@ RSpec.configure do |config|
     FileUtils.rm_rf(Dir["spec/gnupg/pubring.gpg~"])
   end
 
-  config.before(:suite) do
-    set_test_gnupg_home
-  end
-
   config.after(:suite) do
     cleanup_gnupg_home
+    stop_smtp_daemon
   end
 
   # rspec-mocks config goes here. You can use an alternate test double
   # library (such as bogus or mocha) by changing the `mock_with` option here.
   config.mock_with :rspec do |mocks|
-    # Prevents you from mocking or stubbing a method that does not exist on
-    # a real object. This is generally recommended, and will default to
-    # `true` in RSpec 4.
     mocks.verify_partial_doubles = true
   end
 
-  def set_test_gnupg_home
-    gpghome_upstream = File.join File.dirname(__dir__), "spec", "gnupg"
-    gpghome_tmp = "/tmp/schleuder-#{Time.now.to_i}-#{rand(100)}"
-    Dir.mkdir(gpghome_tmp)
-    ENV["GNUPGHOME"] = gpghome_tmp
-    FileUtils.cp_r Dir["#{gpghome_upstream}/{private*,*.gpg,.*migrated}"], gpghome_tmp
-  end
-
   def cleanup_gnupg_home
-    FileUtils.rm_rf(ENV["GNUPGHOME"])
     ENV["GNUPGHOME"] = nil
-    puts `gpgconf --kill gpg-agent 2>&1`
+    FileUtils.rm_rf Schleuder::Conf.lists_dir
+  end
+
+  def smtp_daemon_outputdir
+    File.join(Conf.lists_dir, 'smtp-daemon-output')
+  end
+
+  def start_smtp_daemon
+    if ! File.directory?(smtp_daemon_outputdir)
+      FileUtils.mkdir_p(smtp_daemon_outputdir)
+    end
+    daemon = File.join(ENV['SCHLEUDER_ROOT'], 'spec', 'smtp-daemon.rb')
+    pid = Process.spawn(daemon, '2523', smtp_daemon_outputdir)
+    pidfile = File.join(smtp_daemon_outputdir, 'pid')
+    IO.write(pidfile, pid)
+  end
+
+  def stop_smtp_daemon
+    pidfile = File.join(smtp_daemon_outputdir, 'pid')
+    if File.exist?(pidfile)
+      pid = File.read(pidfile).to_i
+      Process.kill(15, pid)
+      FileUtils.rm_rf smtp_daemon_outputdir
+    end
+  end
+
+  def run_schleuder(command, email, message_path)
+    `SCHLEUDER_ENV=test SCHLEUDER_CONFIG=spec/schleuder.yml bin/schleuder #{command} #{email} < #{message_path} 2>&1`
+  end
+
+  Mail.defaults do
+    delivery_method :test
   end
 end

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-ruby-extras/schleuder.git



More information about the Pkg-ruby-extras-commits mailing list