Revision 3611dd6a
Added by koszko over 1 year ago
| test/__main__.py | ||
|---|---|---|
| 36 | 36 |
from .server import do_an_internet |
| 37 | 37 |
from .misc_constants import * |
| 38 | 38 |
from .profiles import firefox_safe_mode |
| 39 |
from .extension_crafting import get_extension_base_url |
|
| 39 | 40 |
|
| 40 | 41 |
def fail(msg, error_code): |
| 41 | 42 |
print('Error:', msg)
|
| 42 |
print('Usage:', sys.argv[0], '[certificates_directory] [proxy_port]')
|
|
| 43 |
print('Usage:', sys.argv[0], '[--load-haketilo]', '[certificates_directory] [proxy_port]')
|
|
| 43 | 44 |
sys.exit(error_code) |
| 44 | 45 |
|
| 45 |
certdir = Path(sys.argv[1]).resolve() if len(sys.argv) > 1 else default_cert_dir |
|
| 46 |
load_haketilo = False |
|
| 47 |
argv_idx = 1 |
|
| 48 |
if len(sys.argv) > argv_idx and sys.argv[argv_idx] == '--load-haketilo': |
|
| 49 |
load_haketilo = True |
|
| 50 |
argv_idx += 1 |
|
| 51 |
|
|
| 52 |
certdir = Path(sys.argv[argv_idx]).resolve() if len(sys.argv) > argv_idx \ |
|
| 53 |
else default_cert_dir |
|
| 54 |
|
|
| 46 | 55 |
if not certdir.is_dir(): |
| 47 | 56 |
fail('selected certificate directory does not exist.', 2)
|
| 48 | 57 |
|
| 49 |
port = sys.argv[2] if len(sys.argv) > 2 else str(default_proxy_port) |
|
| 58 |
argv_idx += 1 |
|
| 59 |
|
|
| 60 |
port = sys.argv[argv_idx] if len(sys.argv) > argv_idx \ |
|
| 61 |
else str(default_proxy_port) |
|
| 62 |
|
|
| 50 | 63 |
if not port.isnumeric(): |
| 51 | 64 |
fail('port must be an integer.', 3)
|
| 52 | 65 |
|
| 53 | 66 |
httpd = do_an_internet(certdir, int(port)) |
| 54 | 67 |
driver = firefox_safe_mode(proxy_port=int(port)) |
| 55 | 68 |
|
| 69 |
if load_haketilo: |
|
| 70 |
driver.install_addon(str(here.parent / 'mozilla-build.zip'), temporary=True) |
|
| 71 |
driver.get(get_extension_base_url(driver) + 'html/settings.html') |
|
| 72 |
|
|
| 56 | 73 |
print("You can now control the browser through 'driver' object")
|
| 57 | 74 |
|
| 58 | 75 |
# Here we enable readline-enhanced editing: |
Also available in: Unified diff
facilitate running test environment with Haketilo loaded into browser