예제 #1
0
파일: test_acl.py 프로젝트: atteeela/ramses
 def test_parse_acl_callable_principal(self, mock_perms, mock_res):
     mock_perms.return_value = 'Foo'
     mock_res.return_value = 'registry callable'
     perms = acl.parse_acl('allow {{my_user}} all')
     mock_perms.assert_called_once_with(['all'])
     mock_res.assert_called_once_with('{{my_user}}')
     assert perms == [(Allow, 'registry callable', 'Foo')]
예제 #2
0
 def test_parse_acl_callable_principal(self, mock_perms, mock_res):
     mock_perms.return_value = 'Foo'
     mock_res.return_value = 'registry callable'
     perms = acl.parse_acl('allow {{my_user}} all', self.methods_map)
     mock_perms.assert_called_once_with(['all'], self.methods_map)
     mock_res.assert_called_once_with('{{my_user}}')
     assert perms == [(Allow, 'registry callable', 'Foo')]
예제 #3
0
 def test_parse_acl_multiple_values(self, mock_perms):
     mock_perms.return_value = 'Foo'
     perms = acl.parse_acl(
         'allow everyone read,write;allow authenticated all')
     mock_perms.assert_has_calls([
         call(['read', 'write']),
         call(['all']),
     ])
     assert sorted(perms) == sorted([
         (Allow, Everyone, 'Foo'),
         (Allow, Authenticated, 'Foo'),
     ])
예제 #4
0
파일: test_acl.py 프로젝트: atteeela/ramses
 def test_parse_acl_multiple_values(self, mock_perms):
     mock_perms.return_value = 'Foo'
     perms = acl.parse_acl(
         'allow everyone read,write;allow authenticated all')
     mock_perms.assert_has_calls([
         call(['read', 'write']),
         call(['all']),
     ])
     assert sorted(perms) == sorted([
         (Allow, Everyone, 'Foo'),
         (Allow, Authenticated, 'Foo'),
     ])
예제 #5
0
 def test_parse_acl_group_principal(self, mock_perms):
     mock_perms.return_value = 'Foo'
     perms = acl.parse_acl('allow admin all', self.methods_map)
     mock_perms.assert_called_once_with(['all'], self.methods_map)
     assert perms == [(Allow, 'g:admin', 'Foo')]
예제 #6
0
 def test_parse_acl_special_principal(self, mock_perms):
     mock_perms.return_value = 'Foo'
     perms = acl.parse_acl('allow everyone all', self.methods_map)
     mock_perms.assert_called_once_with(['all'], self.methods_map)
     assert perms == [(Allow, Everyone, 'Foo')]
예제 #7
0
 def test_parse_acl_unknown_action(self):
     with pytest.raises(ValueError) as ex:
         acl.parse_acl('foobar admin all', self.methods_map)
     assert 'Unknown ACL action: foobar' in str(ex.value)
예제 #8
0
 def test_parse_acl_no_string(self):
     perms = acl.parse_acl('', self.methods_map)
     assert perms == [acl.ALLOW_ALL]
예제 #9
0
 def test_parse_acl_no_string(self):
     perms = acl.parse_acl('')
     assert perms == [acl.ALLOW_ALL]
예제 #10
0
파일: test_acl.py 프로젝트: atteeela/ramses
 def test_parse_acl_group_principal(self, mock_perms):
     mock_perms.return_value = 'Foo'
     perms = acl.parse_acl('allow g:admin all')
     mock_perms.assert_called_once_with(['all'])
     assert perms == [(Allow, 'g:admin', 'Foo')]
예제 #11
0
파일: test_acl.py 프로젝트: atteeela/ramses
 def test_parse_acl_special_principal(self, mock_perms):
     mock_perms.return_value = 'Foo'
     perms = acl.parse_acl('allow everyone all')
     mock_perms.assert_called_once_with(['all'])
     assert perms == [(Allow, Everyone, 'Foo')]
예제 #12
0
파일: test_acl.py 프로젝트: atteeela/ramses
 def test_parse_acl_unknown_action(self):
     with pytest.raises(ValueError) as ex:
         acl.parse_acl('foobar admin all')
     assert 'Unknown ACL action: foobar' in str(ex.value)
예제 #13
0
파일: test_acl.py 프로젝트: atteeela/ramses
 def test_parse_acl_no_string(self):
     perms = acl.parse_acl('')
     assert perms == [acl.ALLOW_ALL]