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

Handle x-subscribe without argument.

parent 216900c5
module Schleuder
module RequestPlugins
def self.subscribe(arguments, list, mail)
if arguments.blank?
return I18n.t(
"plugins.subscription_management.subscribe_requires_arguments"
)
end
email = arguments.shift
if arguments.present?
......
......@@ -134,6 +134,22 @@ de:
oder (als admin):
X-SET-FINGERPRINT: subscription2@hostname 0xB3D190D5235C74E1907EACFE898F2C91E2E6E1F3
subscribe_requires_arguments: |
Fehler: Du hast zu dem Schlüsselwort 'SUBSCRIBE' keinen Wert angegeben.
Mindestens ein Wert ist nötig, drei weitere sind optional. Bspw.:
X-SUBSCRIBE: new-subscription@hostname
Oder, um den Schlüssel für das neue Abo zuzuweisen:
X-SUBSCRIBE: new-subscription@hostname 0xB3D190D5235C74E1907EACFE898F2C91E2E6E1F3
Oder, um den Schlüssel zuzuweisen, und das Abo zum admin zu machen:
X-SUBSCRIBE: new-subscription@hostname 0xB3D190D5235C74E1907EACFE898F2C91E2E6E1F3 true
Oder, um den Schlüssel zuzuweisen, das Abo zum admin zu machen, und die Zustellung von Listen-Emails für dieses Abo abzuschalten:
X-SUBSCRIBE: new-subscription@hostname 0xB3D190D5235C74E1907EACFE898F2C91E2E6E1F3 true false
Wenn du die optionalen Werte weglässt hat das Abo keinen Schlüssel zugewiesen, ist nicht admin, und hat die Zustellung von Listen-Email aktiviert.
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.)
......
......@@ -138,6 +138,22 @@ en:
or (as an admin):
X-SET-FINGERPRINT: subscription2@hostname 0xB3D190D5235C74E1907EACFE898F2C91E2E6E1F3
subscribe_requires_arguments: |
Error: You did not send any arguments for the keyword 'SUBSCRIBE'.
At least one argument is required, three more are optional. E.g.:
X-SUBSCRIBE: new-subscription@hostname
Or, defining the key to use for the new subscription:
X-SUBSCRIBE: new-subscription@hostname 0xB3D190D5235C74E1907EACFE898F2C91E2E6E1F3
Or, defining the key to use, and setting this subscription to be an admin:
X-SUBSCRIBE: new-subscription@hostname 0xB3D190D5235C74E1907EACFE898F2C91E2E6E1F3 true
Or, defining the key to use, setting this subscription as admin, and disabling the delivery of list-emails to this subscription:
X-SUBSCRIBE: new-subscription@hostname 0xB3D190D5235C74E1907EACFE898F2C91E2E6E1F3 true false
If you omit the optional arguments, the subscription has no key assigned, is not an admin, and has the delivery of list-emails enabled.
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.)
......
......@@ -298,6 +298,44 @@ describe "user sends keyword" do
teardown_list_and_mailer(list)
end
it "x-subscribe without arguments" 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-SUBSCRIBE:"
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
subscription = list.subscriptions.where(email: 'test@example.org').first
puts message
expect(message.to).to eql(['schleuder@example.org'])
expect(message.to_s).not_to include("translation missing")
expect(message.first_plaintext_part.body.to_s).to eql(I18n.t("plugins.subscription_management.subscribe_requires_arguments"))
expect(subscription).to be_blank
teardown_list_and_mailer(list)
end
it "x-unsubscribe without argument" 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