Add IPv6-aware Wi-Fi state, HTTPS/SSH listeners, mDNS service reconciliation, and browser Wi-Fi administration. Include a guarded build-local fix for mDNS 1.12.0 membership handling, focused regression suites, and Phase 12 acceptance documentation.
54 lines
2.5 KiB
Python
54 lines
2.5 KiB
Python
#!/usr/bin/env python3
|
|
"""Actual Wi-Fi secret handlers through shared browser prompt IO; host fakes only."""
|
|
from pathlib import Path
|
|
import os
|
|
import subprocess
|
|
import tempfile
|
|
|
|
ROOT = Path(__file__).resolve().parents[2]
|
|
IDF = Path(os.environ.get("IDF_PATH", str(Path.home() / ".platformio/packages/framework-espidf")))
|
|
|
|
def stripped(path):
|
|
return "\n".join(line for line in (ROOT / path).read_text().splitlines()
|
|
if not line.startswith(("#include", "#pragma once")))
|
|
|
|
def function(source, signature):
|
|
start = source.index(signature)
|
|
return source[start:source.index("\n}", start) + 2] + "\n"
|
|
|
|
wifi = (ROOT / "src/wifi_console.c").read_text()
|
|
unit = (ROOT / "tests/admin_console_boundary/fakes.h").read_text() + "\n"
|
|
unit += stripped("src/admin_ssh_console.h") + "\n" + stripped("src/admin_ssh_console.c") + "\n"
|
|
unit += stripped("src/wifi_config.h") + r'''
|
|
#include <stdlib.h>
|
|
#define ESP_ERR_INVALID_SIZE 100
|
|
#define UART_NUM_0 0
|
|
#define WIFI_CONSOLE_SECRET_CAPACITY WIFI_CONFIG_PSK_MAX_LEN
|
|
static esp_err_t uart_flush_input(int port) { (void)port; assert(false); return ESP_FAIL; }
|
|
static int uart_read_bytes(int port, void *out, size_t n, unsigned wait)
|
|
{ (void)port; (void)out; (void)n; (void)wait; assert(false); return -1; }
|
|
static wifi_app_config_t working;
|
|
static unsigned applies, wipes;
|
|
void wifi_config_secure_wipe(void *p, size_t n) {
|
|
secure_wipe(p,n); ++wipes;
|
|
for (size_t i=0;i<n;++i) assert(!((uint8_t *)p)[i]);
|
|
}
|
|
static esp_err_t wifi_manager_get_working_config(wifi_app_config_t *out)
|
|
{ *out=working; return ESP_OK; }
|
|
static esp_err_t wifi_manager_apply_working_config(const wifi_app_config_t *in)
|
|
{ working=*in; ++applies; return ESP_OK; }
|
|
'''
|
|
unit += stripped("src/console_input.c") + "\n"
|
|
for signature in ("static bool parse_u32(", "static bool parse_slot(",
|
|
"static esp_err_t apply_candidate(", "static esp_err_t read_secret_no_echo(",
|
|
"static int set_profile_secret(", "static int set_ap_secret("):
|
|
unit += function(wifi, signature)
|
|
unit += (ROOT / "tests/admin_console_boundary/wifi.c").read_text()
|
|
with tempfile.TemporaryDirectory(prefix="browser-wifi-prompts-") as directory:
|
|
path = Path(directory)
|
|
(path / "test.c").write_text(unit)
|
|
subprocess.run(["cc", "-std=c11", "-Wall", "-Wextra", "-Werror", "-Wno-unused-variable", str(path / "test.c"),
|
|
str(IDF / "components/console/split_argv.c"), "-o", str(path / "test")],
|
|
check=True, timeout=30)
|
|
subprocess.run([str(path / "test")], check=True, timeout=10)
|