#!/usr/bin/env python3 """Prompt credentials without echo; never save them in source or reports.""" from pathlib import Path import getpass import os import subprocess import sys suite = Path(__file__).resolve().parent env = os.environ.copy() arguments = sys.argv[1:] if '--verify-order' in arguments: position = arguments.index('--verify-order') if len(arguments) < position + 3 or not arguments[position + 1].isdigit() or not arguments[position + 2].startswith('UI-TEST-'): raise SystemExit('--verify-order benötigt AUFTRAGSNUMMER und UI-TEST-MARKER.') env['VOTIAN_UI_VERIFY_ORDER_ID'], env['VOTIAN_UI_VERIFY_ORDER_MARKER'] = arguments[position + 1:position + 3] del arguments[position:position + 3] if '--create-order' in arguments: if env.get('VOTIAN_UI_VERIFY_ORDER_ID'): raise SystemExit('--create-order und --verify-order dürfen nicht kombiniert werden.') arguments.remove('--create-order') env['VOTIAN_UI_CREATE_ORDER'] = '1' print('Speichert einen markierten, unvollständigen Testauftrag ohne Kurier.') if not env.get('VOTIAN_UI_USERNAME'): env['VOTIAN_UI_USERNAME'] = input('Votian-Testbenutzer: ') if not env.get('VOTIAN_UI_PASSWORD'): env['VOTIAN_UI_PASSWORD'] = getpass.getpass('Votian-Passwort (wird nicht gespeichert): ') binary = suite / 'node_modules/.bin/playwright' if not binary.exists(): binary = suite.parent / 'node_modules/.bin/playwright' if not binary.exists(): raise SystemExit('Playwright fehlt. Zuerst npm ci im Projekt oder im Testverzeichnis ausführen.') command = [str(binary), 'test', '-c', str(suite / 'playwright.config.ts'), *arguments] try: sys.exit(subprocess.call(command, cwd=suite, env=env)) finally: env.pop('VOTIAN_UI_PASSWORD', None)