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')]
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')]
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'), ])
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')]
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')]
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)
def test_parse_acl_no_string(self): perms = acl.parse_acl('', self.methods_map) assert perms == [acl.ALLOW_ALL]
def test_parse_acl_no_string(self): perms = acl.parse_acl('') assert perms == [acl.ALLOW_ALL]
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')]
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')]
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)