mirror of
https://github.com/m1ngsama/TNT.git
synced 2026-02-08 08:54:05 +00:00
fix(ci): support macOS by using gtimeout from coreutils
This commit is contained in:
parent
bd4695b329
commit
c120cb5ac5
5 changed files with 34 additions and 10 deletions
2
.github/workflows/ci.yml
vendored
2
.github/workflows/ci.yml
vendored
|
|
@ -25,7 +25,7 @@ jobs:
|
||||||
- name: Install dependencies (macOS)
|
- name: Install dependencies (macOS)
|
||||||
if: runner.os == 'macOS'
|
if: runner.os == 'macOS'
|
||||||
run: |
|
run: |
|
||||||
brew install libssh
|
brew install libssh coreutils
|
||||||
|
|
||||||
- name: Build
|
- name: Build
|
||||||
run: make
|
run: make
|
||||||
|
|
|
||||||
|
|
@ -20,12 +20,18 @@ cleanup() {
|
||||||
}
|
}
|
||||||
trap cleanup EXIT
|
trap cleanup EXIT
|
||||||
|
|
||||||
|
# Detect timeout command
|
||||||
|
TIMEOUT_CMD="timeout"
|
||||||
|
if command -v gtimeout >/dev/null 2>&1; then
|
||||||
|
TIMEOUT_CMD="gtimeout"
|
||||||
|
fi
|
||||||
|
|
||||||
echo "Testing anonymous SSH access to TNT server..."
|
echo "Testing anonymous SSH access to TNT server..."
|
||||||
echo ""
|
echo ""
|
||||||
|
|
||||||
# Test 1: Connection with any username and password
|
# Test 1: Connection with any username and password
|
||||||
echo "Test 1: Connection with any username (should succeed)"
|
echo "Test 1: Connection with any username (should succeed)"
|
||||||
timeout 10 expect -c "
|
$TIMEOUT_CMD 10 expect -c "
|
||||||
spawn ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -p $PORT testuser@localhost
|
spawn ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -p $PORT testuser@localhost
|
||||||
expect {
|
expect {
|
||||||
\"password:\" {
|
\"password:\" {
|
||||||
|
|
@ -54,7 +60,7 @@ echo ""
|
||||||
|
|
||||||
# Test 2: Connection should work with empty password
|
# Test 2: Connection should work with empty password
|
||||||
echo "Test 2: Simple connection (standard SSH command)"
|
echo "Test 2: Simple connection (standard SSH command)"
|
||||||
timeout 10 expect -c "
|
$TIMEOUT_CMD 10 expect -c "
|
||||||
spawn ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -p $PORT anonymous@localhost
|
spawn ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -p $PORT anonymous@localhost
|
||||||
expect {
|
expect {
|
||||||
\"password:\" {
|
\"password:\" {
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,12 @@ cleanup() {
|
||||||
|
|
||||||
trap cleanup EXIT
|
trap cleanup EXIT
|
||||||
|
|
||||||
|
# Detect timeout command
|
||||||
|
TIMEOUT_CMD="timeout"
|
||||||
|
if command -v gtimeout >/dev/null 2>&1; then
|
||||||
|
TIMEOUT_CMD="gtimeout"
|
||||||
|
fi
|
||||||
|
|
||||||
echo "=== TNT Basic Tests ==="
|
echo "=== TNT Basic Tests ==="
|
||||||
|
|
||||||
# Path to binary
|
# Path to binary
|
||||||
|
|
@ -39,7 +45,7 @@ else
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Test 2: SSH connection
|
# Test 2: SSH connection
|
||||||
if timeout 5 ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null \
|
if $TIMEOUT_CMD 5 ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null \
|
||||||
-o BatchMode=yes -p $PORT localhost exit 2>/dev/null; then
|
-o BatchMode=yes -p $PORT localhost exit 2>/dev/null; then
|
||||||
echo "✓ SSH connection works"
|
echo "✓ SSH connection works"
|
||||||
PASS=$((PASS + 1))
|
PASS=$((PASS + 1))
|
||||||
|
|
@ -49,7 +55,7 @@ else
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Test 3: Message logging
|
# Test 3: Message logging
|
||||||
(echo "testuser"; echo "test message"; sleep 1) | timeout 5 ssh -o StrictHostKeyChecking=no \
|
(echo "testuser"; echo "test message"; sleep 1) | $TIMEOUT_CMD 5 ssh -o StrictHostKeyChecking=no \
|
||||||
-o UserKnownHostsFile=/dev/null -p $PORT localhost >/dev/null 2>&1 &
|
-o UserKnownHostsFile=/dev/null -p $PORT localhost >/dev/null 2>&1 &
|
||||||
sleep 3
|
sleep 3
|
||||||
if [ -f messages.log ]; then
|
if [ -f messages.log ]; then
|
||||||
|
|
|
||||||
|
|
@ -43,6 +43,12 @@ if [ ! -f "$BIN" ]; then
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Detect timeout command
|
||||||
|
TIMEOUT_CMD="timeout"
|
||||||
|
if command -v gtimeout >/dev/null 2>&1; then
|
||||||
|
TIMEOUT_CMD="gtimeout"
|
||||||
|
fi
|
||||||
|
|
||||||
# Test 1: 4096-bit RSA Key Generation
|
# Test 1: 4096-bit RSA Key Generation
|
||||||
print_test "1. RSA 4096-bit Key Generation"
|
print_test "1. RSA 4096-bit Key Generation"
|
||||||
rm -f host_key
|
rm -f host_key
|
||||||
|
|
@ -75,19 +81,19 @@ fi
|
||||||
print_test "2. Environment Variable Configuration"
|
print_test "2. Environment Variable Configuration"
|
||||||
|
|
||||||
# Test bind address
|
# Test bind address
|
||||||
TNT_BIND_ADDR=127.0.0.1 timeout 3 $BIN 2>&1 | grep -q "TNT chat server" && \
|
TNT_BIND_ADDR=127.0.0.1 $TIMEOUT_CMD 3 $BIN 2>&1 | grep -q "TNT chat server" && \
|
||||||
pass "TNT_BIND_ADDR configuration works" || fail "TNT_BIND_ADDR not working"
|
pass "TNT_BIND_ADDR configuration works" || fail "TNT_BIND_ADDR not working"
|
||||||
|
|
||||||
# Test with access token set (just verify it starts)
|
# Test with access token set (just verify it starts)
|
||||||
TNT_ACCESS_TOKEN="test123" timeout 3 $BIN 2>&1 | grep -q "TNT chat server" && \
|
TNT_ACCESS_TOKEN="test123" $TIMEOUT_CMD 3 $BIN 2>&1 | grep -q "TNT chat server" && \
|
||||||
pass "TNT_ACCESS_TOKEN configuration accepted" || fail "TNT_ACCESS_TOKEN not working"
|
pass "TNT_ACCESS_TOKEN configuration accepted" || fail "TNT_ACCESS_TOKEN not working"
|
||||||
|
|
||||||
# Test max connections configuration
|
# Test max connections configuration
|
||||||
TNT_MAX_CONNECTIONS=10 timeout 3 $BIN 2>&1 | grep -q "TNT chat server" && \
|
TNT_MAX_CONNECTIONS=10 $TIMEOUT_CMD 3 $BIN 2>&1 | grep -q "TNT chat server" && \
|
||||||
pass "TNT_MAX_CONNECTIONS configuration accepted" || fail "TNT_MAX_CONNECTIONS not working"
|
pass "TNT_MAX_CONNECTIONS configuration accepted" || fail "TNT_MAX_CONNECTIONS not working"
|
||||||
|
|
||||||
# Test rate limit toggle
|
# Test rate limit toggle
|
||||||
TNT_RATE_LIMIT=0 timeout 3 $BIN 2>&1 | grep -q "TNT chat server" && \
|
TNT_RATE_LIMIT=0 $TIMEOUT_CMD 3 $BIN 2>&1 | grep -q "TNT chat server" && \
|
||||||
pass "TNT_RATE_LIMIT configuration accepted" || fail "TNT_RATE_LIMIT not working"
|
pass "TNT_RATE_LIMIT configuration accepted" || fail "TNT_RATE_LIMIT not working"
|
||||||
|
|
||||||
sleep 1
|
sleep 1
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,12 @@ if [ ! -f "$BIN" ]; then
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Detect timeout command
|
||||||
|
TIMEOUT_CMD="timeout"
|
||||||
|
if command -v gtimeout >/dev/null 2>&1; then
|
||||||
|
TIMEOUT_CMD="gtimeout"
|
||||||
|
fi
|
||||||
|
|
||||||
echo "Starting TNT server on port $PORT..."
|
echo "Starting TNT server on port $PORT..."
|
||||||
$BIN -p $PORT &
|
$BIN -p $PORT &
|
||||||
SERVER_PID=$!
|
SERVER_PID=$!
|
||||||
|
|
@ -27,7 +33,7 @@ echo "Spawning $CLIENTS clients for ${DURATION}s..."
|
||||||
for i in $(seq 1 $CLIENTS); do
|
for i in $(seq 1 $CLIENTS); do
|
||||||
(
|
(
|
||||||
sleep $((i % 5))
|
sleep $((i % 5))
|
||||||
echo "test user $i" | timeout $DURATION ssh -o StrictHostKeyChecking=no \
|
echo "test user $i" | $TIMEOUT_CMD $DURATION ssh -o StrictHostKeyChecking=no \
|
||||||
-o UserKnownHostsFile=/dev/null -p $PORT localhost \
|
-o UserKnownHostsFile=/dev/null -p $PORT localhost \
|
||||||
>/dev/null 2>&1
|
>/dev/null 2>&1
|
||||||
) &
|
) &
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue