From 7ad74431dc47bf326256be39682eeca48c2cd952 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A1=D0=BA=D0=BE=D0=B2=D0=BE=D1=80=D0=BE=D0=B4=D0=B0=20?= =?UTF-8?q?=D0=9D=D0=B8=D0=BA=D0=B8=D1=82=D0=B0=20=D0=90=D0=BD=D0=B4=D1=80?= =?UTF-8?q?=D0=B5=D0=B5=D0=B2=D0=B8=D1=87?= Date: Fri, 12 Jun 2020 09:33:11 +0300 Subject: [PATCH] Extend email format tests Before this, a simple /@/ check passed this format test. This now extends the test a bit more, to check 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 in the local part This should trigger most of the naive implementations (e.g. /@/) and is still not hard to implement as it doesn't include quoted strings support. JSON Schema uses RFC 5322. Refs: https://tools.ietf.org/html/rfc5322#page-17 Refs: https://tools.ietf.org/html/rfc5322#page-12 --- tests/draft2019-09/optional/format/email.json | 35 +++++++++++++++++++ tests/draft3/optional/format/email.json | 35 +++++++++++++++++++ tests/draft4/optional/format/email.json | 35 +++++++++++++++++++ tests/draft6/optional/format/email.json | 35 +++++++++++++++++++ tests/draft7/optional/format/email.json | 35 +++++++++++++++++++ 5 files changed, 175 insertions(+) diff --git a/tests/draft2019-09/optional/format/email.json b/tests/draft2019-09/optional/format/email.json index c837c84b..02396d26 100644 --- a/tests/draft2019-09/optional/format/email.json +++ b/tests/draft2019-09/optional/format/email.json @@ -12,6 +12,41 @@ "description": "an invalid e-mail address", "data": "2962", "valid": false + }, + { + "description": "tilde in local part is valid", + "data": "te~st@example.com", + "valid": true + }, + { + "description": "tilde before local part is valid", + "data": "~test@example.com", + "valid": true + }, + { + "description": "tilde after local part is valid", + "data": "test~@example.com", + "valid": true + }, + { + "description": "dot before local part is not valid", + "data": ".test@example.com", + "valid": false + }, + { + "description": "dot after local part is not valid", + "data": "test.@example.com", + "valid": false + }, + { + "description": "two separated dots inside local part are valid", + "data": "te.s.t@example.com", + "valid": true + }, + { + "description": "two subsequent dots inside local part are not valid", + "data": "te..st@example.com", + "valid": false } ] } diff --git a/tests/draft3/optional/format/email.json b/tests/draft3/optional/format/email.json index c837c84b..02396d26 100644 --- a/tests/draft3/optional/format/email.json +++ b/tests/draft3/optional/format/email.json @@ -12,6 +12,41 @@ "description": "an invalid e-mail address", "data": "2962", "valid": false + }, + { + "description": "tilde in local part is valid", + "data": "te~st@example.com", + "valid": true + }, + { + "description": "tilde before local part is valid", + "data": "~test@example.com", + "valid": true + }, + { + "description": "tilde after local part is valid", + "data": "test~@example.com", + "valid": true + }, + { + "description": "dot before local part is not valid", + "data": ".test@example.com", + "valid": false + }, + { + "description": "dot after local part is not valid", + "data": "test.@example.com", + "valid": false + }, + { + "description": "two separated dots inside local part are valid", + "data": "te.s.t@example.com", + "valid": true + }, + { + "description": "two subsequent dots inside local part are not valid", + "data": "te..st@example.com", + "valid": false } ] } diff --git a/tests/draft4/optional/format/email.json b/tests/draft4/optional/format/email.json index c837c84b..02396d26 100644 --- a/tests/draft4/optional/format/email.json +++ b/tests/draft4/optional/format/email.json @@ -12,6 +12,41 @@ "description": "an invalid e-mail address", "data": "2962", "valid": false + }, + { + "description": "tilde in local part is valid", + "data": "te~st@example.com", + "valid": true + }, + { + "description": "tilde before local part is valid", + "data": "~test@example.com", + "valid": true + }, + { + "description": "tilde after local part is valid", + "data": "test~@example.com", + "valid": true + }, + { + "description": "dot before local part is not valid", + "data": ".test@example.com", + "valid": false + }, + { + "description": "dot after local part is not valid", + "data": "test.@example.com", + "valid": false + }, + { + "description": "two separated dots inside local part are valid", + "data": "te.s.t@example.com", + "valid": true + }, + { + "description": "two subsequent dots inside local part are not valid", + "data": "te..st@example.com", + "valid": false } ] } diff --git a/tests/draft6/optional/format/email.json b/tests/draft6/optional/format/email.json index c837c84b..02396d26 100644 --- a/tests/draft6/optional/format/email.json +++ b/tests/draft6/optional/format/email.json @@ -12,6 +12,41 @@ "description": "an invalid e-mail address", "data": "2962", "valid": false + }, + { + "description": "tilde in local part is valid", + "data": "te~st@example.com", + "valid": true + }, + { + "description": "tilde before local part is valid", + "data": "~test@example.com", + "valid": true + }, + { + "description": "tilde after local part is valid", + "data": "test~@example.com", + "valid": true + }, + { + "description": "dot before local part is not valid", + "data": ".test@example.com", + "valid": false + }, + { + "description": "dot after local part is not valid", + "data": "test.@example.com", + "valid": false + }, + { + "description": "two separated dots inside local part are valid", + "data": "te.s.t@example.com", + "valid": true + }, + { + "description": "two subsequent dots inside local part are not valid", + "data": "te..st@example.com", + "valid": false } ] } diff --git a/tests/draft7/optional/format/email.json b/tests/draft7/optional/format/email.json index c837c84b..02396d26 100644 --- a/tests/draft7/optional/format/email.json +++ b/tests/draft7/optional/format/email.json @@ -12,6 +12,41 @@ "description": "an invalid e-mail address", "data": "2962", "valid": false + }, + { + "description": "tilde in local part is valid", + "data": "te~st@example.com", + "valid": true + }, + { + "description": "tilde before local part is valid", + "data": "~test@example.com", + "valid": true + }, + { + "description": "tilde after local part is valid", + "data": "test~@example.com", + "valid": true + }, + { + "description": "dot before local part is not valid", + "data": ".test@example.com", + "valid": false + }, + { + "description": "dot after local part is not valid", + "data": "test.@example.com", + "valid": false + }, + { + "description": "two separated dots inside local part are valid", + "data": "te.s.t@example.com", + "valid": true + }, + { + "description": "two subsequent dots inside local part are not valid", + "data": "te..st@example.com", + "valid": false } ] }