summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZuul <zuul@review.opendev.org>2022-06-03 05:43:01 +0000
committerGerrit Code Review <review@openstack.org>2022-06-03 05:43:01 +0000
commit95bfb28926f388eeebaf8404fc057bb832b55559 (patch)
tree304a6fe422587ec379e48b48e9002db6a2081a0c
parent478a6a3dc9e063f098ff2efe8ad4c1c7d7d286db (diff)
parent4e6da9b9021466ddd2ee9eb9bcce2cf5a0d5fac7 (diff)
downloaddesignate-95bfb28926f388eeebaf8404fc057bb832b55559.tar.gz
Merge "Improve wording for validation error messages" into stable/xena
-rw-r--r--designate/objects/fields.py29
-rw-r--r--designate/tests/unit/objects/test_caa_object.py10
2 files changed, 20 insertions, 19 deletions
diff --git a/designate/objects/fields.py b/designate/objects/fields.py
index dd3268c8..cda9efcc 100644
--- a/designate/objects/fields.py
+++ b/designate/objects/fields.py
@@ -206,9 +206,9 @@ class DomainField(StringFields):
if len(host) > 63:
raise ValueError("Host %s is too long" % host)
if not value.endswith('.'):
- raise ValueError("Domain %s is not end with a dot" % value)
+ raise ValueError("Domain %s does not end with a dot" % value)
if not re.match(self.RE_ZONENAME, value):
- raise ValueError("Domain %s is not match" % value)
+ raise ValueError("Domain %s is invalid" % value)
return value
@@ -222,7 +222,7 @@ class EmailField(StringFields):
raise ValueError("%s is not an email" % value)
email = value.replace('@', '.')
if not re.match(self.RE_ZONENAME, "%s." % email):
- raise ValueError("Email %s is not match" % value)
+ raise ValueError("Email %s is invalid" % value)
return value
@@ -239,9 +239,9 @@ class HostField(StringFields):
if len(host) > 63:
raise ValueError("Host %s is too long" % host)
if value.endswith('.') is False:
- raise ValueError("Host name %s is not end with a dot" % value)
+ raise ValueError("Host name %s does not end with a dot" % value)
if not re.match(self.RE_HOSTNAME, value):
- raise ValueError("Host name %s is not match" % value)
+ raise ValueError("Host name %s is invalid" % value)
return value
@@ -258,7 +258,7 @@ class SRVField(StringFields):
if len(host) > 63:
raise ValueError("Host %s is too long" % host)
if value.endswith('.') is False:
- raise ValueError("Host name %s is not end with a dot" % value)
+ raise ValueError("Host name %s does not end with a dot" % value)
if not re.match(self.RE_SRV_HOST_NAME, value):
raise ValueError("Host name %s is not a SRV record" % value)
return value
@@ -293,7 +293,7 @@ class TldField(StringFields):
def coerce(self, obj, attr, value):
value = super(TldField, self).coerce(obj, attr, value)
if not re.match(self.RE_TLDNAME, value):
- raise ValueError("%s is not an TLD" % value)
+ raise ValueError("%s is not a TLD" % value)
return value
@@ -321,7 +321,7 @@ class NaptrServiceField(StringFields):
raise ValueError("NAPTR record service field cannot be longer than"
" 255 characters" % value)
if not re.match(self.RE_NAPTR_SERVICE, "%s" % value):
- raise ValueError("%s NAPTR record service does not match" % value)
+ raise ValueError("%s NAPTR record service is invalid" % value)
return value
@@ -336,7 +336,7 @@ class NaptrRegexpField(StringFields):
" 255 characters" % value)
if value:
if not re.match(self.RE_NAPTR_REGEXP, "%s" % value):
- raise ValueError("%s is not a NAPTR record regexp" % value)
+ raise ValueError("%s NAPTR record is invalid" % value)
return value
@@ -358,10 +358,11 @@ class CaaPropertyField(StringFields):
raise ValueError("Host %s is too long" % host)
idn_with_dot = idn + '.'
if not re.match(self.RE_ZONENAME, idn_with_dot):
- raise ValueError("Domain %s does not match" % idn)
+ raise ValueError("Domain %s is invalid" % idn)
for entry in entries:
if not re.match(self.RE_KVP, entry):
- raise ValueError("%s is not valid key-value pair" % entry)
+ raise ValueError("%s is not a valid key-value pair" %
+ entry)
elif tag == 'iodef':
if re.match(self.RE_URL_MAIL, val):
parts = val.split('@')
@@ -372,7 +373,7 @@ class CaaPropertyField(StringFields):
raise ValueError("Host %s is too long" % host)
idn_with_dot = idn + '.'
if not re.match(self.RE_ZONENAME, idn_with_dot):
- raise ValueError("Domain %s does not match" % idn)
+ raise ValueError("Domain %s is invalid" % idn)
elif re.match(self.RE_URL_HTTP, val):
parts = val.split('/')
idn = parts[2]
@@ -382,9 +383,9 @@ class CaaPropertyField(StringFields):
raise ValueError("Host %s is too long" % host)
idn_with_dot = idn + '.'
if not re.match(self.RE_ZONENAME, idn_with_dot):
- raise ValueError("Domain %s does not match" % idn)
+ raise ValueError("Domain %s is invalid" % idn)
else:
- raise ValueError("%s is not valid URL" % val)
+ raise ValueError("%s is not a valid URL" % val)
else:
raise ValueError("Property tag %s must be 'issue', 'issuewild'"
" or 'iodef'" % value)
diff --git a/designate/tests/unit/objects/test_caa_object.py b/designate/tests/unit/objects/test_caa_object.py
index 877ffb25..023944bf 100644
--- a/designate/tests/unit/objects/test_caa_object.py
+++ b/designate/tests/unit/objects/test_caa_object.py
@@ -72,7 +72,7 @@ class CAARecordTest(oslotest.base.BaseTestCase):
caa_record = objects.CAA()
self.assertRaisesRegex(
ValueError,
- 'Domain abc. does not match',
+ 'Domain abc. is invalid',
caa_record._from_string, '0 issue abc.'
)
@@ -80,7 +80,7 @@ class CAARecordTest(oslotest.base.BaseTestCase):
caa_record = objects.CAA()
self.assertRaisesRegex(
ValueError,
- 'def is not valid key-value pair',
+ 'def is not a valid key-value pair',
caa_record._from_string, '0 issue abc;def'
)
@@ -98,7 +98,7 @@ class CAARecordTest(oslotest.base.BaseTestCase):
caa_record = objects.CAA()
self.assertRaisesRegex(
ValueError,
- 'Domain example.net. does not match',
+ 'Domain example.net. is invalid',
caa_record._from_string, '0 iodef mailto:me@example.net.'
)
@@ -116,7 +116,7 @@ class CAARecordTest(oslotest.base.BaseTestCase):
caa_record = objects.CAA()
self.assertRaisesRegex(
ValueError,
- 'Domain example.net. does not match',
+ 'Domain example.net. is invalid',
caa_record._from_string, '0 iodef https://example.net./'
)
@@ -124,6 +124,6 @@ class CAARecordTest(oslotest.base.BaseTestCase):
caa_record = objects.CAA()
self.assertRaisesRegex(
ValueError,
- 'https:// is not valid URL',
+ 'https:// is not a valid URL',
caa_record._from_string, '0 iodef https://'
)