Skip to content

Commit

Permalink
Merge pull request #1260 from i12momal/rama8
Browse files Browse the repository at this point in the history
Replace bin in test_mixed_ownership.py
  • Loading branch information
danigm authored Aug 7, 2024
2 parents 47cb5d7 + 860a4b0 commit 7a336ff
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 6 deletions.
5 changes: 3 additions & 2 deletions rpmlint/pkg.py
Original file line number Diff line number Diff line change
Expand Up @@ -877,14 +877,15 @@ def create_files(self, files):
self._mock_file(path, file)

def add_dir(self, path, metadata=None):
pkgdir = PkgFile(path)
name = path
pkgdir = PkgFile(name)
pkgdir.magic = 'directory'

path = os.path.join(self.dir_name(), path.lstrip('/'))
os.makedirs(Path(path), exist_ok=True)

pkgdir.path = path
self.files[path] = pkgdir
self.files[name] = pkgdir

if metadata:
for k, v in metadata.items():
Expand Down
15 changes: 15 additions & 0 deletions test/mockdata/mock_mixed_ownership.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
from Testing import get_tested_mock_package

MixedOwnership = get_tested_mock_package(
files={
'/usr/bin/noproblem': {},
'/var/lib/badfolder': {
'metadata': {'user': 'nobody'},
'is_dir': True},
'/var/lib/badfolder/broken1': {
'metadata': {'user': 'root'}},
'/var/lib/badfolder/correctperms': {
'metadata': {'user': 'root'},
'is_dir': True},
'/var/lib/badfolder/correctperms/broken2': {},
})
9 changes: 5 additions & 4 deletions test/test_mixed_ownership.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
from mockdata.mock_mixed_ownership import MixedOwnership
import pytest
from rpmlint.checks.MixedOwnershipCheck import MixedOwnershipCheck
from rpmlint.filter import Filter

from Testing import CONFIG, get_tested_package
from Testing import CONFIG


@pytest.fixture(scope='function', autouse=True)
Expand All @@ -13,10 +14,10 @@ def mixedownershipcheck():
return output, test


@pytest.mark.parametrize('package', ['binary/mixed-ownership'])
def test_mixed_ownership(tmp_path, package, mixedownershipcheck):
@pytest.mark.parametrize('package', [MixedOwnership])
def test_mixed_ownership(package, mixedownershipcheck):
output, test = mixedownershipcheck
test.check(get_tested_package(package, tmp_path))
test.check(package)
out = output.print_results(output.results)
assert 'noproblem' not in out
assert 'file-parent-ownership-mismatch Path "/var/lib/badfolder/broken1" owned by "root" is stored in directory owned by "nobody"' in out
Expand Down

0 comments on commit 7a336ff

Please sign in to comment.