Пример #1
0
def test_two_A_responses():
    qname = "dualstack.mc-12555-1019789594.us-east-1.elb.amazonaws.com."
    T = Tester()
    T.newtest(testname="py.test")
    response = dbdns.query(T, qname, dns.rdatatype.A)
    count = 0
    for rrset in response.answer:
        for rr in rrset:
            if rr.rdtype == dns.rdatatype.A:
                print("IP address for {} is {}".format(qname, rr.address))
                count += 1
    assert count >= 2
Пример #2
0
def test_a_read():
    qname = "google-public-dns-a.google.com."
    T = Tester()
    T.newtest(testname="py.test")
    response = dbdns.query(T, qname, dns.rdatatype.A)
    count = 0
    for rrset in response.answer:
        for rr in rrset:
            if rr.rdtype == dns.rdatatype.A:
                print("IP addr for {} is {}".format(qname, rr.address))
                assert rr.address == "8.8.8.8"
                count += 1
    assert count > 0
Пример #3
0
def test_read_tlsa():
    """Verify that a TLSA record can be read"""
    qname = "_443._tcp.good.dane.verisignlabs.com"
    T = Tester()
    T.newtest(testname="py.test")
    response = dbdns.query(T, qname, dns.rdatatype.TLSA)
    count = 0
    for rrset in response.answer:
        for rr in rrset:
            if rr.rdtype == dns.rdatatype.TLSA:
                print("{}: {} {} {} {}".format(qname, rr.usage, rr.selector, rr.mtype, hexdump(rr.cert)))
                count += 1
    assert count > 0
Пример #4
0
def test_dnssec_response_notpresent():
    qname = "www.google.com"
    T = Tester()
    T.newtest(testname="py.test")
    response = dbdns.query(T, qname, dns.rdatatype.A)
    count = 0
    for rrset in response.answer:
        for rr in rrset:
            if rr.rdtype == dns.rdatatype.A:
                dnssec = response.flags & dns.flags.AD
                print("IP address for {} is {} DNSSEC: {}".format(qname, rr.address, dnssec))
                if dnssec:
                    count += 1
    assert count == 0
Пример #5
0
def test_cname_read():
    # This test makes use of the fact that a.nitroba.org is set as a cname to b.nitroba.org
    qname = "a.nitroba.org"
    T = Tester()
    T.newtest(testname="py.test")
    response = dbdns.query(T, qname, dns.rdatatype.CNAME)
    count = 0
    for rset in response.answer:
        for rr in rset:
            if rr.rdtype == dns.rdatatype.CNAME:
                print("cname for a.nitroba.org is {}".format(rr.target))
                assert str(rr.target) == "b.nitroba.org."
                count += 1
    assert count > 0  # no response?
Пример #6
0
def email_receiver(cmd,msg):
    T = Tester()
    T.newtest(testname=cmd)

    # Save the received email mesasge in the database
    messageid = T.insert_email_message(tester.EMAIL_TAG_USER_SENT,str(msg))
    args = {"messageid":messageid,"cmd":cmd}

    # Depending on the command, institute the next step...
    if cmd=="bouncer":
        T.insert_task(tester.TASK_COMPOSE_SIMPLE_RESPONSE, args)
        T.commit()
        
    elif cmd=="register":
        T.insert_task(tester.TASK_REGISTER_FROM_EMAIL, args)
        T.commit()

    else:
         # Log invalid command
         logging.info("Invalid command: {}  Message {}".format(cmd,messageid))
Пример #7
0
if __name__=="__main__":
    import argparse,sys
    from tester import Tester

    parser = argparse.ArgumentParser(description="smimea tester")
    parser.add_argument("--print",help="get and print a certificate for an email address")
    parser.add_argument("--send",help="send test emails email to the address provided")
    parser.add_argument("--debug",help="print the test email messages, but don't send them",action='store_true')
    parser.add_argument("--smtpdebug",help="enable SMTP debugging",action='store_true')
    parser.add_argument("--type61",help="Create a Type61 [RFC 7929] record; specify email address on command line")
    parser.add_argument("--pubkey",help="Dump GPG public key block",action='store_true')


    args = parser.parse_args()
    T = Tester()
    T.newtest(testname="dig")
    if args.print:
        print(openpgpkey_to_txt(T,args.print))

    if args.send:
        encrypting_key = get_pubkey(T,args.send)
        if not encrypting_key:
            print("Cannot find key for {}".format(args.send))
            exit(1)
            
        import smtplib
        if args.debug:
            s = DebugSendmail()
        else:
            s = smtplib.SMTP("mail.nist.gov")
            if args.smtpdebug: