0001-api-extend-api-users-value-to-also-look-within-name-.patch
tests/test_api.py | ||
---|---|---|
506 | 506 |
assert [x.get('id') for x in resp.json['roles']['concerned']] == [str(role.id), str(another_role.id)] |
507 | 507 |
assert [x.get('id') for x in resp.json['roles']['actions']] == [str(role.id)] |
508 | 508 | |
509 |
def test_user_by_nameid(pub, local_user): |
|
510 |
resp = get_app(pub).get(sign_uri('/api/users/xyz/', user=local_user), |
|
511 |
status=404) |
|
512 |
local_user.name_identifiers = ['xyz'] |
|
513 |
local_user.store() |
|
514 |
resp = get_app(pub).get(sign_uri('/api/users/xyz/', user=local_user)) |
|
515 |
assert str(resp.json['id']) == str(local_user.id) |
|
516 | ||
509 | 517 |
def test_user_forms(pub, local_user): |
510 | 518 |
FormDef.wipe() |
511 | 519 |
formdef = FormDef() |
wcs/api.py | ||
---|---|---|
412 | 412 |
raise AccessForbiddenError('no user specified') |
413 | 413 |
user_info = user.get_substitution_variables(prefix='') |
414 | 414 |
del user_info['user'] |
415 |
user_info['id'] = user.id |
|
415 | 416 |
user_info['user_roles'] = [ |
416 | 417 |
Role.get(x).get_json_export_dict() for x in user.roles or []] |
417 | 418 |
return json.dumps(user_info) |
... | ... | |
537 | 538 |
if not (is_url_signed() or ( |
538 | 539 |
get_request().user and get_request().user.can_go_in_admin())): |
539 | 540 |
raise AccessForbiddenError() |
540 |
return ApiUserDirectory(get_publisher().user_class.get(component)) |
|
541 |
user_class = get_publisher().user_class |
|
542 |
try: |
|
543 |
user = user_class.get(component) |
|
544 |
except KeyError: |
|
545 |
try: |
|
546 |
user = user_class.get_users_with_name_identifier(component)[0] |
|
547 |
except IndexError: |
|
548 |
raise TraversalError() |
|
549 |
return ApiUserDirectory(user) |
|
541 | 550 | |
542 | 551 | |
543 | 552 |
class ApiDirectory(Directory): |
wcs/sql.py | ||
---|---|---|
758 | 758 |
return None |
759 | 759 |
else: |
760 | 760 |
raise KeyError() |
761 |
try: |
|
762 |
# id in SQL are always integers, don't even look in the |
|
763 |
# database if asked for something else. |
|
764 |
int(id) |
|
765 |
except ValueError: |
|
766 |
raise KeyError() |
|
761 | 767 |
conn, cur = get_connection_and_cursor() |
762 | 768 | |
763 | 769 |
sql_statement = '''SELECT %s |
764 |
- |