-
Notifications
You must be signed in to change notification settings - Fork 248
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Steven Kreitzer <[email protected]>
- Loading branch information
Showing
4 changed files
with
111 additions
and
3 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 |
---|---|---|
|
@@ -96,6 +96,64 @@ func TestSASL_Plain_AuthFail(t *testing.T) { | |
} | ||
} | ||
|
||
func TestSASL_Login(t *testing.T) { | ||
be, srv := testutils.SMTPServer(t, "127.0.0.1:"+testPort) | ||
defer srv.Close() | ||
defer testutils.CheckSMTPConnLeak(t, srv) | ||
|
||
mod := &Downstream{ | ||
hostname: "mx.example.invalid", | ||
endpoints: []config.Endpoint{ | ||
{ | ||
Scheme: "tcp", | ||
Host: "127.0.0.1", | ||
Port: testPort, | ||
}, | ||
}, | ||
saslFactory: testSaslFactory(t, "login", "test", "testpass"), | ||
log: testutils.Logger(t, "target.smtp"), | ||
} | ||
|
||
testutils.DoTestDelivery(t, mod, "[email protected]", []string{"[email protected]"}) | ||
be.CheckMsg(t, 0, "[email protected]", []string{"[email protected]"}) | ||
if be.Messages[0].AuthUser != "test" { | ||
t.Errorf("Wrong AuthUser: %v", be.Messages[0].AuthUser) | ||
} | ||
if be.Messages[0].AuthPass != "testpass" { | ||
t.Errorf("Wrong AuthPass: %v", be.Messages[0].AuthPass) | ||
} | ||
} | ||
|
||
func TestSASL_Login_AuthFail(t *testing.T) { | ||
be, srv := testutils.SMTPServer(t, "127.0.0.1:"+testPort) | ||
defer srv.Close() | ||
defer testutils.CheckSMTPConnLeak(t, srv) | ||
|
||
be.AuthErr = &smtp.SMTPError{ | ||
Code: 550, | ||
EnhancedCode: smtp.EnhancedCode{5, 1, 2}, | ||
Message: "Hey", | ||
} | ||
|
||
mod := &Downstream{ | ||
hostname: "mx.example.invalid", | ||
endpoints: []config.Endpoint{ | ||
{ | ||
Scheme: "tcp", | ||
Host: "127.0.0.1", | ||
Port: testPort, | ||
}, | ||
}, | ||
saslFactory: testSaslFactory(t, "login", "test", "testpass"), | ||
log: testutils.Logger(t, "target.smtp"), | ||
} | ||
|
||
_, err := testutils.DoTestDeliveryErr(t, mod, "[email protected]", []string{"[email protected]"}) | ||
if err == nil { | ||
t.Error("Expected an error, got none") | ||
} | ||
} | ||
|
||
func TestSASL_Forward(t *testing.T) { | ||
be, srv := testutils.SMTPServer(t, "127.0.0.1:"+testPort) | ||
defer srv.Close() | ||
|
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