41 lines
1.9 KiB
Python
41 lines
1.9 KiB
Python
"""Exercise actual Windows confined execution, rather than infer it from ACL text."""
|
|
import json
|
|
import os
|
|
from pathlib import Path
|
|
import subprocess
|
|
import sys
|
|
import tempfile
|
|
|
|
import pytest
|
|
|
|
REPO = Path(__file__).resolve().parents[2]
|
|
sys.path.insert(0, str(REPO / 'tools'))
|
|
from acceptance_workspace import create_workspace_root
|
|
|
|
|
|
@pytest.mark.skipif(sys.platform != 'win32', reason='Official Windows ACL runner regression')
|
|
def test_official_shell_private_temp_negative_inherited_root_positive():
|
|
parent = Path(os.environ['LOCALAPPDATA']) / 'DxProductivity/acceptance-shell'
|
|
parent.mkdir(parents=True, exist_ok=True)
|
|
roots = {'private_temp': Path(tempfile.mkdtemp(prefix='regression-private-', dir=parent)),
|
|
'inherited': create_workspace_root(parent, 'regression-inherited-')}
|
|
evidence = {}
|
|
for name, root in roots.items():
|
|
result = subprocess.run(['node', 'tools/check_acceptance_workspace.mjs', str(root), sys.executable],
|
|
cwd=REPO, capture_output=True, text=True, encoding='utf-8', timeout=120, check=True)
|
|
evidence[name] = json.loads(result.stdout)
|
|
output = REPO / 'outputs/shell-rootcause-probe'
|
|
output.mkdir(parents=True, exist_ok=True)
|
|
(output / 'behavior-regression.json').write_text(json.dumps(evidence, ensure_ascii=False, indent=2), encoding='utf-8')
|
|
for row in evidence.values():
|
|
assert row['inline']['exit_code'] == 0
|
|
assert '314159' in row['inline']['stdout']
|
|
negative, positive = evidence['private_temp'], evidence['inherited']
|
|
assert negative['script']['exit_code'] != 0
|
|
assert 'Permission denied' in negative['script']['stderr']
|
|
assert negative['listing']['exit_code'] != 0
|
|
assert positive['script']['exit_code'] == 0
|
|
assert json.loads(positive['script']['stdout']) == {'probe': 42}
|
|
assert positive['listing']['exit_code'] == 0
|
|
assert 'probe.py' in positive['listing']['stdout']
|