|
|
|
@@ -10,23 +10,23 @@ RUN_ID=$(echo "$RUN_ID" | sha256sum 2>/dev/null | head -c 8 || echo "${RUN_ID}"
|
|
|
|
|
|
|
|
|
|
cleanup_namespaces() {
|
|
|
|
|
local subs=()
|
|
|
|
|
subs+=("alice@test.local" "routetest-alice@test.local" "routetest-bob@test.local")
|
|
|
|
|
subs+=("val-user@test.local" "dup-user@test.local" "upd-user@test.local" "get-user@test.local")
|
|
|
|
|
subs+=("ns-u1@test.local" "ns-u2@test.local" "alice-del@test.local" "carol-del@test.local")
|
|
|
|
|
subs+=("py-user@test.local" "js-user@test.local" "ttl-user@test.local" "body-user@test.local")
|
|
|
|
|
subs+=("stress-user@test.local" "brand-new-empty-user-xyzqwerty@test.local" "chain-user@test.local")
|
|
|
|
|
subs+=("dup2-user-${RUN_ID}@test.local" "name-user-${RUN_ID}@test.local")
|
|
|
|
|
subs+=("len57-user-${RUN_ID}@test.local" "big-user-${RUN_ID}@test.local" "size-user-${RUN_ID}@test.local")
|
|
|
|
|
subs+=("ttl-exp-${RUN_ID}@test.local" "race-${RUN_ID}@test.local")
|
|
|
|
|
subs+=("mfunc-${RUN_ID}@test.local" "victim-${RUN_ID}@test.local" "attacker-${RUN_ID}@test.local")
|
|
|
|
|
subs+=("lang-multi-${RUN_ID}@test.local" "lang-inv-${RUN_ID}@test.local")
|
|
|
|
|
subs+=("test-alice@test.local" "test-routetest-alice@test.local" "test-routetest-bob@test.local")
|
|
|
|
|
subs+=("test-val-user@test.local" "test-dup-user@test.local" "test-upd-user@test.local" "test-get-user@test.local")
|
|
|
|
|
subs+=("test-ns-u1@test.local" "test-ns-u2@test.local" "test-alice-del@test.local" "test-carol-del@test.local")
|
|
|
|
|
subs+=("test-py-user@test.local" "test-js-user@test.local" "test-ttl-user@test.local" "test-body-user@test.local")
|
|
|
|
|
subs+=("test-stress-user@test.local" "test-brand-new-empty-user-xyzqwerty@test.local" "test-chain-user@test.local")
|
|
|
|
|
subs+=("test-dup2-user-${RUN_ID}@test.local" "test-name-user-${RUN_ID}@test.local")
|
|
|
|
|
subs+=("test-len57-user-${RUN_ID}@test.local" "test-big-user-${RUN_ID}@test.local" "test-size-user-${RUN_ID}@test.local")
|
|
|
|
|
subs+=("test-ttl-exp-${RUN_ID}@test.local" "test-race-${RUN_ID}@test.local")
|
|
|
|
|
subs+=("test-mfunc-${RUN_ID}@test.local" "test-victim-${RUN_ID}@test.local" "test-attacker-${RUN_ID}@test.local")
|
|
|
|
|
subs+=("test-lang-multi-${RUN_ID}@test.local" "test-lang-inv-${RUN_ID}@test.local")
|
|
|
|
|
|
|
|
|
|
local uid
|
|
|
|
|
for uid in $(seq 1 10); do
|
|
|
|
|
subs+=("u${uid}-${RUN_ID}@test.local")
|
|
|
|
|
subs+=("test-u${uid}-${RUN_ID}@test.local")
|
|
|
|
|
done
|
|
|
|
|
for uid in $(seq 1 3); do
|
|
|
|
|
subs+=("fullcycle-u${uid}-${RUN_ID}@test.local")
|
|
|
|
|
subs+=("test-fullcycle-u${uid}-${RUN_ID}@test.local")
|
|
|
|
|
done
|
|
|
|
|
|
|
|
|
|
if [ -x "$NS_CLEANUP_SCRIPT" ]; then
|
|
|
|
@@ -51,23 +51,23 @@ echo ""
|
|
|
|
|
echo ">>> БЛОК A: Фиксы v0.6.8 — регресс"
|
|
|
|
|
|
|
|
|
|
R=$(curl -s -w "\n%{http_code}" -X POST ${BASE}/functions/nonexistent-xyz-abc/invoke \
|
|
|
|
|
-H "X-Test-Sub: alice@test.local" -H "Content-Type: application/json" -d '{}')
|
|
|
|
|
-H "X-Test-Sub: test-alice@test.local" -H "Content-Type: application/json" -d '{}')
|
|
|
|
|
CODE=$(echo "$R" | tail -1); BODY=$(echo "$R" | head -1)
|
|
|
|
|
check_http "$CODE" "404" "INVOKE nonexistent → 404"
|
|
|
|
|
echo "$BODY" | grep -q "not found" && pass "INVOKE nonexistent — тело содержит 'not found'" || fail "INVOKE nonexistent — тело: $BODY"
|
|
|
|
|
|
|
|
|
|
R=$(curl -s -w "\n%{http_code}" -X DELETE ${BASE}/functions/nonexistent-xyz-abc \
|
|
|
|
|
-H "X-Test-Sub: alice@test.local")
|
|
|
|
|
-H "X-Test-Sub: test-alice@test.local")
|
|
|
|
|
CODE=$(echo "$R" | tail -1)
|
|
|
|
|
check_http "$CODE" "404" "DELETE nonexistent → 404"
|
|
|
|
|
|
|
|
|
|
# Создаём изолированные функции и проверяем route isolation
|
|
|
|
|
ISO_NAME="iso-${RUN_ID}"
|
|
|
|
|
R_A=$(curl -s -X POST ${BASE}/functions \
|
|
|
|
|
-H "X-Test-Sub: routetest-alice@test.local" -H "Content-Type: application/json" \
|
|
|
|
|
-H "X-Test-Sub: test-routetest-alice@test.local" -H "Content-Type: application/json" \
|
|
|
|
|
-d "{\"name\":\"${ISO_NAME}\",\"language\":\"nodejs\",\"code\":\"module.exports=async(ctx)=>({body:\\\"alice-iso\\\"})\",\"ttl\":\"5m\"}")
|
|
|
|
|
R_B=$(curl -s -X POST ${BASE}/functions \
|
|
|
|
|
-H "X-Test-Sub: routetest-bob@test.local" -H "Content-Type: application/json" \
|
|
|
|
|
-H "X-Test-Sub: test-routetest-bob@test.local" -H "Content-Type: application/json" \
|
|
|
|
|
-d "{\"name\":\"${ISO_NAME}\",\"language\":\"nodejs\",\"code\":\"module.exports=async(ctx)=>({body:\\\"bob-iso\\\"})\",\"ttl\":\"5m\"}")
|
|
|
|
|
ROUTE_A=$(echo "$R_A" | python3 -c "import sys,json; print(json.load(sys.stdin).get('route','?'))" 2>/dev/null)
|
|
|
|
|
ROUTE_B=$(echo "$R_B" | python3 -c "import sys,json; print(json.load(sys.stdin).get('route','?'))" 2>/dev/null)
|
|
|
|
@@ -77,9 +77,9 @@ sleep 10
|
|
|
|
|
|
|
|
|
|
# Invoke после изоляции
|
|
|
|
|
INV_A=$(curl -s -X POST ${BASE}/functions/${ISO_NAME}/invoke \
|
|
|
|
|
-H "X-Test-Sub: routetest-alice@test.local" -H "Content-Type: application/json" -d '{}')
|
|
|
|
|
-H "X-Test-Sub: test-routetest-alice@test.local" -H "Content-Type: application/json" -d '{}')
|
|
|
|
|
INV_B=$(curl -s -X POST ${BASE}/functions/${ISO_NAME}/invoke \
|
|
|
|
|
-H "X-Test-Sub: routetest-bob@test.local" -H "Content-Type: application/json" -d '{}')
|
|
|
|
|
-H "X-Test-Sub: test-routetest-bob@test.local" -H "Content-Type: application/json" -d '{}')
|
|
|
|
|
BODY_A=$(echo "$INV_A" | python3 -c "import sys,json; print(json.load(sys.stdin).get('response_raw','?'))" 2>/dev/null)
|
|
|
|
|
BODY_B=$(echo "$INV_B" | python3 -c "import sys,json; print(json.load(sys.stdin).get('response_raw','?'))" 2>/dev/null)
|
|
|
|
|
[ "$BODY_A" = "alice-iso" ] && pass "Route isolation invoke — alice получает alice" || fail "Route isolation — alice получила: $BODY_A"
|
|
|
|
@@ -90,7 +90,7 @@ echo ""
|
|
|
|
|
echo ">>> БЛОК B: Валидация входных данных"
|
|
|
|
|
|
|
|
|
|
R=$(curl -s -w "\n%{http_code}" -X POST ${BASE}/functions \
|
|
|
|
|
-H "X-Test-Sub: val-user@test.local" -H "Content-Type: application/json" \
|
|
|
|
|
-H "X-Test-Sub: test-val-user@test.local" -H "Content-Type: application/json" \
|
|
|
|
|
-d '{"language":"nodejs","code":"x"}')
|
|
|
|
|
CODE=$(echo "$R" | tail -1); check_http "$CODE" "400" "Создание без name → 400"
|
|
|
|
|
|
|
|
|
|