예제 #1
0
def handle_mail(state: State, arguments: str) -> Reply:
    if arguments[:5].upper() != "FROM:":
        return handle_wrong_arguments()
    try:
        path, rest = parse_reverse_path(arguments[5:])
    except ValueError as exc:
        return handle_wrong_arguments(str(exc))
    if not is_valid_smtp_arguments(rest):
        return handle_wrong_arguments()
    if not state.greeted:
        return handle_no_greeting()
    if not state.mail_allowed:
        return handle_bad_command_sequence()
    state.clear()
    state.reverse_path = path
    return SMTPStatus.OK, "Sender OK"
예제 #2
0
파일: syntax.py 프로젝트: srittau/FakeSMTPd
 def test_invalid_domain(self) -> None:
     with pytest.raises(ValueError):
         parse_reverse_path("<foo@*>")
예제 #3
0
파일: syntax.py 프로젝트: srittau/FakeSMTPd
 def test_empty_path(self) -> None:
     path, rest = parse_reverse_path("<>")
     assert path == ""
     assert rest == ""
예제 #4
0
파일: syntax.py 프로젝트: srittau/FakeSMTPd
 def test_missing_at(self) -> None:
     with pytest.raises(ValueError):
         parse_reverse_path("<invalid>")
예제 #5
0
파일: syntax.py 프로젝트: srittau/FakeSMTPd
 def test_invalid_local_part(self) -> None:
     with pytest.raises(ValueError):
         parse_reverse_path("<@@example.com>")
예제 #6
0
파일: syntax.py 프로젝트: srittau/FakeSMTPd
 def test_invalid(self) -> None:
     with pytest.raises(ValueError):
         parse_reverse_path("INVALID")
예제 #7
0
파일: syntax.py 프로젝트: srittau/FakeSMTPd
 def test_quoted_string(self) -> None:
     path, rest = parse_reverse_path('<"foo \\" bar"@example.com>')
     assert path == '"foo \\" bar"@example.com'
     assert rest == ""
예제 #8
0
파일: syntax.py 프로젝트: srittau/FakeSMTPd
 def test_mailbox_with_rest(self) -> None:
     path, rest = parse_reverse_path("<*****@*****.**>REST")
     assert path == "*****@*****.**"
     assert rest == "REST"
예제 #9
0
파일: syntax.py 프로젝트: srittau/FakeSMTPd
 def test_mailbox(self) -> None:
     path, rest = parse_reverse_path("<*****@*****.**>")
     assert path == "*****@*****.**"
     assert rest == ""
예제 #10
0
파일: syntax.py 프로젝트: srittau/FakeSMTPd
 def test_empty_path_with_rest(self) -> None:
     path, rest = parse_reverse_path("<>REST")
     assert path == ""
     assert rest == "REST"