Skip to content

Commit c857051

Browse files
committed
Extend email format tests
Before this, a simple /@/ check passed this format test. This now extends the test a bit more, to check that obviously invalid domains are rejected, and that local part is checked at least for something. Symbol check + dot position check is a good indication here, because: 1) It's common and doesn't need implementing complex quotes logic 2) Dot is the only symbol which validity depends on the position Refs: https://tools.ietf.org/html/rfc5322#page-17 Refs: https://tools.ietf.org/html/rfc5322#page-12
1 parent 1f34d33 commit c857051

File tree

5 files changed

+250
-0
lines changed

5 files changed

+250
-0
lines changed

tests/draft2019-09/optional/format/email.json

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,56 @@
1212
"description": "an invalid e-mail address",
1313
"data": "2962",
1414
"valid": false
15+
},
16+
{
17+
"description": "localhost email is valid",
18+
"data": "root@localhost",
19+
"valid": true
20+
},
21+
{
22+
"description": "tilda in local part is valid",
23+
"data": "te~st@example.com",
24+
"valid": true
25+
},
26+
{
27+
"description": "tilda before local part is valid",
28+
"data": "~test@example.com",
29+
"valid": true
30+
},
31+
{
32+
"description": "tilda after local part is valid",
33+
"data": "test~@example.com",
34+
"valid": true
35+
},
36+
{
37+
"description": "dot before local part is not valid",
38+
"data": ".test@example.com",
39+
"valid": false
40+
},
41+
{
42+
"description": "dot after local part is not valid",
43+
"data": "test.@example.com",
44+
"valid": false
45+
},
46+
{
47+
"description": "two separated dots dots inside local part are valid",
48+
"data": "te.s.t@example.com",
49+
"valid": true
50+
},
51+
{
52+
"description": "two subsequent dots inside local part are not valid",
53+
"data": "te..st@example.com",
54+
"valid": false
55+
},
56+
{
57+
"description": "space in domain is not valid",
58+
"data": "test@example .com",
59+
"valid": false
60+
},
61+
{
62+
"description": "symbol in domain is not valid",
63+
"data": "test@example&.com",
64+
"valid": false
1565
}
1666
]
1767
}

tests/draft3/optional/format/email.json

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,56 @@
1212
"description": "an invalid e-mail address",
1313
"data": "2962",
1414
"valid": false
15+
},
16+
{
17+
"description": "localhost email is valid",
18+
"data": "root@localhost",
19+
"valid": true
20+
},
21+
{
22+
"description": "tilda in local part is valid",
23+
"data": "te~st@example.com",
24+
"valid": true
25+
},
26+
{
27+
"description": "tilda before local part is valid",
28+
"data": "~test@example.com",
29+
"valid": true
30+
},
31+
{
32+
"description": "tilda after local part is valid",
33+
"data": "test~@example.com",
34+
"valid": true
35+
},
36+
{
37+
"description": "dot before local part is not valid",
38+
"data": ".test@example.com",
39+
"valid": false
40+
},
41+
{
42+
"description": "dot after local part is not valid",
43+
"data": "test.@example.com",
44+
"valid": false
45+
},
46+
{
47+
"description": "two separated dots inside local part are valid",
48+
"data": "te.s.t@example.com",
49+
"valid": true
50+
},
51+
{
52+
"description": "two subsequent dots inside local part are not valid",
53+
"data": "te..st@example.com",
54+
"valid": false
55+
},
56+
{
57+
"description": "space in domain is not valid",
58+
"data": "test@example .com",
59+
"valid": false
60+
},
61+
{
62+
"description": "symbol in domain is not valid",
63+
"data": "test@example&.com",
64+
"valid": false
1565
}
1666
]
1767
}

