mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Modify tests to use user temp directory
Modifies the win_dacl tests to use the user temp directory as using any other directories breaks the expected matching perms
This commit is contained in:
parent
2da58365e9
commit
b6a92f693d
1 changed files with 27 additions and 5 deletions
|
@ -1,3 +1,6 @@
|
|||
import os
|
||||
import tempfile
|
||||
|
||||
import pytest
|
||||
|
||||
import salt.utils.win_dacl as win_dacl
|
||||
|
@ -18,9 +21,24 @@ def configure_loader_modules(minion_opts):
|
|||
}
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def user_temp_dir():
|
||||
"""
|
||||
Return the user's temp directory if available
|
||||
|
||||
Some of the tests fail if using system temp directories
|
||||
"""
|
||||
if "TMP" in os.environ and os.path.exists(os.environ["TMP"]):
|
||||
return os.environ["TMP"]
|
||||
return tempfile.gettempdir()
|
||||
|
||||
|
||||
@pytest.fixture(scope="function")
|
||||
def test_file():
|
||||
with pytest.helpers.temp_file("dacl_test.file") as test_file:
|
||||
def test_file(tmp_path_factory, user_temp_dir):
|
||||
|
||||
with pytest.helpers.temp_file(
|
||||
"dacl_test.file", directory=user_temp_dir
|
||||
) as test_file:
|
||||
yield test_file
|
||||
|
||||
|
||||
|
@ -671,8 +689,10 @@ def test_get_set_inheritance(test_file):
|
|||
assert result is False
|
||||
|
||||
|
||||
def test_copy_security():
|
||||
with pytest.helpers.temp_file("source_test.file") as source:
|
||||
def test_copy_security(user_temp_dir):
|
||||
with pytest.helpers.temp_file(
|
||||
"source_test.file", directory=user_temp_dir
|
||||
) as source:
|
||||
# Set permissions on Source
|
||||
result = win_dacl.set_permissions(
|
||||
obj_name=str(source),
|
||||
|
@ -697,7 +717,9 @@ def test_copy_security():
|
|||
)
|
||||
assert result is True
|
||||
|
||||
with pytest.helpers.temp_file("target_test.file") as target:
|
||||
with pytest.helpers.temp_file(
|
||||
"target_test.file", directory=user_temp_dir
|
||||
) as target:
|
||||
# Copy security from Source to Target
|
||||
result = win_dacl.copy_security(source=str(source), target=str(target))
|
||||
assert result is True
|
||||
|
|
Loading…
Add table
Reference in a new issue