-
Notifications
You must be signed in to change notification settings - Fork 254
server: Move to using Backend.Features() instead of Enable* flags #112
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -21,6 +21,22 @@ type Backend interface { | |
| AnonymousLogin(state *ConnectionState) (Session, error) | ||
| } | ||
|
|
||
| type Feature int32 | ||
|
|
||
| const ( | ||
| FeatureSMTPUTF8 Feature = 2 << iota | ||
emersion marked this conversation as resolved.
Show resolved
Hide resolved
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why is this 2 instead of 1? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ouch, most likely a typo |
||
| FeatureBINARYMIME | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The rest of the code seems to use the Go capitalization: "BinaryMIME" (Same for "RequireTLS" I suppose) |
||
| FeatureREQUIRETLS | ||
| ) | ||
|
|
||
| func (f Feature) Contains(feat Feature) bool { | ||
| return f&feat != 0 | ||
| } | ||
|
|
||
| type FeatureBackend interface { | ||
emersion marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| Features() Feature | ||
| } | ||
|
|
||
| type BodyType string | ||
|
|
||
| const ( | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -40,10 +40,16 @@ type backend struct { | |
| // Read N bytes of message before returning dataErr. | ||
| dataErrOffset int64 | ||
|
|
||
| features smtp.Feature | ||
|
|
||
| panicOnMail bool | ||
| userErr error | ||
| } | ||
|
|
||
| func (be *backend) Features() smtp.Feature { | ||
| return be.features | ||
| } | ||
|
|
||
| func (be *backend) Login(_ *smtp.ConnectionState, username, password string) (smtp.Session, error) { | ||
| if be.userErr != nil { | ||
| return &session{}, be.userErr | ||
|
|
@@ -338,10 +344,10 @@ func TestServerPanicRecover(t *testing.T) { | |
| } | ||
|
|
||
| func TestServerSMTPUTF8(t *testing.T) { | ||
| _, s, c, scanner := testServerAuthenticated(t) | ||
| s.EnableSMTPUTF8 = true | ||
| be, s, c, scanner := testServerAuthenticated(t) | ||
| defer s.Close() | ||
| defer c.Close() | ||
| be.features = smtp.FeatureSMTPUTF8 | ||
|
|
||
| io.WriteString(c, "MAIL FROM:<[email protected]> SMTPUTF8\r\n") | ||
| scanner.Scan() | ||
|
|
@@ -1050,7 +1056,7 @@ func TestServer_Chunking_Binarymime(t *testing.T) { | |
| be, s, c, scanner := testServerAuthenticated(t) | ||
| defer s.Close() | ||
| defer c.Close() | ||
| s.EnableBINARYMIME = true | ||
| be.features = smtp.FeatureBINARYMIME | ||
|
|
||
| io.WriteString(c, "MAIL FROM:<[email protected]> BODY=BINARYMIME\r\n") | ||
| scanner.Scan() | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.