update 2026-10-08 13:17:49

This commit is contained in:
action committed 2026-10-08 13:17:49 +08:00
1 parent 4c2363b0c6
commit a406d6528c
88 files changed
+423 -21796

No files matched your search

@@ -62,7 +62,38 @@ assert_unsafe_upload_rejected() {
json_ok "v.ok === false && v.code === 'uploaded_archive_unsafe'"
}
INIT_STUB_DIR="$(mktemp -d "${TMPDIR:-/tmp}/oxidns-init-stub.XXXXXX")"
printf '#!/bin/sh\nsleep 30\n' > "$INIT_STUB_DIR/oxidns"
: > "$INIT_STUB_DIR/config.yaml"
chmod 755 "$INIT_STUB_DIR/oxidns"
# Drive start_service from the real init script and record the procd params it sets.
printf '%s\n' \
'set -eu' \
'PROCD_ARGS="'"$INIT_STUB_DIR"'/procd-args"' \
'config_load() { :; }' \
'config_get() { case "$1" in CONFIG_PATH) CONFIG_PATH="'"$INIT_STUB_DIR"'/config.yaml" ;; WORKING_DIR) WORKING_DIR="'"$INIT_STUB_DIR"'" ;; esac; }' \
'config_get_bool() { eval "$1=\$FAKE_UCI_VALUE"; }' \
'procd_open_instance() { :; }' \
'procd_close_instance() { :; }' \
'procd_set_param() { printf "%s\n" "$*" >> "$PROCD_ARGS"; }' \
'. "'"$PWD"'/root/etc/init.d/oxidns"' \
'PROG="'"$INIT_STUB_DIR"'/oxidns"' \
'start_service' > "$INIT_STUB_DIR/drive.sh"
INIT_STUB_ARGS="$INIT_STUB_DIR/procd-args"
init_log_destination_args() {
: > "$INIT_STUB_ARGS"
FAKE_UCI_VALUE="$1" /bin/sh "$INIT_STUB_DIR/drive.sh"
}
init_log_destination_args 1
grep -qx 'stdout 1' "$INIT_STUB_ARGS"
grep -qx 'stderr 1' "$INIT_STUB_ARGS"
init_log_destination_args 0
grep -qx 'stdout 0' "$INIT_STUB_ARGS"
grep -qx 'stderr 0' "$INIT_STUB_ARGS"
rm -rf "$INIT_STUB_DIR"
scripts/check.sh
scripts/service-check.sh
root/usr/libexec/rpcd/luci.oxidns list | json_ok "'status' in v && 'core_install' in v && 'core_reinstall' in v && 'core_upload_install' in v && 'core_progress' in v && 'core_remove' in v && 'logs_recent' in v && 'settings_read' in v && !('config_basic_read' in v) && !('config_basic_save' in v)"
root/usr/libexec/rpcd/luci.oxidns call status | json_ok "v.ok === true && v.core && v.core.installed === false && v.webui && v.webui.installed === false && typeof v.webui.url === 'string' && typeof v.webui.local_only === 'boolean' && typeof v.webui.wildcard === 'boolean' && !('api' in v) && !('api_base_url' in v) && !('package' in v) && !('package_manager' in v)"
@@ -216,6 +247,25 @@ EOF
rm -rf "$REMOVE_PREFLIGHT_DIR"
rm -rf "$FAKE_UCI_DIR"
printf '%s' '{"limit":"20"}' | root/usr/libexec/rpcd/luci.oxidns call logs_recent | json_ok "v.ok === true && v.source === 'logread' && Array.isArray(v.lines) && !('entries' in v)"
SERVICE_LOG_DIR="$(mktemp -d "${TMPDIR:-/tmp}/oxidns-service-log-test.XXXXXX")"
# Records only the last argument, which is the message passed after `-t <tag>`.
cat > "$SERVICE_LOG_DIR/logger" <<'EOF'
#!/bin/sh
for last; do :; done
printf '%s\n' "$last" >> "$FAKE_LOGGER_OUT"
EOF
chmod 755 "$SERVICE_LOG_DIR/logger"
assert_service_event() {
: > "$SERVICE_LOG_DIR/events.log"
printf '%s' '{}' |
PATH="$SERVICE_LOG_DIR:$PATH" FAKE_LOGGER_OUT="$SERVICE_LOG_DIR/events.log" \
root/usr/libexec/rpcd/luci.oxidns call "service_$1" |
json_ok "v.ok === false && v.code === '$2'"
test "$(cat "$SERVICE_LOG_DIR/events.log")" = "$3"
}
assert_service_event start core_not_installed "service start ignored: OxiDNS core is not installed"
assert_service_event stop service_unavailable "service stop failed: init script not found: /etc/init.d/oxidns"
rm -rf "$SERVICE_LOG_DIR"
DIST_DIR="$(mktemp -d "${TMPDIR:-/tmp}/luci-app-oxidns-dist.XXXXXX")"
scripts/build-luci-package.sh 0.1.0 "$DIST_DIR" >/dev/null