45 lines
2.3 KiB
Python
45 lines
2.3 KiB
Python
#!/usr/bin/env python3
|
|
"""Explicit future dev/test UI click for one protected immutable case file."""
|
|
import argparse
|
|
import os
|
|
import shutil
|
|
import subprocess
|
|
import sys
|
|
|
|
from run_pending import CA, ROOT, STATE, quiet_run
|
|
sys.path.insert(0, str(ROOT / 'deploy'))
|
|
from vm_mvp_acceptance import protected_json, require, EXECUTABLE
|
|
|
|
|
|
def main():
|
|
parser = argparse.ArgumentParser(description=__doc__)
|
|
parser.add_argument('--case-file', required=True)
|
|
parser.add_argument('--dev-test-ui-approve', action='store_true', required=True)
|
|
parser.add_argument('--prepare-only', action='store_true')
|
|
args = parser.parse_args()
|
|
value = protected_json(args.case_file)
|
|
require(value.get('profile') == 'dev/test' and value.get('case') in EXECUTABLE
|
|
and value.get('expected_principal') == 'simulated-testprincipal-a', 'fixed_dev_test_case_required')
|
|
if args.prepare_only:
|
|
require(value.get('phase')=='prepare' and value['request']['parameters']['execution_identity']=='root', 'root_UI_preparation_only')
|
|
cache = ROOT / 'web/node_modules/.cache'
|
|
home = cache / 'browser-home'
|
|
nss = home / '.pki/nssdb'; nss.mkdir(parents=True, exist_ok=True, mode=0o700); home.chmod(0o700)
|
|
certutil = shutil.which('certutil') or str(cache / 'nss-tools/root/usr/bin/certutil')
|
|
if not (nss / 'cert9.db').exists():
|
|
quiet_run([certutil, '-N', '-d', 'sql:' + str(nss), '--empty-password'])
|
|
quiet_run([certutil, '-A', '-d', 'sql:' + str(nss), '-n', 'RMM isolated development CA', '-t', 'C,,', '-i', str(CA)])
|
|
quiet_run([certutil, '-V', '-d', 'sql:' + str(nss), '-n', 'RMM isolated development CA', '-u', 'L'])
|
|
env = {k: v for k, v in os.environ.items() if k not in ('DEBUG', 'PWDEBUG', 'NODE_DEBUG')}
|
|
env.update(RMM_E2E_PROFILE='dev/test', RMM_E2E_MODE='mvp-prepare' if args.prepare_only else 'mvp-actions', RMM_E2E_CASE_FILE=args.case_file,TZ='UTC',
|
|
RMM_E2E_LOGIN_FILE=str(STATE / 'browser-login.json'), PLAYWRIGHT_BROWSERS_PATH=str(cache / 'playwright-browsers'))
|
|
return subprocess.run(['npm', 'run', 'test:browser', '--', 'mvp-actions.spec.ts'], cwd=ROOT / 'web', env=env).returncode
|
|
|
|
|
|
if __name__ == '__main__':
|
|
try:
|
|
sys.exit(main())
|
|
except Exception:
|
|
print('MVP_BROWSER_INCOMPLETE: private diagnostics withheld')
|
|
sys.exit(2)
|