
Some checks failed
CI - 4NK_node / Code Quality (push) Failing after 37s
CI - 4NK_node / Unit Tests (push) Failing after 36s
CI - 4NK_node / Integration Tests (push) Successful in 33s
CI - 4NK_node / Security Tests (push) Failing after 32s
CI - 4NK_node / Docker Build & Test (push) Failing after 15s
CI - 4NK_node / Documentation Tests (push) Successful in 10s
CI - 4NK_node / Security Audit (push) Successful in 8s
CI - 4NK_node / Release Guard (push) Has been skipped
CI - 4NK_node / Performance Tests (push) Successful in 34s
CI - 4NK_node / Notify (push) Failing after 2s
CI - 4NK_node / Publish Release (push) Has been skipped
49 lines
1.5 KiB
Bash
Executable File
49 lines
1.5 KiB
Bash
Executable File
#!/bin/bash
|
|
# Test de connectivité du reverse proxy vers sdk_storage (/storage)
|
|
# Sorties:
|
|
# - 0 si tests OK
|
|
# - 1 sinon
|
|
|
|
set -euo pipefail
|
|
|
|
HOST="${HOST:-localhost}"
|
|
BASE_URL="https://${HOST}/storage"
|
|
LOG_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")"/.. && pwd)/logs"
|
|
TS="$(date +%Y-%m-%d_%H-%M-%S)"
|
|
LOG_FILE="$LOG_DIR/storage_proxy_${TS}.log"
|
|
mkdir -p "$LOG_DIR"
|
|
|
|
log() {
|
|
printf "%s %s\n" "[$(date +%H:%M:%S)]" "$*" | tee -a "$LOG_FILE"
|
|
}
|
|
|
|
fail() {
|
|
log "ERREUR: $*"
|
|
exit 1
|
|
}
|
|
|
|
key_hex="$(head -c 32 /dev/urandom | od -An -tx1 | tr -d " \n")$(head -c 32 /dev/urandom | od -An -tx1 | tr -d " \n")"
|
|
key_hex="${key_hex:0:64}"
|
|
val_hex="68656c6c6f5f34726e6b" # "hello_4rnk" en hex
|
|
|
|
log "HEAD ${BASE_URL}/"
|
|
code_head=$(curl -skI "${BASE_URL}/" | awk 'NR==1{print $2}' || true)
|
|
log "HTTP ${code_head:-inconnu}"
|
|
|
|
log "POST ${BASE_URL}/store"
|
|
resp_post=$(curl -sk -H 'Content-Type: application/json' -X POST "${BASE_URL}/store" \
|
|
-d "{\"key\":\"${key_hex}\",\"value\":\"${val_hex}\",\"ttl\":120}" || true)
|
|
printf "%s\n" "$resp_post" | tee -a "$LOG_FILE"
|
|
|
|
echo "$resp_post" | grep -q 'Data stored successfully' || fail "stockage échoué"
|
|
|
|
log "GET ${BASE_URL}/retrieve/${key_hex}"
|
|
resp_get=$(curl -sk "${BASE_URL}/retrieve/${key_hex}" || true)
|
|
printf "%s\n" "$resp_get" | tee -a "$LOG_FILE"
|
|
|
|
echo "$resp_get" | grep -q "\"key\":\"${key_hex}\"" || fail "clé non retrouvée"
|
|
echo "$resp_get" | grep -q "\"value\":\"${val_hex}\"" || fail "valeur inattendue"
|
|
|
|
log "Succès: /storage opérationnel via reverse proxy"
|
|
exit 0
|