fix(GODT-3132): Do not allow sending on disabled accounts

This commit is contained in:
Leander Beernaert
2023-11-22 13:52:00 +01:00
parent ef183e0758
commit 36f7d9672f
2 changed files with 13 additions and 2 deletions

View File

@ -102,7 +102,7 @@ func (s *Service) smtpSendMail(ctx context.Context, authID string, from string,
} }
} }
if !fromAddr.Send { if !fromAddr.Send || fromAddr.Status != proton.AddressStatusEnabled {
s.log.Errorf("Can't send emails on address: %v", fromAddr.Email) s.log.Errorf("Can't send emails on address: %v", fromAddr.Email)
return &ErrCanNotSendOnAddress{address: fromAddr.Email} return &ErrCanNotSendOnAddress{address: fromAddr.Email}
} }

View File

@ -1,6 +1,7 @@
Feature: SMTP wrong messages Feature: SMTP wrong messages
Background: Background:
Given there exists an account with username "[user:user]" and password "password" Given there exists an account with username "[user:user]" and password "password"
And the account "[user:user]" has additional disabled address "[user:disabled]@[domain]"
And there exists an account with username "[user:to]" and password "password" And there exists an account with username "[user:to]" and password "password"
Then it succeeds Then it succeeds
When bridge starts When bridge starts
@ -54,4 +55,14 @@ Feature: SMTP wrong messages
hello hello
""" """
Then it fails Then it fails with error "invalid return path"
Scenario: Send from a valid address that cannot send
When SMTP client "1" sends the following message from "[user:disabled]@[domain]" to "[user:to]@[domain]":
"""
From: Bridge Test Disabled <[user:disabled]@[domain]>
To: Internal Bridge <[user:to]@[domain]>
Hello
"""
And it fails with error "Error: can't send on address: [user:disabled]@[domain]"