tests/draft4/optional/format/email.json

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,56 @@
1212
"description": "an invalid e-mail address",
1313
"data": "2962",
1414
"valid": false
15+
},
16+
{
17+
"description": "localhost email is valid",
18+
"data": "root@localhost",
19+
"valid": true
20+
},
21+
{
22+
"description": "tilda in local part is valid",
23+
"data": "te~st@example.com",
24+
"valid": true
25+
},
26+
{
27+
"description": "tilda before local part is valid",
28+
"data": "~test@example.com",
29+
"valid": true
30+
},
31+
{
32+
"description": "tilda after local part is valid",
33+
"data": "test~@example.com",
34+
"valid": true
35+
},
36+
{
37+
"description": "dot before local part is not valid",
38+
"data": ".test@example.com",
39+
"valid": false
40+
},
41+
{
42+
"description": "dot after local part is not valid",
43+
"data": "test.@example.com",
44+
"valid": false
45+
},
46+
{
47+
"description": "two separated dots inside local part are valid",
48+
"data": "te.s.t@example.com",
49+
"valid": true
50+
},
51+
{
52+
"description": "two subsequent dots inside local part are not valid",
53+
"data": "te..st@example.com",
54+
"valid": false
55+
},
56+
{
57+
"description": "space in domain is not valid",
58+
"data": "test@example .com",
59+
"valid": false
60+
},
61+
{
62+
"description": "symbol in domain is not valid",
63+
"data": "test@example&.com",
64+
"valid": false
1565
}
1666
]
1767
}

tests/draft6/optional/format/email.json

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,56 @@
1212
"description": "an invalid e-mail address",
1313
"data": "2962",
1414
"valid": false
15+
},
16+
{
17+
"description": "localhost email is valid",
18+
"data": "root@localhost",
19+
"valid": true
20+
},
21+
{
22+
"description": "tilda in local part is valid",
23+
"data": "te~st@example.com",
24+
"valid": true
25+
},
26+
{
27+
"description": "tilda before local part is valid",
28+
"data": "~test@example.com",
29+
"valid": true
30+
},
31+
{
32+
"description": "tilda after local part is valid",
33+
"data": "test~@example.com",
34+
"valid": true
35+
},
36+
{
37+
"description": "dot before local part is not valid",
38+
"data": ".test@example.com",
39+
"valid": false
40+
},
41+
{
42+
"description": "dot after local part is not valid",
43+
"data": "test.@example.com",
44+
"valid": false
45+
},
46+
{
47+
"description": "two separated dots inside local part are valid",
48+
"data": "te.s.t@example.com",
49+
"valid": true
50+
},
51+
{
52+
"description": "two subsequent dots inside local part are not valid",
53+
"data": "te..st@example.com",
54+
"valid": false
55+
},
56+
{
57+
"description": "space in domain is not valid",
58+
"data": "test@example .com",
59+
"valid": false
60+
},
61+
{
62+
"description": "symbol in domain is not valid",
63+
"data": "test@example&.com",
64+
"valid": false
1565
}
1666
]
1767
}

tests/draft7/optional/format/email.json

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,56 @@
1212
"description": "an invalid e-mail address",
1313
"data": "2962",
1414
"valid": false
15+
},
16+
{
17+
"description": "localhost email is valid",
18+
"data": "root@localhost",
19+
"valid": true
20+
},
21+
{
22+
"description": "tilda in local part is valid",
23+
"data": "te~st@example.com",
24+
"valid": true
25+
},
26+
{
27+
"description": "tilda before local part is valid",
28+
"data": "~test@example.com",
29+
"valid": true
30+
},
31+
{
32+
"description": "tilda after local part is valid",
33+
"data": "test~@example.com",
34+
"valid": true
35+
},
36+
{
37+
"description": "dot before local part is not valid",
38+
"data": ".test@example.com",
39+
"valid": false
40+
},
41+
{
42+
"description": "dot after local part is not valid",
43+
"data": "test.@example.com",
44+
"valid": false
45+
},
46+
{
47+
"description": "two separated dots inside local part are valid",
48+
"data": "te.s.t@example.com",
49+
"valid": true
50+
},
51+
{
52+
"description": "two subsequent dots inside local part are not valid",
53+
"data": "te..st@example.com",
54+
"valid": false
55+
},
56+
{
57+
"description": "space in domain is not valid",
58+
"data": "test@example .com",
59+
"valid": false
60+
},
61+
{
62+
"description": "symbol in domain is not valid",
63+
"data": "test@example&.com",
64+
"valid": false
1565
}
1666
]
1767
}

0 commit comments

Comments
 (0)