Skip to content
Snippets Groups Projects
Commit 5e6a6c72 authored by Daniel's avatar Daniel
Browse files

ENH: Added a better message for too simple passwords.

Is this enough for #7?

Also added documentation.
parent 03af96e6
No related branches found
No related tags found
No related merge requests found
......@@ -164,7 +164,9 @@ def _insert_user(name, password=None, status=None, email=None, entity=None, **kw
raise e
except ClientErrorException as e:
if e.status == 409:
e.msg = "User name is yet in use."
e.msg = "User name is already in use."
if e.status == 422:
e.msg = "Maybe the password does not match the required standard?"
raise e
......@@ -219,7 +221,6 @@ def _delete_role(name, **kwargs):
def _set_roles(username, roles, realm=None, **kwargs):
xml = etree.Element("Roles")
print(roles)
for r in roles:
xml.append(etree.Element("Role", name=r))
......@@ -262,6 +263,24 @@ def _get_roles(username, realm=None, **kwargs):
def _set_permissions(role, permission_rules, **kwargs):
"""Set permissions for a role.
Parameters
----------
role : str
The role for which the permissions are set.
permission_rules : iterable<PermissionRule>
An iterable with PermissionRule objects.
**kwargs :
Additional arguments which are passed to the HTTP request.
Returns
-------
None
"""
xml = etree.Element("PermissionRules")
for p in permission_rules:
xml.append(p._to_xml())
......@@ -291,6 +310,19 @@ def _get_permissions(role, **kwargs):
class PermissionRule():
"""Permission rules.
Parameters
----------
action : str
Either "grant" or "deny"
permission : str
For example "RETRIEVE:*".
priority : bool, optional
Whether the priority shall be set, defaults is False.
"""
@staticmethod
def _parse_boolean(bstr):
......
......@@ -382,7 +382,7 @@ def _handle_response_status(http_response):
"Request failed. The response returned with status "
"{}.".format(status))
elif 399 < status < 500:
raise ClientErrorException(msg=("Request failed. The response returned"
raise ClientErrorException(msg=("Request failed. The response returned "
"with status {}.").format(status), status=status, body=body)
elif status > 499:
raise ServerErrorException(body=body)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment