A platform for community discussion. Free, open, simple.
Add specs to check email domain whitelist/blacklist for To and Cc
Gerhard Schlager9f7ae908d818
diff --git a/spec/components/email/receiver_spec.rb b/spec/components/email/receiver_spec.rbindex 1ae5e656b36..3c5017aec38 100644--- a/spec/components/email/receiver_spec.rb+++ b/spec/components/email/receiver_spec.rb@@ -674,7 +674,7 @@ describe Email::Receiver doendend- context "no staged users on error" do+ context "staged users" dobefore doSiteSetting.enable_staged_users = trueend@@ -711,7 +711,7 @@ describe Email::Receiver doinclude_examples "no staged users", :unsubscribe_new_user, Email::Receiver::UnsubscribeNotAllowedend- context "when email address is not on whitelist" do+ context "when From email address is not on whitelist" dobefore doSiteSetting.email_domains_whitelist = "example.com|bar.com"end@@ -719,7 +719,7 @@ describe Email::Receiver doinclude_examples "no staged users", :blacklist_whitelist_email, Email::Receiver::EmailNotAllowedend- context "when email address is on blacklist" do+ context "when From email address is on blacklist" dobefore doSiteSetting.email_domains_blacklist = "email.com|mail.com"end@@ -727,6 +727,30 @@ describe Email::Receiver doinclude_examples "no staged users", :blacklist_whitelist_email, Email::Receiver::EmailNotAllowedend+ context "blacklist and whitelist for To and Cc" do+ before do+ Fabricate(:group, incoming_email: "[email protected]")+ end++ it "does not create staged users for email addresses not on whitelist" do+ SiteSetting.email_domains_whitelist = "mail.com|example.com"+ process(:blacklist_whitelist_email)++ expect(User.find_by_email("[email protected]")).to be_nil+ expect(User.find_by_email("[email protected]")).to be_nil+ expect(User.find_by_email("[email protected]")).to be_present+ end++ it "does not create staged users for email addresses on blacklist" do+ SiteSetting.email_domains_blacklist = "email.com|foo.com"+ process(:blacklist_whitelist_email)++ expect(User.find_by_email("[email protected]")).to be_nil+ expect(User.find_by_email("[email protected]")).to be_nil+ expect(User.find_by_email("[email protected]")).to be_present+ end+ end+context "when destinations aren't matching any of the incoming emails" doinclude_examples "no staged users", :bad_destinations, Email::Receiver::BadDestinationAddressenddiff --git a/spec/fixtures/emails/blacklist_whitelist_email.eml b/spec/fixtures/emails/blacklist_whitelist_email.emlindex f6b38bfcce3..f9b0adf7905 100644--- a/spec/fixtures/emails/blacklist_whitelist_email.eml+++ b/spec/fixtures/emails/blacklist_whitelist_email.eml@@ -1,5 +1,7 @@Return-Path: <[email protected]>From: Foo <[email protected]>Date: Fri, 15 Jan 2016 00:12:43 +0100Message-ID: <[email protected]>Mime-Version: 1.0