custom_profile_fields: Clarify an external account error message.

This error message is for a very precise situation -- the pattern not
having the desired format. We should say that, rather than a generic
"Malformed".
This commit is contained in:
yogesh sirsat 2022-04-29 20:38:57 +05:30 committed by Tim Abbott
parent 6a5d646739
commit 08e8a21da0
2 changed files with 3 additions and 3 deletions

View File

@ -365,7 +365,7 @@ def check_external_account_url_pattern(var_name: str, val: object) -> str:
s = check_string(var_name, val) s = check_string(var_name, val)
if s.count("%(username)s") != 1: if s.count("%(username)s") != 1:
raise ValidationError(_("Malformed URL pattern.")) raise ValidationError(_("URL pattern must contain '%(username)s'."))
url_val = s.replace("%(username)s", "username") url_val = s.replace("%(username)s", "username")
check_url(var_name, url_val) check_url(var_name, url_val)

View File

@ -290,7 +290,7 @@ class CreateCustomProfileFieldTest(CustomProfileFieldTestCase):
} }
).decode() ).decode()
result = self.client_post("/json/realm/profile_fields", info=data) result = self.client_post("/json/realm/profile_fields", info=data)
self.assert_json_error(result, "Malformed URL pattern.") self.assert_json_error(result, "URL pattern must contain '%(username)s'.")
data["field_data"] = orjson.dumps( data["field_data"] = orjson.dumps(
{ {
@ -299,7 +299,7 @@ class CreateCustomProfileFieldTest(CustomProfileFieldTestCase):
} }
).decode() ).decode()
result = self.client_post("/json/realm/profile_fields", info=data) result = self.client_post("/json/realm/profile_fields", info=data)
self.assert_json_error(result, "Malformed URL pattern.") self.assert_json_error(result, "URL pattern must contain '%(username)s'.")
data["field_data"] = orjson.dumps( data["field_data"] = orjson.dumps(
{ {