Skip to content

Commit 1d04424

Browse files
committed
endpoint/smtp: Fix auth_map ignored
1 parent c852199 commit 1d04424

File tree

2 files changed

+71
-2
lines changed

2 files changed

+71
-2
lines changed

internal/endpoint/smtp/smtp.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,8 @@ func (endp *Endpoint) setConfig(cfg *config.Map) error {
289289
return err
290290
}
291291

292+
endp.saslAuth.Log.Debug = endp.Log.Debug
293+
292294
// INTERNATIONALIZATION: See RFC 6531 Section 3.3.
293295
endp.serv.Domain, err = idna.ToASCII(hostname)
294296
if err != nil {
@@ -310,8 +312,6 @@ func (endp *Endpoint) setConfig(cfg *config.Map) error {
310312
return fmt.Errorf("%s: auth. provider must be set for submission endpoint", endp.name)
311313
}
312314
}
313-
endp.saslAuth.AuthNormalize = endp.authNormalize
314-
endp.saslAuth.AuthMap = endp.authMap
315315

316316
if ioDebug {
317317
endp.serv.Debug = endp.Log.DebugWriter()

tests/multiple_domains_test.go

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,26 +71,44 @@ func TestMultipleDomains_SeparateNamespace(tt *testing.T) {
7171
t.Run(2)
7272

7373
user1 := t.Conn("imap")
74+
defer user1.Close()
7475
user1.ExpectPattern(`\* OK *`)
7576
user1.Writeln(`. LOGIN [email protected] user1`)
7677
user1.ExpectPattern(`. OK *`)
7778
user1.Writeln(`. CREATE user1`)
7879
user1.ExpectPattern(`. OK *`)
7980

81+
user1SMTP := t.Conn("submission")
82+
defer user1SMTP.Close()
83+
user1SMTP.SMTPNegotation("localhost", []string{"AUTH PLAIN"}, nil)
84+
user1SMTP.SMTPPlainAuth("[email protected]", "user1", true)
85+
8086
user2 := t.Conn("imap")
87+
defer user2.Close()
8188
user2.ExpectPattern(`\* OK *`)
8289
user2.Writeln(`. LOGIN [email protected] user2`)
8390
user2.ExpectPattern(`. OK *`)
8491
user2.Writeln(`. CREATE user2`)
8592
user2.ExpectPattern(`. OK *`)
8693

94+
user2SMTP := t.Conn("submission")
95+
defer user2SMTP.Close()
96+
user2SMTP.SMTPNegotation("localhost", []string{"AUTH PLAIN"}, nil)
97+
user2SMTP.SMTPPlainAuth("[email protected]", "user2", true)
98+
8799
user3 := t.Conn("imap")
100+
defer user3.Close()
88101
user3.ExpectPattern(`\* OK *`)
89102
user3.Writeln(`. LOGIN [email protected] user3`)
90103
user3.ExpectPattern(`. OK *`)
91104
user3.Writeln(`. CREATE user3`)
92105
user3.ExpectPattern(`. OK *`)
93106

107+
user3SMTP := t.Conn("submission")
108+
defer user3SMTP.Close()
109+
user3SMTP.SMTPNegotation("localhost", []string{"AUTH PLAIN"}, nil)
110+
user3SMTP.SMTPPlainAuth("[email protected]", "user3", true)
111+
94112
user1.Writeln(`. LIST "" "*"`)
95113
user1.Expect(`* LIST (\HasNoChildren) "." INBOX`)
96114
user1.Expect(`* LIST (\HasNoChildren) "." "user1"`)
@@ -150,26 +168,44 @@ func TestMultipleDomains_SharedCredentials_DistinctMailboxes(tt *testing.T) {
150168
t.Run(2)
151169

152170
user1 := t.Conn("imap")
171+
defer user1.Close()
153172
user1.ExpectPattern(`\* OK *`)
154173
user1.Writeln(`. LOGIN [email protected] user1`)
155174
user1.ExpectPattern(`. OK *`)
156175
user1.Writeln(`. CREATE user1`)
157176
user1.ExpectPattern(`. OK *`)
158177

178+
user1SMTP := t.Conn("submission")
179+
defer user1SMTP.Close()
180+
user1SMTP.SMTPNegotation("localhost", []string{"AUTH PLAIN"}, nil)
181+
user1SMTP.SMTPPlainAuth("[email protected]", "user1", true)
182+
159183
user2 := t.Conn("imap")
184+
defer user2.Close()
160185
user2.ExpectPattern(`\* OK *`)
161186
user2.Writeln(`. LOGIN [email protected] user2`)
162187
user2.ExpectPattern(`. OK *`)
163188
user2.Writeln(`. CREATE user2`)
164189
user2.ExpectPattern(`. OK *`)
165190

191+
user2SMTP := t.Conn("submission")
192+
defer user2SMTP.Close()
193+
user2SMTP.SMTPNegotation("localhost", []string{"AUTH PLAIN"}, nil)
194+
user2SMTP.SMTPPlainAuth("[email protected]", "user2", true)
195+
166196
user3 := t.Conn("imap")
197+
defer user3.Close()
167198
user3.ExpectPattern(`\* OK *`)
168199
user3.Writeln(`. LOGIN [email protected] user1`)
169200
user3.ExpectPattern(`. OK *`)
170201
user3.Writeln(`. CREATE user3`)
171202
user3.ExpectPattern(`. OK *`)
172203

204+
user3SMTP := t.Conn("submission")
205+
defer user3SMTP.Close()
206+
user3SMTP.SMTPNegotation("localhost", []string{"AUTH PLAIN"}, nil)
207+
user3SMTP.SMTPPlainAuth("[email protected]", "user1", true)
208+
173209
user1.Writeln(`. LIST "" "*"`)
174210
user1.Expect(`* LIST (\HasNoChildren) "." INBOX`)
175211
user1.Expect(`* LIST (\HasNoChildren) "." "user1"`)
@@ -232,30 +268,62 @@ func TestMultipleDomains_SharedCredentials_SharedMailboxes(tt *testing.T) {
232268
t.Run(2)
233269

234270
user1 := t.Conn("imap")
271+
defer user1.Close()
235272
user1.ExpectPattern(`\* OK *`)
236273
user1.Writeln(`. LOGIN user1 user1`)
237274
user1.ExpectPattern(`. OK *`)
238275
user1.Writeln(`. CREATE user1`)
239276
user1.ExpectPattern(`. OK *`)
240277

278+
user1SMTP := t.Conn("submission")
279+
defer user1SMTP.Close()
280+
user1SMTP.SMTPNegotation("localhost", []string{"AUTH PLAIN"}, nil)
281+
user1SMTP.SMTPPlainAuth("user1", "user1", true)
282+
241283
user2 := t.Conn("imap")
284+
defer user2.Close()
242285
user2.ExpectPattern(`\* OK *`)
243286
user2.Writeln(`. LOGIN [email protected] user2`)
244287
user2.ExpectPattern(`. OK *`)
245288
user2.Writeln(`. CREATE user2`)
246289
user2.ExpectPattern(`. OK *`)
247290

291+
user2SMTP := t.Conn("submission")
292+
defer user2SMTP.Close()
293+
user2SMTP.SMTPNegotation("localhost", []string{"AUTH PLAIN"}, nil)
294+
user2SMTP.SMTPPlainAuth("user2", "user2", true)
295+
248296
user12 := t.Conn("imap")
297+
defer user12.Close()
249298
user12.ExpectPattern(`\* OK *`)
250299
user12.Writeln(`. LOGIN [email protected] user1`)
251300
user12.ExpectPattern(`. OK *`)
252301
user12.Writeln(`. CREATE user12`)
253302
user12.ExpectPattern(`. OK *`)
254303

304+
user13 := t.Conn("imap")
305+
defer user13.Close()
306+
user13.ExpectPattern(`\* OK *`)
307+
user13.Writeln(`. LOGIN [email protected] user1`)
308+
user13.ExpectPattern(`. OK *`)
309+
user13.Writeln(`. CREATE user13`)
310+
user13.ExpectPattern(`. OK *`)
311+
312+
user12SMTP := t.Conn("submission")
313+
defer user12SMTP.Close()
314+
user12SMTP.SMTPNegotation("localhost", []string{"AUTH PLAIN"}, nil)
315+
user12SMTP.SMTPPlainAuth("user1", "user1", true)
316+
317+
user13SMTP := t.Conn("submission")
318+
defer user13SMTP.Close()
319+
user13SMTP.SMTPNegotation("localhost", []string{"AUTH PLAIN"}, nil)
320+
user13SMTP.SMTPPlainAuth("[email protected]", "user1", true)
321+
255322
user1.Writeln(`. LIST "" "*"`)
256323
user1.Expect(`* LIST (\HasNoChildren) "." INBOX`)
257324
user1.Expect(`* LIST (\HasNoChildren) "." "user1"`)
258325
user1.Expect(`* LIST (\HasNoChildren) "." "user12"`)
326+
user1.Expect(`* LIST (\HasNoChildren) "." "user13"`)
259327
user1.ExpectPattern(". OK *")
260328

261329
user2.Writeln(`. LIST "" "*"`)
@@ -267,5 +335,6 @@ func TestMultipleDomains_SharedCredentials_SharedMailboxes(tt *testing.T) {
267335
user12.Expect(`* LIST (\HasNoChildren) "." INBOX`)
268336
user12.Expect(`* LIST (\HasNoChildren) "." "user1"`)
269337
user12.Expect(`* LIST (\HasNoChildren) "." "user12"`)
338+
user12.Expect(`* LIST (\HasNoChildren) "." "user13"`)
270339
user12.ExpectPattern(". OK *")
271340
}

0 commit comments

Comments
 (0)