Skip to content

Commit

Permalink
[#1392] more fixes from awful commit + tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kindly committed Dec 13, 2013
1 parent 146568a commit e376437
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 15 deletions.
16 changes: 1 addition & 15 deletions ckan/lib/dictization/model_dictize.py
Expand Up @@ -531,7 +531,7 @@ def user_dictize(user, context):
result_dict['apikey'] = apikey
result_dict['email'] = email

## this should not really really be needed but tests r it
## this should not really really be needed but tests need it
if new_authz.is_sysadmin(requester):
result_dict['apikey'] = apikey
result_dict['email'] = email
Expand Down Expand Up @@ -708,17 +708,3 @@ def user_following_group_dictize(follower, context):

base_columns = set(['id', 'resource_id', 'title', 'description',
'view_type', 'order', 'config'])

def resource_view_dictize(resource_view, context):
dictized = d.table_dictize(resource_view, context)
dictized.pop('order')
config = dictized.pop('config', {})
dictized.update(config)
return dictized

def resource_view_list_dictize(resource_views, context):
resource_view_dicts = []
for view in resource_views:
resource_view_dicts.append(resource_view_dictize(view, context))
return resource_view_dicts

42 changes: 42 additions & 0 deletions ckan/new_tests/logic/action/test_get.py
Expand Up @@ -147,6 +147,48 @@ def test_organization_show_private_packages_not_returned(self):
assert org_dict['packages'][0]['name'] == 'dataset_1'
assert org_dict['package_count'] == 1

def test_user_get(self):

user = factories.User()

## auth_ignored
got_user = helpers.call_action('user_show', id=user['id'])

assert 'password' not in got_user
assert 'reset_key' not in got_user
assert 'apikey' not in got_user
assert 'email' not in got_user

got_user = helpers.call_action('user_show',
context={'keep_email': True},
id=user['id'])

assert got_user['email'] == user['email']
assert 'apikey' not in got_user
assert 'password' not in got_user
assert 'reset_key' not in got_user

got_user = helpers.call_action('user_show',
context={'keep_apikey': True},
id=user['id'])


assert 'email' not in got_user
assert got_user['apikey'] == user['apikey']
assert 'password' not in got_user
assert 'reset_key' not in got_user

sysadmin = factories.User(sysadmin=True)

got_user = helpers.call_action('user_show',
context={'user': sysadmin['name']},
id=user['id'])

assert got_user['email'] == user['email']
assert got_user['apikey'] == user['apikey']
assert 'password' not in got_user
assert 'reset_key' not in got_user


class TestBadLimitQueryParameters(object):
'''test class for #1258 non-int query parameters cause 500 errors
Expand Down

0 comments on commit e376437

Please sign in to comment.