Verified Commit ecb9c25b authored by paz's avatar paz
Browse files

Handle x-fetch-key without argument

parent 30f77e1c
......@@ -90,6 +90,12 @@ module Schleuder
end
def self.fetch_key(arguments, list, mail)
if arguments.blank?
return I18n.t(
"plugins.key_management.fetch_key_requires_arguments"
)
end
arguments.map do |argument|
list.fetch_keys(argument)
end
......
......@@ -108,6 +108,18 @@ de:
X-DELETE-KEY: 0xB3D190D5235C74E1907EACFE898F2C91E2E6E1F3 a-subscription@hostname
Die Schlüssel werden nur gelöscht, wenn sie der einzige Treffer für den jeweiligen Wert sind.
fetch_key_requires_arguments: |
Fehler: Du hast zu dem Schlüsselwort 'FETCH-KEY' keinen Wert angegeben.
Ein Wert ist nötig, weitere sind optional. Jeder Wert kann eine URL sein, die via HTTP geladen wird, oder ein Text, mit dem auf den OpenPGP-Schlüsselserver gesucht wird.
Bspw., um einen Schlüssel per fingerprint vom Schlüsselserver zu holen:
X-FETCH-KEY: 0xB3D190D5235C74E1907EACFE898F2C91E2E6E1F3
Oder, um zwei Schlüssel per Email-Adresse vom Schlüsselserver zu holen:
X-FETCH-KEY: a-subscription@hostname anotherone@example.org
Oder, um einen Schlüssel per HTTP von einem Server zu laden:
X-FETCH-KEY: https://example.org/keys/mykey.asc
resend:
not_resent_no_keys: Resending an <%{email}> fehlgeschlagen (%{num_keys} Schlüssel gefunden und unverschlüsseltes Senden verboten).
encrypted_to: Verschlüsselt an
......
......@@ -112,6 +112,18 @@ en:
X-DELETE-KEY: 0xB3D190D5235C74E1907EACFE898F2C91E2E6E1F3 a-subscription@hostname
The matching keys will be deleted only if the argument matches them distinctly.
fetch_key_requires_arguments: |
Error: You did not send any arguments for the keyword 'FETCH-KEY'.
One is required, more are optional. Each argument can be an URL to fetch via HTTP, or a string to look up at the OpenPGP-keyservers.
E.g., to fetch a key by fingerprint from the keyserver:
X-FETCH-KEY: 0xB3D190D5235C74E1907EACFE898F2C91E2E6E1F3
Or, to fetch two keys by email-address from the keyserver:
X-FETCH-KEY: a-subscription@hostname anotherone@example.org
Or, to fetch a key keys by URL:
X-FETCH-KEY: https://example.org/keys/mykey.asc
resend:
not_resent_no_keys: Resending to <%{email}> failed (%{num_keys} keys found and unencrypted sending disallowed).
encrypted_to: Encrypted to
......
......@@ -1314,6 +1314,43 @@ describe "user sends keyword" do
teardown_list_and_mailer(list)
end
it "x-fetch-key without arguments" do
list = create(:list)
list.subscribe("schleuder@example.org", '59C71FB38AEE22E091C78259D06350440F759BD3', true)
list_keys_num = list.keys.size
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-fetch-KEY: "
mail.deliver
encrypted_mail = Mail::TestMailer.deliveries.first
Mail::TestMailer.deliveries.clear
with_sks_mock do
begin
Schleuder::Runner.new().run(encrypted_mail.to_s, list.request_address)
rescue SystemExit
end
end
raw = Mail::TestMailer.deliveries.first
message = Mail.create_message_to_list(raw.to_s, list.request_address, list).setup
expect(list.keys.size).to eql(list_keys_num)
expect(message.to_s).not_to include("translation missing")
expect(message.first_plaintext_part.body.to_s).to eql(I18n.t("plugins.key_management.fetch_key_requires_arguments"))
teardown_list_and_mailer(list)
end
it "x-resend" do
list = create(:list, public_footer: "-- \nblablabla")
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