Example #1
0
def test_bad_lookup_record_2():
	try:
		import DNS
	except ImportError:
		pytest.skip("PyDNS not installed.")
	
	mock = DomainValidator()
	
	with pytest.raises(RuntimeError):
		mock.lookup_domain('example.com', 'cname')
Example #2
0
def test_bad_lookup_record_2():
    try:
        import DNS
    except ImportError:
        pytest.skip("PyDNS not installed.")

    mock = DomainValidator()

    with pytest.raises(RuntimeError):
        mock.lookup_domain('example.com', 'cname')
Example #3
0
def test_domain_lookup():
    try:
        import DNS
    except ImportError:
        pytest.skip("PyDNS not installed.")

    mock = DomainValidator()
    dataset = [
        ('gothcandy.com', 'a', '174.129.236.35'),
        ('a' * 64 + '.gothcandy.com', 'a', False),
        ('gothcandy.com', 'mx', [(10, 'mx1.emailsrvr.com'),
                                 (20, 'mx2.emailsrvr.com')]),
        ('nx.example.com', 'a', False),
        ('xn--ls8h.la', 'a', '38.103.165.13'),  # IDN: (poop).la
    ]

    def closure(domain, kind, expect):
        try:
            assert mock.lookup_domain(domain, kind,
                                      server=['8.8.8.8']) == expect
        except DNS.DNSError:
            pytest.skip("Skipped due to DNS error.")

    for domain, kind, expect in dataset:
        yield closure, domain, kind, expect
Example #4
0
def test_domain_validation():
    try:
        import DNS
    except ImportError:
        pytest.skip("PyDNS not installed.")

    mock = DomainValidator(lookup_dns='mx')
    dataset = [
        ('example.com', 'Domain does not seem to exist.'),
        # TODO This domain is always erroring out, please do something
        # ('xn--ls8h.la', ''), # IDN: (poop).la
        ('', 'Invalid domain: It cannot be empty.'),
        ('-bad.example.com', 'Invalid domain.'),
        ('gothcandy.com', ''),
        ('a' * 64 + '.gothcandy.com', 'Domain does not seem to exist.'),
        ('gothcandy.com', ''),
        ('nx.example.com', 'Domain does not seem to exist.'),
    ]

    def closure(domain, expect):
        try:
            assert mock.validate_domain(domain) == (domain, expect)
        except DNS.DNSError:
            pytest.skip("Skipped due to DNS error.")

    for domain, expect in dataset:
        yield closure, domain, expect
Example #5
0
def test_bad_lookup_record_1():
    try:
        import DNS
    except ImportError:
        pytest.skip("PyDNS not installed.")

    with pytest.raises(RuntimeError):
        DomainValidator(lookup_dns='cname')
Example #6
0
def test_common_rules_fixed():
    mock = DomainValidator(fix=True)
    dataset = [
        ('*****@*****.**', ('*****@*****.**', '')),
        ('[email protected].', ('*****@*****.**', '')),
    ]

    def closure(address, expect):
        eq_(mock._apply_common_rules(address, 255), expect)

    for address, expect in dataset:
        yield closure, address, expect
Example #7
0
def test_domain_validation_basic():
    mock = DomainValidator()
    dataset = [
        ('example.com', ''),
        ('xn--ls8h.la', ''),  # IDN: (poop).la
        ('', 'Invalid domain: It cannot be empty.'),
        ('-bad.example.com', 'Invalid domain.'),
    ]

    def closure(domain, expect):
        eq_(mock.validate_domain(domain), (domain, expect))

    for domain, expect in dataset:
        yield closure, domain, expect
Example #8
0
def test_common_rules():
    mock = DomainValidator()
    dataset = [
        ('*****@*****.**', ''),
        ('', 'It cannot be empty.'),
        ('*' * 256, 'It cannot be longer than 255 chars.'),
        ('*****@*****.**', 'It cannot start with a dot.'),
        ('[email protected].', 'It cannot end with a dot.'),
        ('*****@*****.**', 'It cannot contain consecutive dots.'),
    ]

    def closure(address, expect):
        eq_(mock._apply_common_rules(address, 255), (address, expect))

    for address, expect in dataset:
        yield closure, address, expect
