diff options
author | Zuul <zuul@review.opendev.org> | 2022-06-03 00:13:54 +0000 |
---|---|---|
committer | Gerrit Code Review <review@openstack.org> | 2022-06-03 00:13:54 +0000 |
commit | 63af2e0eb5de12a7927e74f126c9fbe1e6f3e0b8 (patch) | |
tree | d69b5a582eb5d5b32276ede95b8b03814764422c | |
parent | d98eafed3548361b9b453f9b3441a5fb58650b9a (diff) | |
parent | 1eb5cb418451d20809b4f009db8821861a61566a (diff) | |
download | designate-63af2e0eb5de12a7927e74f126c9fbe1e6f3e0b8.tar.gz |
Merge "Improve wording for validation error messages" into stable/wallaby
-rw-r--r-- | designate/objects/fields.py | 29 | ||||
-rw-r--r-- | designate/tests/unit/objects/test_caa_object.py | 10 |
2 files changed, 20 insertions, 19 deletions
diff --git a/designate/objects/fields.py b/designate/objects/fields.py index 19a52c0d..b9721958 100644 --- a/designate/objects/fields.py +++ b/designate/objects/fields.py @@ -204,9 +204,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 @@ -220,7 +220,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 @@ -237,9 +237,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 @@ -256,7 +256,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 @@ -291,7 +291,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 @@ -319,7 +319,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 @@ -334,7 +334,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 @@ -356,10 +356,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('@') @@ -370,7 +371,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] @@ -380,9 +381,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://' ) |