FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
validators/tests/test_domain.py at master · python-validators/validators · GitHub
python-validators
validators
Repository navigation
Code
Issues
6
(6)
Pull requests
34
(34)
Discussions
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
validators
/
tests
/
test_domain.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
109 lines (99 loc) · 3.89 KB
Breadcrumbs
validators
/
tests
/
test_domain.py
Copy path
File metadata and controls
109 lines (99 loc) · 3.89 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
"""Test Domain."""
# external
import
pytest
# local
from
validators
import
ValidationError
,
domain
@
pytest
.
mark
.
parametrize
(
(
"value"
,
"rfc_1034"
,
"rfc_2782"
),
[
(
"example.com"
,
False
,
False
),
(
"exa_mple.com"
,
False
,
True
),
(
"xn----gtbspbbmkef.xn--p1ai"
,
False
,
False
),
(
"underscore_subdomain.example.com"
,
False
,
True
),
(
"something.versicherung"
,
False
,
False
),
(
"someThing.versicherung."
,
True
,
False
),
(
"11.com"
,
False
,
False
),
(
"3.cn."
,
True
,
False
),
(
"_example.com"
,
False
,
True
),
(
"example_.com"
,
False
,
True
),
(
"_exa_mple_.com"
,
False
,
True
),
(
"a.cn"
,
False
,
False
),
(
"sub1.sub2.sample.co.uk"
,
False
,
False
),
(
"somerandomexample.xn--fiqs8s"
,
False
,
False
),
(
"kräuter.com."
,
True
,
False
),
(
"über.com"
,
False
,
False
),
],
)
def
test_returns_true_on_valid_domain
(
value
:
str
,
rfc_1034
:
bool
,
rfc_2782
:
bool
):
"""Test returns true on valid domain."""
assert
domain
(
value
,
rfc_1034
=
rfc_1034
,
rfc_2782
=
rfc_2782
)
@
pytest
.
mark
.
parametrize
(
(
"value"
,
"consider_tld"
,
"rfc_1034"
,
"rfc_2782"
),
[
(
"example.com"
,
True
,
False
,
False
),
(
"exa_mple.com"
,
True
,
False
,
True
),
(
"xn----gtbspbbmkef.xn--p1ai"
,
True
,
False
,
False
),
(
"underscore_subdomain.example.com"
,
True
,
False
,
True
),
(
"someThing.versicherung."
,
True
,
True
,
False
),
(
"11.com"
,
True
,
False
,
False
),
(
"3.cn."
,
True
,
True
,
False
),
(
"_example.com"
,
True
,
False
,
True
),
(
"example_.com"
,
True
,
False
,
True
),
(
"somerandomexample.xn--fiqs8s"
,
True
,
False
,
False
),
(
"somerandomexample.onion"
,
True
,
False
,
False
),
],
)
def
test_returns_true_on_valid_top_level_domain
(
value
:
str
,
consider_tld
:
bool
,
rfc_1034
:
bool
,
rfc_2782
:
bool
):
"""Test returns true on valid top level domain."""
assert
domain
(
value
,
consider_tld
=
consider_tld
,
rfc_1034
=
rfc_1034
,
rfc_2782
=
rfc_2782
)
@
pytest
.
mark
.
parametrize
(
(
"value"
,
"rfc_1034"
,
"rfc_2782"
),
[
(
"example.com/."
,
True
,
False
),
(
"example.com:4444"
,
False
,
False
),
(
"example.-com"
,
False
,
False
),
(
"example."
,
False
,
False
),
(
"-example.com"
,
False
,
False
),
(
"example-.com."
,
True
,
False
),
(
"_example.com"
,
False
,
False
),
(
"_example._com"
,
False
,
False
),
(
"example_.com"
,
False
,
False
),
(
"example"
,
False
,
False
),
(
"example.com!"
,
True
,
False
),
(
"example?.com"
,
True
,
False
),
(
"__exa__mple__.com"
,
False
,
True
),
(
"a......b.com"
,
False
,
False
),
(
"a.123"
,
False
,
False
),
(
"123.123"
,
False
,
False
),
(
"123.123.123."
,
True
,
False
),
(
"123.123.123.123"
,
False
,
False
),
],
)
def
test_returns_failed_validation_on_invalid_domain
(
value
:
str
,
rfc_1034
:
bool
,
rfc_2782
:
bool
):
"""Test returns failed validation on invalid domain."""
assert
isinstance
(
domain
(
value
,
rfc_1034
=
rfc_1034
,
rfc_2782
=
rfc_2782
),
ValidationError
)
@
pytest
.
mark
.
parametrize
(
(
"value"
,
"consider_tld"
,
"rfc_1034"
,
"rfc_2782"
),
[
(
"example.266"
,
True
,
False
,
False
),
(
"exa_mple.org_"
,
True
,
False
,
True
),
(
"xn----gtbspbbmkef.xn-p1ai"
,
True
,
False
,
False
),
(
"underscore_subdomain.example.flat"
,
True
,
False
,
True
),
(
"someThing.versicherung.reddit."
,
True
,
True
,
False
),
(
"11.twitter"
,
True
,
False
,
False
),
(
"3.cnx."
,
True
,
True
,
False
),
(
"_example.#13"
,
True
,
False
,
True
),
(
"example_.fo-ul"
,
True
,
False
,
True
),
(
"somerandomexample.xn-n-fiqs8s"
,
True
,
False
,
False
),
],
)
def
test_returns_failed_validation_invalid_top_level_domain
(
value
:
str
,
consider_tld
:
bool
,
rfc_1034
:
bool
,
rfc_2782
:
bool
):
"""Test returns failed validation invalid top level domain."""
assert
isinstance
(
domain
(
value
,
consider_tld
=
consider_tld
,
rfc_1034
=
rfc_1034
,
rfc_2782
=
rfc_2782
),
ValidationError
,
)
Back
|
FazBrowse Home
|
New Git URL