Files
mirror-3x-ui/scripts/test
Hamed Sanaei 5fe46c2e55 fix(ssl): recover interrupted IP certificate migrations
Register recovery before retiring legacy renewal state and detach completed journals before deleting backups.
2026-12-03 21:32:11 +03:30
..
…

IP certificate regression tests

Run from the repository root in Bash. The suite uses temporary files, mocks ACME orders and service commands, and generates certificate fixtures from a local CA. It never requests a certificate from a CA or executes the complete installer.

bash -n install.sh
bash -n x-ui.sh
bash scripts/sync-ip-ssl-helpers.sh --check
bash scripts/test/ip-ssl-test.sh
bash scripts/test/ip-ssl-entrypoint-test.sh
IP_SSL_LINUX_TEST=1 bash scripts/test/ip-ssl-listener-test.sh
bash scripts/test/ip-ssl-certificate-test.sh

Linux integration needs socat, curl, flock, openssl (1.1.1+), and standard coreutils. The listener tests bind unprivileged random ports on loopback. They need an IPv6 loopback interface, but no public IPv6 address, root privileges, or working external echo service. Run the same commands on Debian/Ubuntu and AlmaLinux/RHEL; install test dependencies in a disposable container if they are missing locally.

The tests cover real embedded installer/menu functions, discovery and consent, unattended overrides, both socket families, actual IP SAN types and matching keys, failed issuance and installation, failed restoration, interruption, shared-path locking, rejected automatic renewals, and the persisted renewal runner. Package installation, ACME orders, and panel/service operations are mocked at their command boundaries.

To check unchanged upstream acme.sh listener implementations separately:

curl -fsSLo /tmp/acme-3.1.5.sh https://raw.githubusercontent.com/acmesh-official/acme.sh/3.1.5/acme.sh
bash scripts/test/ip-ssl-acme-listener-test.sh /tmp/acme-3.1.5.sh 28085
curl -fsSLo /tmp/acme-3.1.6.sh https://raw.githubusercontent.com/acmesh-official/acme.sh/3.1.6/acme.sh
bash scripts/test/ip-ssl-acme-listener-test.sh /tmp/acme-3.1.6.sh 28085
bash scripts/test/ip-ssl-acme-lifecycle-test.sh /tmp/acme-3.1.5.sh /tmp/acme-3.1.6.sh

The listener test invokes the upstream dispatcher, sends independent loopback HTTP requests with curl -4 and curl -6, prints the sockets with ss, then stops the listeners. It does not issue ACME orders or change an installed client. Run it in a disposable Linux environment with iproute2/iproute installed. Test both net.ipv6.bindv6only=0 and 1 container configurations where available.

The lifecycle test exercises stock --installcert and the retry path of stock --renew. It reproduces the live-file overwrite on a failed upstream reload, then checks the x-ui runner against the same behavior using isolated ACME state, fixture certificates, and no CA requests. CI fetches the two upstream versions by commit and runs this test alongside the lifecycle and concurrency regressions.

Loopback success does not establish public reachability. Real CA validation, external port 80 forwarding, provider firewalls, and scheduled cron execution on a deployed server require separate deployment testing.

After editing scripts/lib/ip-ssl.sh, run bash scripts/sync-ip-ssl-helpers.sh to refresh both standalone scripts. CI checks that the embedded helpers match the canonical source.