Пример #1
0
 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 == ["*****@*****.**", "*****@*****.**"]
Пример #2
0
 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"
Пример #3
0
 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"
Пример #4
0
 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"
Пример #5
0
 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 == ["*****@*****.**"]
Пример #6
0
 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"]
Пример #7
0
 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"
Пример #8
0
 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"
Пример #9
0
 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"
Пример #10
0
 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"
Пример #11
0
 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"
Пример #12
0
 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"