Skip to content

Commit

Permalink
[2939] add more testing
Browse files Browse the repository at this point in the history
  • Loading branch information
kindly committed Nov 14, 2012
1 parent e96d979 commit 5ea6c01
Showing 1 changed file with 32 additions and 3 deletions.
35 changes: 32 additions & 3 deletions ckan/tests/logic/test_auth.py
Expand Up @@ -104,24 +104,40 @@ def test_5_add_users_to_org(self):
'id': 'org_with_user'}
self._action_post('organization_member_create', member, 'admin')

## add disallowed editor.
user = {'name': 'editor_wannabe',
'password': 'pass',
'email': 'moo@moo.com'}
res = self._action_post('user_create', user, 'sysadmin')
self.apikeys['editor_wannabe'] = str(json.loads(res.body)['result']['apikey'])

## editor should not be able to approve others as editors
member = {'username': 'editor_wannabe',
'role': 'editor',
'id': 'org_with_user'}
self._action_post('organization_member_create', member, 'editor', 409)


def test_6_admin_add_datasets(self):

#org admin should be able to add dataset to group.
dataset = {'name': 'admin_dataset', 'owner_org': 'org_with_user'}
res = self._action_post('package_create', dataset, 'admin', 200)

#not able to add dataset to org admin does not belong to.
dataset = {'name': 'admin_dataset_bad', 'owner_org': 'org_no_user'}
res = self._action_post('package_create', dataset, 'admin', 409)

#no owner org
#admin not able to make dataset not owned by a group
dataset = {'name': 'admin_dataset_bad' }
res = self._action_post('package_create', dataset, 'admin', 409)

#non existant owner org
#not able to add org to not existant group
dataset = {'name': 'admin_dataset_bad', 'owner_org': 'org_not_exist' }
res = self._action_post('package_create', dataset, 'admin', 409)

def test_7_editor_add_datasets(self):

##same as admin
dataset = {'name': 'editor_dataset', 'owner_org': 'org_with_user'}
res = self._action_post('package_create', dataset, 'editor', 200)

Expand All @@ -136,3 +152,16 @@ def test_7_editor_add_datasets(self):
dataset = {'name': 'admin_dataset_bad', 'owner_org': 'org_not_exist' }
res = self._action_post('package_create', dataset, 'editor', 409)

def test_8_editor_update_datasets(self):

##editor should be able to update dataset
dataset = {'id': 'editor_dataset', 'title': 'test'}
res = self._action_post('package_update', dataset, 'editor', 200)

# editor tries to change owner org
dataset = {'id': 'editor_dataset', 'owner_org': 'org_no_user'}
res = self._action_post('package_update', dataset, 'editor', 403)

#non existant owner org
dataset = {'id': 'admin_dataset', 'owner_org': 'org_not_exist' }
res = self._action_post('package_update', dataset, 'editor', 403)

0 comments on commit 5ea6c01

Please sign in to comment.