مراية لـ
https://github.com/postalserver/postal.git
تم المزامنة 2025-12-01 05:43:04 +00:00
feat: new configuration system (and schema) (#2819)
هذا الالتزام موجود في:
@@ -39,7 +39,7 @@ module SMTPServer
|
||||
client.handle("RCPT TO: #{route.name}@#{route.domain.name}")
|
||||
Timecop.freeze do
|
||||
client.handle("DATA")
|
||||
expect(client.headers["received"]).to include "from test.example.com (1.2.3.4 [1.2.3.4]) by postal.example.com with SMTP; #{Time.now.utc.rfc2822}"
|
||||
expect(client.headers["received"]).to include "from test.example.com (1.2.3.4 [1.2.3.4]) by #{Postal::Config.postal.smtp_hostname} with SMTP; #{Time.now.utc.rfc2822}"
|
||||
end
|
||||
end
|
||||
|
||||
@@ -72,7 +72,7 @@ module SMTPServer
|
||||
client.handle("This is some content for the message.")
|
||||
client.handle("It will keep going.")
|
||||
expect(client.instance_variable_get("@data")).to eq <<~DATA
|
||||
Received: from test.example.com (1.2.3.4 [1.2.3.4]) by #{Postal.config.dns.smtp_server_hostname} with SMTP; #{Time.now.utc.rfc2822}\r
|
||||
Received: from test.example.com (1.2.3.4 [1.2.3.4]) by #{Postal::Config.postal.smtp_hostname} with SMTP; #{Time.now.utc.rfc2822}\r
|
||||
Subject: Test\r
|
||||
\r
|
||||
This is some content for the message.\r
|
||||
|
||||
@@ -24,7 +24,7 @@ module SMTPServer
|
||||
describe "when finished sending data" do
|
||||
context "when the data is larger than the maximum message size" do
|
||||
it "returns an error and resets the state" do
|
||||
allow(Postal.config.smtp_server).to receive(:max_message_size).and_return(1)
|
||||
allow(Postal::Config.smtp_server).to receive(:max_message_size).and_return(1)
|
||||
client.handle("DATA")
|
||||
client.handle("a" * 1024 * 1024 * 10)
|
||||
expect(client.handle(".")).to eq "552 Message too large (maximum size 1MB)"
|
||||
@@ -34,10 +34,10 @@ module SMTPServer
|
||||
context "when a loop is detected" do
|
||||
it "returns an error and resets the state" do
|
||||
client.handle("DATA")
|
||||
client.handle("Received: from example1.com by #{Postal.config.dns.smtp_server_hostname}")
|
||||
client.handle("Received: from example2.com by #{Postal.config.dns.smtp_server_hostname}")
|
||||
client.handle("Received: from example1.com by #{Postal.config.dns.smtp_server_hostname}")
|
||||
client.handle("Received: from example2.com by #{Postal.config.dns.smtp_server_hostname}")
|
||||
client.handle("Received: from example1.com by #{Postal::Config.postal.smtp_hostname}")
|
||||
client.handle("Received: from example2.com by #{Postal::Config.postal.smtp_hostname}")
|
||||
client.handle("Received: from example1.com by #{Postal::Config.postal.smtp_hostname}")
|
||||
client.handle("Received: from example2.com by #{Postal::Config.postal.smtp_hostname}")
|
||||
client.handle("Subject: Test")
|
||||
client.handle("From: #{mail_from}")
|
||||
client.handle("To: #{rcpt_to}")
|
||||
@@ -93,7 +93,7 @@ module SMTPServer
|
||||
|
||||
context "when sending a bounce message" do
|
||||
let(:credential) { nil }
|
||||
let(:rcpt_to) { "#{server.token}@#{Postal.config.dns.return_path}" }
|
||||
let(:rcpt_to) { "#{server.token}@#{Postal::Config.dns.return_path_domain}" }
|
||||
|
||||
context "when there is a return path route" do
|
||||
let(:domain) { create(:domain, owner: server) }
|
||||
@@ -114,7 +114,7 @@ module SMTPServer
|
||||
|
||||
queued_message = QueuedMessage.first
|
||||
expect(queued_message).to have_attributes(
|
||||
domain: Postal.config.dns.return_path,
|
||||
domain: Postal::Config.dns.return_path_domain,
|
||||
server: server
|
||||
)
|
||||
|
||||
@@ -145,7 +145,7 @@ module SMTPServer
|
||||
|
||||
queued_message = QueuedMessage.first
|
||||
expect(queued_message).to have_attributes(
|
||||
domain: Postal.config.dns.return_path,
|
||||
domain: Postal::Config.dns.return_path_domain,
|
||||
server: server
|
||||
)
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ module SMTPServer
|
||||
describe "HELO" do
|
||||
it "returns the hostname" do
|
||||
expect(client.state).to eq :welcome
|
||||
expect(client.handle("HELO: test.example.com")).to eq "250 #{Postal.config.dns.smtp_server_hostname}"
|
||||
expect(client.handle("HELO: test.example.com")).to eq "250 #{Postal::Config.postal.smtp_hostname}"
|
||||
expect(client.state).to eq :welcomed
|
||||
end
|
||||
end
|
||||
@@ -24,7 +24,7 @@ module SMTPServer
|
||||
|
||||
context "when TLS is enabled" do
|
||||
it "returns capabilities include starttls" do
|
||||
allow(Postal.config.smtp_server).to receive(:tls_enabled?).and_return(true)
|
||||
allow(Postal::Config.smtp_server).to receive(:tls_enabled?).and_return(true)
|
||||
expect(client.handle("EHLO test.example.com")).to eq ["250-My capabilities are",
|
||||
"250-STARTTLS",
|
||||
"250 AUTH CRAM-MD5 PLAIN LOGIN"]
|
||||
|
||||
@@ -36,18 +36,18 @@ module SMTPServer
|
||||
|
||||
context "when the RCPT TO address is the system return path host" do
|
||||
it "returns an error if the server does not exist" do
|
||||
expect(client.handle("RCPT TO: nothing@#{Postal.config.dns.return_path}")).to eq "550 Invalid server token"
|
||||
expect(client.handle("RCPT TO: nothing@#{Postal::Config.dns.return_path_domain}")).to eq "550 Invalid server token"
|
||||
end
|
||||
|
||||
it "returns an error if the server is suspended" do
|
||||
server = create(:server, :suspended)
|
||||
expect(client.handle("RCPT TO: #{server.token}@#{Postal.config.dns.return_path}"))
|
||||
expect(client.handle("RCPT TO: #{server.token}@#{Postal::Config.dns.return_path_domain}"))
|
||||
.to eq "535 Mail server has been suspended"
|
||||
end
|
||||
|
||||
it "adds a recipient if all OK" do
|
||||
server = create(:server)
|
||||
address = "#{server.token}@#{Postal.config.dns.return_path}"
|
||||
address = "#{server.token}@#{Postal::Config.dns.return_path_domain}"
|
||||
expect(client.handle("RCPT TO: #{address}")).to eq "250 OK"
|
||||
expect(client.recipients).to eq [[:bounce, address, server]]
|
||||
expect(client.state).to eq :rcpt_to_received
|
||||
@@ -56,19 +56,19 @@ module SMTPServer
|
||||
|
||||
context "when the RCPT TO address is on a host using the return path prefix" do
|
||||
it "returns an error if the server does not exist" do
|
||||
address = "nothing@#{Postal.config.dns.custom_return_path_prefix}.example.com"
|
||||
address = "nothing@#{Postal::Config.dns.custom_return_path_prefix}.example.com"
|
||||
expect(client.handle("RCPT TO: #{address}")).to eq "550 Invalid server token"
|
||||
end
|
||||
|
||||
it "returns an error if the server is suspended" do
|
||||
server = create(:server, :suspended)
|
||||
address = "#{server.token}@#{Postal.config.dns.custom_return_path_prefix}.example.com"
|
||||
address = "#{server.token}@#{Postal::Config.dns.custom_return_path_prefix}.example.com"
|
||||
expect(client.handle("RCPT TO: #{address}")).to eq "535 Mail server has been suspended"
|
||||
end
|
||||
|
||||
it "adds a recipient if all OK" do
|
||||
server = create(:server)
|
||||
address = "#{server.token}@#{Postal.config.dns.custom_return_path_prefix}.example.com"
|
||||
address = "#{server.token}@#{Postal::Config.dns.custom_return_path_prefix}.example.com"
|
||||
expect(client.handle("RCPT TO: #{address}")).to eq "250 OK"
|
||||
expect(client.recipients).to eq [[:bounce, address, server]]
|
||||
expect(client.state).to eq :rcpt_to_received
|
||||
@@ -77,28 +77,28 @@ module SMTPServer
|
||||
|
||||
context "when the RCPT TO address is within the route domain" do
|
||||
it "returns an error if the route token is invalid" do
|
||||
address = "nothing@#{Postal.config.dns.route_domain}"
|
||||
address = "nothing@#{Postal::Config.dns.route_domain}"
|
||||
expect(client.handle("RCPT TO: #{address}")).to eq "550 Invalid route token"
|
||||
end
|
||||
|
||||
it "returns an error if the server is suspended" do
|
||||
server = create(:server, :suspended)
|
||||
route = create(:route, server: server)
|
||||
address = "#{route.token}@#{Postal.config.dns.route_domain}"
|
||||
address = "#{route.token}@#{Postal::Config.dns.route_domain}"
|
||||
expect(client.handle("RCPT TO: #{address}")).to eq "535 Mail server has been suspended"
|
||||
end
|
||||
|
||||
it "returns an error if the route is set to Reject mail" do
|
||||
server = create(:server)
|
||||
route = create(:route, server: server, mode: "Reject")
|
||||
address = "#{route.token}@#{Postal.config.dns.route_domain}"
|
||||
address = "#{route.token}@#{Postal::Config.dns.route_domain}"
|
||||
expect(client.handle("RCPT TO: #{address}")).to eq "550 Route does not accept incoming messages"
|
||||
end
|
||||
|
||||
it "adds a recipient if all OK" do
|
||||
server = create(:server)
|
||||
route = create(:route, server: server)
|
||||
address = "#{route.token}+tag1@#{Postal.config.dns.route_domain}"
|
||||
address = "#{route.token}+tag1@#{Postal::Config.dns.route_domain}"
|
||||
expect(client.handle("RCPT TO: #{address}")).to eq "250 OK"
|
||||
expect(client.recipients).to eq [[:route, "#{route.name}+tag1@#{route.domain.name}", server, { route: route }]]
|
||||
expect(client.state).to eq :rcpt_to_received
|
||||
|
||||
المرجع في مشكلة جديدة
حظر مستخدم