Commit 514ca4d1 authored by Michał "rysiek" Woźniak's avatar Michał "rysiek" Woźniak 🔒

added a test for deliver_selfsent: false but mail not signed (suggested by @georg in !302)

parent 50e96975
Pipeline #33386 failed with stages
in 3 minutes and 17 seconds
......@@ -759,7 +759,8 @@ describe Schleuder::List do
it "sends the message to all subscribers including the sender, if deliver_selfsent is true and the mail is correctly signed" do
list = create(:list, send_encrypted_only: false, deliver_selfsent: true)
sub, msgs = list.subscribe("admin@example.org", nil, true, true)
key_material = File.read("spec/fixtures/default_list_key.txt")
sub, msgs = list.subscribe("admin@example.org", nil, true, true, key_material)
key_material = File.read("spec/fixtures/example_key.txt")
sub, msgs = list.subscribe("user1@example.org", nil, false, true, key_material)
mail = Mail.new
......@@ -795,7 +796,8 @@ describe Schleuder::List do
it "sends the message to all subscribers but not the sender, if deliver_selfsent is false and the mail is correctly signed" do
list = create(:list, send_encrypted_only: false, deliver_selfsent: false)
sub, msgs = list.subscribe("admin@example.org", nil, true, true)
key_material = File.read("spec/fixtures/default_list_key.txt")
sub, msgs = list.subscribe("admin@example.org", nil, true, true, key_material)
key_material = File.read("spec/fixtures/example_key.txt")
sub, msgs = list.subscribe("user1@example.org", nil, false, true, key_material)
mail = Mail.new
......@@ -807,7 +809,6 @@ describe Schleuder::List do
sign: true,
sign_as: '59C71FB38AEE22E091C78259D06350440F759BD3'
}
mail.gpg(gpg_opts)
mail.deliver
......@@ -827,4 +828,31 @@ describe Schleuder::List do
teardown_list_and_mailer(list)
end
end
it "sends the message to all subscribers including the sender, if deliver_selfsent is false but the mail is not correctly signed" do
list = create(:list, send_encrypted_only: false, deliver_selfsent: false)
key_material = File.read("spec/fixtures/default_list_key.txt")
sub, msgs = list.subscribe("admin@example.org", nil, true, true, key_material)
key_material = File.read("spec/fixtures/example_key.txt")
sub, msgs = list.subscribe("user1@example.org", nil, false, true, key_material)
mail = Mail.new
mail.to = list.email
mail.from = 'admin@example.org'
mail.subject = 'Something'
mail.body = "Some content"
mail.gpg()
Schleuder::Runner.new().run(mail, list.email)
messages = Mail::TestMailer.deliveries
recipients = messages.map { |m| m.to.first }.sort
expect(list.deliver_selfsent).to be(false)
expect(messages.size).to be(2)
expect(recipients).to eql(['user1@example.org', 'admin@example.org'])
expect(messages[0].parts.last.body.to_s).to include("-----BEGIN PGP MESSAGE-----")
expect(messages[0].subject).to eql("Something")
teardown_list_and_mailer(list)
end
end
end
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