예제 #1
0
파일: cli.py 프로젝트: juliu-s/dnszonetest
def main():
    '''
    Entry point for the package defined in setup.py.

    :returns: 0 when records from zone file correctly resolve against
        nameserver, 2 when not, 3 on errors.
    :rtype: int
    '''
    # Parse args
    args = parse_args(sys.argv[1:])
    # Setup basic logging
    setup_logging(args.verbose, args.quiet)
    logger.debug('Arguments: %s', args)
    dnszonetest = DnsZoneTest(
        args.zonename,
        args.zonefile,
        nameserver=args.nameserver,
        verbose=args.verbose,
        quiet=args.quiet,
        no_recursion=args.no_recursion,
        compare_ttl=args.compare_ttl,
        compare_ns=args.compare_ns,
        compare_soa=args.compare_soa,
    )
    dnszonetest.compare()
    return dnszonetest.errno
예제 #2
0
파일: cli.py 프로젝트: maartenq/dnszonetest
def main():
    '''
    Entry point for the package defined in setup.py.

    :returns: 0 when records from zone file correctly resolve against
        nameserver, 2 when not, 3 on errors.
    :rtype: int
    '''
    # Parse args
    args = parse_args(sys.argv[1:])
    # Setup basic logging
    setup_logging(args.verbose, args.quiet)
    logger.debug('Arguments: %s', args)
    dnszonetest = DnsZoneTest(
        args.zonename,
        args.zonefile,
        nameserver=args.nameserver,
        protocol=args.protocol,
        verbose=args.verbose,
        quiet=args.quiet,
        no_recursion=args.no_recursion,
        compare_ttl=args.compare_ttl,
        compare_ns=args.compare_ns,
        compare_soa=args.compare_soa,
    )
    dnszonetest.compare()
    return dnszonetest.errno
예제 #3
0
def test_get_nameserver_ip_raises_UnableToResolveNameServerException():
    '''
    test if get_nameserver_ip('non.existing.nameserver') raises
    UnableToResolveNameServerException
    '''
    dzt = DnsZoneTest('example.com', 'example.com', 'non.existing.nameserver')
    with pytest.raises(UnableToResolveNameServerException):
        dzt.get_nameserver_ip()
예제 #4
0
def test_get_nameserver_ip_raises_UnableToResolveNameServerException():
    '''
    test if get_nameserver_ip('non.existing.nameserver') raises
    UnableToResolveNameServerException
    '''
    dzt = DnsZoneTest('example.com', 'example.com', 'non.existing.nameserver')
    with pytest.raises(UnableToResolveNameServerException):
        dzt.get_nameserver_ip()
예제 #5
0
def test_dzt_get_zone_from_file_raises_NoZoneFileException():
    dzt = DnsZoneTest('example.com', '/path/to/non/existing/zone/file')
    with pytest.raises(NoZoneFileException):
        dzt.get_zone_from_file()
예제 #6
0
def dzt_ns(zonefile):
    '''
    DnsZoneTest instance with given nameserver.
    '''
    return DnsZoneTest('example.com', zonefile,
                       'google-public-dns-a.google.com')
예제 #7
0
def dzt(zonefile):
    '''
    DnsZoneTest instance with no given nameserver.
    '''
    return DnsZoneTest('example.com', zonefile)
예제 #8
0
def test_dzt_get_zone_from_file_raises_NoZoneFileException():
    dzt = DnsZoneTest('example.com', '/path/to/non/existing/zone/file')
    with pytest.raises(NoZoneFileException):
        dzt.get_zone_from_file()