def test_forward_paths_added(self) -> None: state = State() state.greeted = True state.reverse_path = "*****@*****.**" handle_rcpt(state, "TO:<*****@*****.**>") handle_rcpt(state, "TO:<*****@*****.**>") assert state.forward_path == ["*****@*****.**", "*****@*****.**"]
def test_no_reverse_path(self) -> None: state = State() state.greeted = True state.reverse_path = None code, message = handle_rcpt(state, "TO:<*****@*****.**>") assert code == SMTPStatus.BAD_SEQUENCE assert message == "Bad command sequence"
def test_response(self) -> None: state = State() state.greeted = True state.reverse_path = "*****@*****.**" code, message = handle_rcpt(state, "TO:<*****@*****.**>") assert code == SMTPStatus.OK assert message == "Receiver OK"
def test_mail_data(self) -> None: state = State() state.greeted = True state.reverse_path = "*****@*****.**" state.mail_data = "" code, message = handle_rcpt(state, "TO:<*****@*****.**>") assert code == SMTPStatus.BAD_SEQUENCE assert message == "Bad command sequence"
def test_with_arguments(self) -> None: state = State() state.greeted = True state.reverse_path = "*****@*****.**" code, message = handle_rcpt(state, "TO:<*****@*****.**> foo=bar baz") assert code == SMTPStatus.OK assert message == "Receiver OK" assert state.forward_path == ["*****@*****.**"]
def test_postmaster(self) -> None: state = State() state.greeted = True state.reverse_path = "*****@*****.**" code, message = handle_rcpt(state, "TO:<postMaster> foo") assert code == SMTPStatus.OK assert message == "Receiver OK" assert state.forward_path == ["postMaster"]
def test_invalid_argument(self) -> None: code, message = handle_rcpt(State(), "TO:<*****@*****.**> -foo") assert code == SMTPStatus.SYNTAX_ERROR_IN_PARAMETERS assert message == "Syntax error in arguments"
def test_path_with_trailing_chars(self) -> None: code, message = handle_rcpt(State(), "TO:<*****@*****.**>foo=bar") assert code == SMTPStatus.SYNTAX_ERROR_IN_PARAMETERS assert message == "Syntax error in arguments"
def test_domain_too_long(self) -> None: code, message = handle_rcpt( State(), f"TO:<foo@{'a' * (SMTP_DOMAIN_LIMIT + 1)}>" ) assert code == SMTPStatus.SYNTAX_ERROR_IN_PARAMETERS assert message == "Path too long"
def test_local_part_too_long(self) -> None: code, message = handle_rcpt( State(), f"TO:<{'a' * (SMTP_LOCAL_PART_LIMIT + 1)}@example.com>" ) assert code == SMTPStatus.SYNTAX_ERROR_IN_PARAMETERS assert message == "Path too long"
def test_path_too_long(self) -> None: code, message = handle_rcpt( State(), f"TO:<{'a' * 60}@{'a' * (SMTP_PATH_LIMIT - 61)}>" ) assert code == SMTPStatus.SYNTAX_ERROR_IN_PARAMETERS assert message == "Path too long"
def test_empty_path(self) -> None: code, message = handle_rcpt(State(), "TO:<>") assert code == SMTPStatus.SYNTAX_ERROR_IN_PARAMETERS assert message == "Syntax error in arguments"