This repository has been archived by the owner on Aug 9, 2023. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from mozilla/add_tests_for_target
Add tests for Target class
- Loading branch information
Showing
1 changed file
with
45 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import sys | ||
import pytest | ||
import os | ||
import json | ||
from lib.target import Target | ||
|
||
|
||
class TestTarget(): | ||
def test_null_validity(self): | ||
target = Target(None) | ||
assert target.isValid() is False | ||
|
||
def test_loopback_validity(self): | ||
target = Target("127.0.0.1") | ||
assert target.isValid() is False | ||
|
||
def test_magic_url_validity(self): | ||
target = Target("169.254.169.254") | ||
assert target.isValid() is False | ||
|
||
def test_private_addresses(self): | ||
target = Target("192.167.1.1") | ||
assert target.isValid() is True | ||
target = Target("192.168.1.1") | ||
assert target.isValid() is False | ||
target = Target("192.169.1.1") | ||
assert target.isValid() is True | ||
target = Target("10.0.0.0.1") | ||
assert target.isValid() is False | ||
target = Target("172.16.0.0.1") | ||
assert target.isValid() is False | ||
|
||
def test_resolves_validity(self): | ||
target = Target("ssh.mozilla.com") | ||
assert target.isValid() is True | ||
target = Target("notarealdomainname.mozilla.com") | ||
assert target.isValid() is False | ||
target = Target(u"notarealdomainname.mozilla.com") | ||
assert target.isValid() is False | ||
target = Target("ssh.mozilla.com") | ||
assert target.isValid() is True | ||
target = Target(u'ssh.mozilla.com') | ||
assert target.isValid() is True | ||
target = Target("github.com") | ||
assert target.isValid() is True |