Commit ebda12d0 authored by georg's avatar georg
Browse files

Merge branch 'paz/fix-set-fingerprint-without-argument' into 'master'

Fix handling x-set-fingerprint without arguments.

Closes #356

See merge request schleuder/schleuder!195
parents 1b04a081 216900c5
......@@ -5,6 +5,11 @@ This project adheres to [Semantic Versioning](http://semver.org/).
## unreleased
### Fixed
* Handle X-SET-FINGERPRINT without an argument and reply with a helpful error-message.
### Changed
* The output of the keywords 'X-ADD-KEY' and 'X-DELETE-KEY' now also show the "oneline"-format to represent keys (which includes fingerprint, primary email-address, date of generation and possible expiry). (#295)
......
......@@ -98,6 +98,12 @@ module Schleuder
end
def self.set_fingerprint(arguments, list, mail)
if arguments.blank?
return I18n.t(
"plugins.subscription_management.set_fingerprint_requires_arguments"
)
end
if arguments.first.match(/@/)
if arguments.first == mail.signer.email || list.from_admin?(mail)
email = arguments.shift
......
......@@ -126,6 +126,14 @@ de:
setting_fingerprint_failed: |
Fingerabdruck für %{email} konnte nicht auf %{fingerprint} gesetzt werden:
%{errors}.
set_fingerprint_requires_arguments: |
Du hast zu dem Schlüsselwort 'SET-FINGERPRINT' keinen Wert angegeben.
Benötigt werden ein oder zwei Werte, bspw.:
X-SET-FINGERPRINT: 0xB3D190D5235C74E1907EACFE898F2C91E2E6E1F3
oder (als admin):
X-SET-FINGERPRINT: subscription2@hostname 0xB3D190D5235C74E1907EACFE898F2C91E2E6E1F3
signatures_attached: Die Signaturen hängen an.
list_management:
no_logfile: Keine Log-Datei für %{listname} gefunden. (Das kann an einem hohem Log-Level und der Abwesenheit von Fehlern liegen.)
......
......@@ -130,6 +130,14 @@ en:
setting_fingerprint_failed: |
Setting fingerprint for %{email} to %{fingerprint} failed:
%{errors}.
set_fingerprint_requires_arguments: |
Error: You did not send any arguments for the keyword 'SET-FINGERPRINT'.
One or two are required, e.g.:
X-SET-FINGERPRINT: 0xB3D190D5235C74E1907EACFE898F2C91E2E6E1F3
or (as an admin):
X-SET-FINGERPRINT: subscription2@hostname 0xB3D190D5235C74E1907EACFE898F2C91E2E6E1F3
signatures_attached: Find the signatures attached.
list_management:
no_logfile: No logfile could be found for %{listname}. (This might be caused by a high log-level and the absence of errors.)
......
......@@ -669,6 +669,39 @@ describe "user sends keyword" do
teardown_list_and_mailer(list)
end
it "x-set-fingerprint without argument" do
list = create(:list)
list.subscribe("schleuder@example.org", '59C71FB38AEE22E091C78259D06350440F759BD3', true)
ENV['GNUPGHOME'] = list.listdir
mail = Mail.new
mail.to = list.request_address
mail.from = list.admins.first.email
gpg_opts = {
encrypt: true,
keys: {list.request_address => list.fingerprint},
sign: true,
sign_as: list.admins.first.fingerprint
}
mail.gpg(gpg_opts)
mail.body = "x-list-name: #{list.email}\nX-set-fingerprint: "
mail.deliver
encrypted_mail = Mail::TestMailer.deliveries.first
Mail::TestMailer.deliveries.clear
begin
Schleuder::Runner.new().run(encrypted_mail.to_s, list.request_address)
rescue SystemExit
end
raw = Mail::TestMailer.deliveries.first
message = Mail.create_message_to_list(raw.to_s, list.request_address, list).setup
expect(message.to).to eql(['schleuder@example.org'])
expect(message.first_plaintext_part.body.to_s).to eql(I18n.t("plugins.subscription_management.set_fingerprint_requires_arguments"))
teardown_list_and_mailer(list)
end
it "x-list-subscriptions without arguments" do
list = create(:list)
list.subscribe("schleuder@example.org", '59C71FB38AEE22E091C78259D06350440F759BD3', true)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment