mirror of
https://github.com/jhillyerd/inbucket.git
synced 2025-12-17 09:37:02 +00:00
smtp/policy: Store messages with full naming for #33
- Added some tests to make sure stores do not enforce their own naming. - Improve recipient structured logging.
This commit is contained in:
@@ -56,7 +56,9 @@ func (m *ManagerStub) GetMetadata(mailbox string) ([]*message.Metadata, error) {
|
||||
|
||||
// MailboxForAddress invokes policy.ParseMailboxName.
|
||||
func (m *ManagerStub) MailboxForAddress(address string) (string, error) {
|
||||
addrPolicy := &policy.Addressing{Config: &config.Root{}}
|
||||
addrPolicy := &policy.Addressing{Config: &config.Root{
|
||||
MailboxNaming: config.FullNaming,
|
||||
}}
|
||||
return addrPolicy.ExtractMailbox(address)
|
||||
}
|
||||
|
||||
|
||||
@@ -27,6 +27,7 @@ func StoreSuite(t *testing.T, factory StoreFactory) {
|
||||
{"metadata", testMetadata, config.Storage{}},
|
||||
{"content", testContent, config.Storage{}},
|
||||
{"delivery order", testDeliveryOrder, config.Storage{}},
|
||||
{"naming", testNaming, config.Storage{}},
|
||||
{"size", testSize, config.Storage{}},
|
||||
{"seen", testSeen, config.Storage{}},
|
||||
{"delete", testDelete, config.Storage{}},
|
||||
@@ -191,6 +192,13 @@ func testDeliveryOrder(t *testing.T, store storage.Store) {
|
||||
}
|
||||
}
|
||||
|
||||
// testNaming ensures the store does not enforce local part mailbox naming.
|
||||
func testNaming(t *testing.T, store storage.Store) {
|
||||
DeliverToStore(t, store, "fred@fish.net", "disk #27", time.Now())
|
||||
GetAndCountMessages(t, store, "fred", 0)
|
||||
GetAndCountMessages(t, store, "fred@fish.net", 1)
|
||||
}
|
||||
|
||||
// testSize verifies message contnet size metadata values.
|
||||
func testSize(t *testing.T, store storage.Store) {
|
||||
mailbox := "fred"
|
||||
@@ -406,7 +414,7 @@ func GetAndCountMessages(t *testing.T, s storage.Store, mailbox string, count in
|
||||
t.Fatalf("Failed to GetMessages for %q: %v", mailbox, err)
|
||||
}
|
||||
if len(msgs) != count {
|
||||
t.Errorf("Got %v messages, want: %v", len(msgs), count)
|
||||
t.Errorf("Got %v messages for %q, want: %v", len(msgs), mailbox, count)
|
||||
}
|
||||
return msgs
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user