-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(smtp-server): fixes proxy protocol
- Loading branch information
Showing
3 changed files
with
35 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# frozen_string_literal: true | ||
|
||
require "rails_helper" | ||
|
||
module SMTPServer | ||
|
||
describe Client do | ||
let(:ip_address) { nil } | ||
subject(:client) { described_class.new(ip_address) } | ||
|
||
describe "PROXY" do | ||
context "when the proxy header is sent correctly" do | ||
it "sets the IP address" do | ||
expect(client.handle("PROXY TCP4 1.1.1.1 2.2.2.2 1111 2222")).to eq "220 #{Postal::Config.postal.smtp_hostname} ESMTP Postal/#{client.trace_id}" | ||
expect(client.ip_address).to eq "1.1.1.1" | ||
end | ||
end | ||
|
||
context "when the proxy header is not valid" do | ||
it "returns an error" do | ||
expect(client.handle("PROXY TCP4")).to eq "502 Proxy Error" | ||
expect(client.finished?).to be true | ||
end | ||
end | ||
end | ||
end | ||
|
||
end |