Skip to content

Never stop coding. Free MIT AI gateway: one endpoint, 375 providers (150+ free), 1,400+ models Kimi, Claude, GPT, Gemini, GLM, DeepSeek, MiniMax. Works with Claude Code, Codex, Cursor, OpenCode, Cline & Copilot. Quota-aware auto-fallback, RTK+Caveman compression saves 15-95% tokens, MCP/A2A, Desktop/PWA. Built by 900+ contributors

888 B
Raw Blame
#!/usr/bin/env bash
# Wrapper: temporarily inject a test entry into /etc/hosts, run the
# mitm-dnsConfig test, then clean up. The entry lets removeDNSEntries
# exercise the full exec path (host present → spawn sudo → mock intercepts).
set -euo pipefail

TEST_HOST="__dns_guard_test__"
HOSTS_FILE="/etc/hosts"
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
REPO_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"

cleanup() {
  sudo sed -i "/$TEST_HOST/d" "$HOSTS_FILE" 2>/dev/null || true
}
trap cleanup EXIT

# Inject test entries (idempotent — duplicates are harmless).
if ! grep -q "$TEST_HOST" "$HOSTS_FILE" 2>/dev/null; then
  echo "127.0.0.1 $TEST_HOST" | sudo tee -a "$HOSTS_FILE" > /dev/null
  echo "::1 $TEST_HOST"       | sudo tee -a "$HOSTS_FILE" > /dev/null
fi

cd "$REPO_ROOT"
node --import tsx/esm --import ./tests/_setup/isolateDataDir.ts \
  --test tests/unit/mitm-dnsConfig.test.ts