示例#1
0
def test_get_username_password_auth_plain_arg():
    smtp = SmtpProtocol()
    smtp.init()

    smtp.parse_request("AUTH PLAIN AHRlc3R1c2VyAEF3M3MwbVA0enpzIQ==")
    assert smtp.request.username == "testuser"
    assert smtp.request.password == "Aw3s0mP4zzs!"
示例#2
0
def test_get_username_cram_md5_challenge():
    smtp = SmtpProtocol()
    smtp.init()

    smtp.rescode = 334
    smtp.request.auth_type = "cram-md5"
    smtp.parse_request("ZnJlZCA5ZTk1YWVlMDljNDBhZjJiODRhMGMyYjNiYmFlNzg2ZQ==")
    assert smtp.request.username == "fred"
    assert smtp.request.password is None
示例#3
0
def test_get_username_password_auth_plain():
    smtp = SmtpProtocol()
    smtp.init()

    user_pass = "******"
    smtp.rescode = 334
    smtp.request.auth_type = "plain"
    smtp.parse_request(user_pass)

    assert smtp.request.username == "testuser"
    assert smtp.request.password == "Aw3s0mP4zzs!"
示例#4
0
def test_get_username_password_auth_login_arg():
    smtp = SmtpProtocol()
    smtp.init()

    smtp.parse_request("AUTH LOGIN Zm9vZEBiZWVyLnBseg==")
    smtp.rescode = 334
    smtp.message = "UGFzc3dvcmQ6"
    smtp.parse_request("U2hvb3BEYVdob29wIQ==")

    assert smtp.request.username == "*****@*****.**"
    assert smtp.request.password == "ShoopDaWhoop!"
示例#5
0
def test_read_smtp_ready_message():
    test = SmtpTest(os.path.join("tests", "pcaps", "smtp-auth-login.pcap"))
    sent, recv = test.get_sent_recv()
    assert recv.ready_message == "220 smtp006.mail.xxx.xxxxx.com ESMTP\r\n"

    # In case of starttls, status 220 is used twice. Test if the banner
    # is still extracted
    smtp = SmtpProtocol()
    smtp.init()
    smtp.parse_reply("220 example.com (Tosti01) ESMTP Service ready\r\n")
    smtp.parse_reply("250-example.com Hello WORKSTATION-42 [192.168.1.100]\r\n"
                     "250-AUTH LOGIN PLAIN\r\n"
                     "250-SIZE 69920427\r\n"
                     "250 STARTTLS\r\n")
    smtp.parse_reply("220 OK STARTTLS ready\r\n")
    assert smtp.reply.ready_message == (
        "220 example.com (Tosti01) ESMTP Service ready\r\n")