forked from Georg/pyacl
Enhance test suite
Map input ACLs for setfacl with expected pyacl output to allow for an easily expandable test matrix. Signed-off-by: Georg Pfuetzenreuter <mail@georg-pfuetzenreuter.net>
This commit is contained in:
parent
6f05367ae6
commit
10a3123305
@ -14,14 +14,17 @@ from subprocess import run
|
||||
import pytest
|
||||
|
||||
|
||||
@pytest.fixture(scope='session')
|
||||
def sample_file(tmp_path_factory):
|
||||
#@pytest.fixture(scope='session')
|
||||
@pytest.fixture
|
||||
def sample_file(tmp_path_factory, aclin):
|
||||
directory = tmp_path_factory.mktemp('sample_files')
|
||||
file = directory / 'file_with_user_read_acl'
|
||||
file.touch()
|
||||
assert not file.read_text() # file should exist
|
||||
run(['setfacl', '-m', 'u:user:r', file], check=True)
|
||||
requested_acl = aclin
|
||||
print(requested_acl)
|
||||
run(['setfacl', '-m', requested_acl, file], check=True)
|
||||
out = run(['getfacl', '-c', file], check=True, capture_output=True)
|
||||
assert 'user:user:r--' in out.stdout.decode() # file should have the ACL set
|
||||
assert requested_acl in out.stdout.decode() # file should have the ACL set
|
||||
yield file
|
||||
rmtree(directory)
|
||||
|
@ -8,39 +8,80 @@ An English copy of the Licence is shipped in a file called LICENSE along with th
|
||||
You may obtain copies of the Licence in any of the official languages at https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12.
|
||||
"""
|
||||
|
||||
from pytest import mark
|
||||
|
||||
from pyacl import acl
|
||||
|
||||
|
||||
def test_parse_acl(sample_file):
|
||||
want = {
|
||||
'user': {
|
||||
testdata = [
|
||||
(
|
||||
'user:user:r',
|
||||
{
|
||||
'user': {
|
||||
'read': True,
|
||||
'write': False,
|
||||
'execute': False,
|
||||
'user': {
|
||||
'read': True,
|
||||
'write': False,
|
||||
'execute': False,
|
||||
},
|
||||
},
|
||||
'group': {
|
||||
None: {
|
||||
'read': True,
|
||||
'write': False,
|
||||
'execute': False,
|
||||
},
|
||||
},
|
||||
'mask': {
|
||||
None: {
|
||||
'read': True,
|
||||
'write': False,
|
||||
'execute': False,
|
||||
},
|
||||
},
|
||||
'other': {
|
||||
None: {
|
||||
'read': True,
|
||||
'write': False,
|
||||
'execute': False,
|
||||
},
|
||||
},
|
||||
},
|
||||
'group': {
|
||||
None: {
|
||||
'read': True,
|
||||
'write': False,
|
||||
'execute': False,
|
||||
),
|
||||
(
|
||||
'user:user:-w-',
|
||||
{
|
||||
'user': {
|
||||
'user': {
|
||||
'read': False,
|
||||
'write': True,
|
||||
'execute': False,
|
||||
},
|
||||
},
|
||||
'group': {
|
||||
None: {
|
||||
'read': True,
|
||||
'write': False,
|
||||
'execute': False,
|
||||
},
|
||||
},
|
||||
'mask': {
|
||||
None: {
|
||||
'read': True,
|
||||
'write': True,
|
||||
'execute': False,
|
||||
},
|
||||
},
|
||||
'other': {
|
||||
None: {
|
||||
'read': True,
|
||||
'write': False,
|
||||
'execute': False,
|
||||
},
|
||||
},
|
||||
},
|
||||
'mask': {
|
||||
None: {
|
||||
'read': True,
|
||||
'write': False,
|
||||
'execute': False,
|
||||
},
|
||||
},
|
||||
'other': {
|
||||
None: {
|
||||
'read': True,
|
||||
'write': False,
|
||||
'execute': False,
|
||||
},
|
||||
},
|
||||
}
|
||||
),
|
||||
]
|
||||
|
||||
@mark.parametrize('aclin, aclout', testdata)
|
||||
def test_parse_acl(sample_file, aclin, aclout):
|
||||
have = acl.parsefromfile(sample_file)
|
||||
assert want == have
|
||||
assert aclout == have
|
||||
|
Loading…
Reference in New Issue
Block a user