Example #9
0
def test_common_rules_fixed():
    try:
        import DNS
    except ImportError:
        pytest.skip("PyDNS not installed.")

    mock = DomainValidator(fix=True)
    dataset = [
        ('*****@*****.**', ('*****@*****.**', '')),
        ('[email protected].', ('*****@*****.**', '')),
    ]

    def closure(address, expect):
        assert mock._apply_common_rules(address, 255) == expect

    for address, expect in dataset:
        yield closure, address, expect
Example #10
0
def test_domain_lookup():
    mock = DomainValidator()
    dataset = [
        ('gothcandy.com', 'a', '174.129.236.35'),
        ('a' * 64 + '.gothcandy.com', 'a', False),
        ('gothcandy.com', 'mx', [(10, 'mx1.emailsrvr.com'),
                                 (20, 'mx2.emailsrvr.com')]),
        ('nx.example.com', 'a', False),
        ('xn--ls8h.la', 'a', '38.103.165.5'),  # IDN: (poop).la
    ]

    def closure(domain, kind, expect):
        try:
            eq_(mock.lookup_domain(domain, kind, server=['8.8.8.8']), expect)
        except DNS.DNSError:
            raise SkipTest("Skipped due to DNS error.")

    for domain, kind, expect in dataset:
        yield closure, domain, kind, expect
Example #11
0
def test_domain_validation_basic():
    try:
        import DNS
    except ImportError:
        pytest.skip("PyDNS not installed.")

    mock = DomainValidator()
    dataset = [
        ('example.com', ''),
        ('xn--ls8h.la', ''),  # IDN: (poop).la
        ('', 'Invalid domain: It cannot be empty.'),
        ('-bad.example.com', 'Invalid domain.'),
    ]

    def closure(domain, expect):
        assert mock.validate_domain(domain) == (domain, expect)

    for domain, expect in dataset:
        yield closure, domain, expect
Example #12
0
def test_domain_validation():
    mock = DomainValidator(lookup_dns='mx')
    dataset = [
        ('example.com', 'Domain does not seem to exist.'),
        ('xn--ls8h.la', ''),  # IDN: (poop).la
        ('', 'Invalid domain: It cannot be empty.'),
        ('-bad.example.com', 'Invalid domain.'),
        ('gothcandy.com', ''),
        ('a' * 64 + '.gothcandy.com', 'Domain does not seem to exist.'),
        ('gothcandy.com', ''),
        ('nx.example.com', 'Domain does not seem to exist.'),
    ]

    def closure(domain, expect):
        try:
            eq_(mock.validate_domain(domain), (domain, expect))
        except DNS.DNSError:
            raise SkipTest("Skipped due to DNS error.")

    for domain, expect in dataset:
        yield closure, domain, expect
Example #13
0
def test_common_rules():
    try:
        import DNS
    except ImportError:
        pytest.skip("PyDNS not installed.")

    mock = DomainValidator()
    dataset = [
        ('*****@*****.**', ''),
        ('', 'It cannot be empty.'),
        ('*' * 256, 'It cannot be longer than 255 chars.'),
        ('*****@*****.**', 'It cannot start with a dot.'),
        ('[email protected].', 'It cannot end with a dot.'),
        ('*****@*****.**', 'It cannot contain consecutive dots.'),
    ]

    def closure(address, expect):
        assert mock._apply_common_rules(address, 255) == (address, expect)

    for address, expect in dataset:
        yield closure, address, expect
Example #14
0
def test_bad_lookup_record_2():
    mock = DomainValidator()
    mock.lookup_domain('example.com', 'cname')
Example #15
0
def test_bad_lookup_record_1():
    mock = DomainValidator(lookup_dns='cname')
def test_bad_lookup_record_2():
    mock = DomainValidator()
    mock.lookup_domain('example.com', 'cname')