ramackri commented on PR #1106:
URL: https://github.com/apache/ranger/pull/1106#issuecomment-5062345031

   ### E2E all-in-one runner (`run-unixauth-e2e.sh`)
   
   Companion to the updated PR description — drop this in `unixauthservice/` 
and run:
   
   ```bash
   chmod +x run-unixauth-e2e.sh && ./run-unixauth-e2e.sh
   ```
   
   ```bash
   #!/usr/bin/env bash
   # E2E harness for RANGER-5690 account fan-out (PR #1106).
   set -euo pipefail
   cd "$(dirname "$0")"
   
   PORT=15151
   
   echo "=== Building ==="
   mvn -q package -DskipTests
   mvn -q dependency:build-classpath -Dmdep.outputFile=target/test-cp.txt
   CP="target/classes:$(cat target/test-cp.txt)"
   javac -cp "$CP" UnixAuthE2eServer.java
   
   cat > mock-validator-fail.sh <<'MOCKFAIL'
   #!/bin/bash
   read -r line
   echo "FAILED: Password did not match."
   MOCKFAIL
   
   cat > mock-validator-ok.sh <<'MOCKOK'
   #!/bin/bash
   read -r line
   if echo "$line" | grep -q "gooduser"; then
     echo "OK"
   else
     echo "FAILED: Password did not match."
   fi
   MOCKOK
   chmod +x mock-validator-fail.sh mock-validator-ok.sh unixauth-e2e-client.py
   
   start_server() {
     local validator=$1; shift
     java -cp ".:$CP" UnixAuthE2eServer "$validator" "$PORT" "$@" > 
/tmp/unixauth-e2e-server.log 2>&1 &
     SERVER_PID=$!
     trap 'kill "$SERVER_PID" 2>/dev/null || true' EXIT
     for _ in $(seq 1 30); do
       grep -q "^READY" /tmp/unixauth-e2e-server.log 2>/dev/null && return 0
       sleep 0.2
     done
     cat /tmp/unixauth-e2e-server.log >&2; exit 1
   }
   stop_server() { kill "$SERVER_PID" 2>/dev/null || true; wait "$SERVER_PID" 
2>/dev/null || true; trap - EXIT; }
   
   echo ""; echo "=== Test 1: Per-IP lockout (threshold=3) ==="
   start_server "$(pwd)/mock-validator-fail.sh" 3
   python3 unixauth-e2e-client.py 127.0.0.1 "$PORT" baduser wrongpass 5
   stop_server
   
   echo ""; echo "=== Test 2: Enumeration + success reset ==="
   start_server "$(pwd)/mock-validator-ok.sh" 3
   python3 unixauth-e2e-client.py 127.0.0.1 "$PORT" nobody wrong 1
   python3 unixauth-e2e-client.py 127.0.0.1 "$PORT" gooduser good 1
   python3 unixauth-e2e-client.py 127.0.0.1 "$PORT" nobody wrong 1
   stop_server
   
   echo ""; echo "=== Test 3: Single-IP no fan-out delay ==="
   start_server "$(pwd)/mock-validator-fail.sh" 100 60000 30000 10000 true 3
   OUT=$(python3 unixauth-e2e-client.py 127.0.0.1 "$PORT" alice wrong 5)
   echo "$OUT"
   echo "$OUT" | grep -qE 'elapsed_ms=[5-9][0-9]{2,}|elapsed_ms=[1-9][0-9]{3,}' 
&& { echo "FAIL: unexpected delay"; exit 1; }
   echo "PASS: no multi-hundred-ms delays on single-IP retries"
   stop_server
   
   echo ""; echo "=== All core E2E scenarios completed ==="
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to