Exemplo n.º 1
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')
     mock_perms.assert_called_once_with(['all'])
     mock_res.assert_called_once_with('{{my_user}}')
     assert perms == [(Allow, 'registry callable', 'Foo')]
Exemplo n.º 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')]
Exemplo n.º 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'),
     ])
Exemplo n.º 4
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'),
     ])
Exemplo n.º 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')]
Exemplo n.º 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')]
Exemplo n.º 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)
Exemplo n.º 8
0
 def test_parse_acl_no_string(self):
     perms = acl.parse_acl('', self.methods_map)
     assert perms == [acl.ALLOW_ALL]
Exemplo n.º 9
0
 def test_parse_acl_no_string(self):
     perms = acl.parse_acl('')
     assert perms == [acl.ALLOW_ALL]
Exemplo n.º 10
0
 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')]
Exemplo n.º 11
0
 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')]
Exemplo n.º 12
0
 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)
Exemplo n.º 13
0
 def test_parse_acl_no_string(self):
     perms = acl.parse_acl('')
     assert perms == [acl.ALLOW_ALL]