Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master'into 1942-secure-cookie
- Loading branch information
Showing
13 changed files
with
192 additions
and
234 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
import nose | ||
|
||
from ckan import new_authz as auth | ||
|
||
from ckan.new_tests import helpers | ||
|
||
|
||
assert_equals = nose.tools.assert_equals | ||
|
||
|
||
class TestCheckConfigPermission(object): | ||
|
||
@helpers.change_config('ckan.auth.anon_create_dataset', None) | ||
def test_get_default_value_if_not_set_in_config(self): | ||
|
||
assert_equals(auth.check_config_permission( | ||
'anon_create_dataset'), | ||
auth.CONFIG_PERMISSIONS_DEFAULTS['anon_create_dataset']) | ||
|
||
@helpers.change_config('ckan.auth.anon_create_dataset', None) | ||
def test_get_default_value_also_works_with_prefix(self): | ||
|
||
assert_equals(auth.check_config_permission( | ||
'ckan.auth.anon_create_dataset'), | ||
auth.CONFIG_PERMISSIONS_DEFAULTS['anon_create_dataset']) | ||
|
||
@helpers.change_config('ckan.auth.anon_create_dataset', True) | ||
def test_config_overrides_default(self): | ||
|
||
assert_equals(auth.check_config_permission( | ||
'anon_create_dataset'), | ||
True) | ||
|
||
@helpers.change_config('ckan.auth.anon_create_dataset', True) | ||
def test_config_override_also_works_with_prefix(self): | ||
|
||
assert_equals(auth.check_config_permission( | ||
'ckan.auth.anon_create_dataset'), | ||
True) | ||
|
||
@helpers.change_config('ckan.auth.unknown_permission', True) | ||
def test_unknown_permission_returns_false(self): | ||
|
||
assert_equals(auth.check_config_permission( | ||
'unknown_permission'), | ||
False) | ||
|
||
def test_unknown_permission_not_in_config_returns_false(self): | ||
|
||
assert_equals(auth.check_config_permission( | ||
'unknown_permission'), | ||
False) | ||
|
||
def test_default_roles_that_cascade_to_sub_groups_is_a_list(self): | ||
|
||
assert isinstance(auth.check_config_permission( | ||
'roles_that_cascade_to_sub_groups'), | ||
list) | ||
|
||
@helpers.change_config('ckan.auth.roles_that_cascade_to_sub_groups', | ||
'admin editor') | ||
def test_roles_that_cascade_to_sub_groups_is_a_list(self): | ||
|
||
assert_equals(sorted(auth.check_config_permission( | ||
'roles_that_cascade_to_sub_groups')), | ||
sorted(['admin', 'editor'])) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.