feat: add shared PostgreSQL client deletion
This commit is contained in:
@@ -87,6 +87,7 @@ enroll() {
|
||||
|
||||
enroll liverecorder 'Live Recorder' '[]' "$WORK_DIR/live.json"
|
||||
enroll imagefind-test 'ImageFind Test Client' '["vector"]' "$WORK_DIR/image.json"
|
||||
enroll delete-test 'Disposable Test Client' '[]' "$WORK_DIR/delete.json"
|
||||
|
||||
json_field() {
|
||||
field=$1
|
||||
@@ -100,8 +101,11 @@ LIVE_PASSWORD=$(json_field password "$WORK_DIR/live.json")
|
||||
IMAGE_DB=$(json_field database "$WORK_DIR/image.json")
|
||||
IMAGE_USER=$(json_field username "$WORK_DIR/image.json")
|
||||
IMAGE_PASSWORD=$(json_field password "$WORK_DIR/image.json")
|
||||
DELETE_DB=$(json_field database "$WORK_DIR/delete.json")
|
||||
DELETE_USER=$(json_field username "$WORK_DIR/delete.json")
|
||||
test -n "$LIVE_DB" && test -n "$LIVE_USER" && test -n "$LIVE_PASSWORD"
|
||||
test -n "$IMAGE_DB" && test -n "$IMAGE_USER" && test -n "$IMAGE_PASSWORD"
|
||||
test -n "$DELETE_DB" && test -n "$DELETE_USER"
|
||||
test "$LIVE_DB" != "$IMAGE_DB"
|
||||
test "$LIVE_USER" != "$IMAGE_USER"
|
||||
|
||||
@@ -124,6 +128,18 @@ if run_client_psql "$LIVE_PASSWORD" -h 127.0.0.1 -p "$PG_PORT" -U "$LIVE_USER" -
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if curl -fsS -b "$COOKIE_JAR" -X DELETE \
|
||||
"$BASE_URL/api/v1/clients/delete-test?confirmation=wrong-name" >/dev/null 2>&1; then
|
||||
printf '%s\n' 'client deletion accepted a mismatched confirmation' >&2
|
||||
exit 1
|
||||
fi
|
||||
curl -fsS -b "$COOKIE_JAR" -X DELETE \
|
||||
"$BASE_URL/api/v1/clients/delete-test?confirmation=delete-test" >/dev/null
|
||||
test -z "$(run_client_psql "$LIVE_PASSWORD" -h 127.0.0.1 -p "$PG_PORT" -U "$LIVE_USER" -d postgres \
|
||||
-Atqc "SELECT 1 FROM pg_database WHERE datname='$DELETE_DB'")"
|
||||
test -z "$(run_client_psql "$LIVE_PASSWORD" -h 127.0.0.1 -p "$PG_PORT" -U "$LIVE_USER" -d postgres \
|
||||
-Atqc "SELECT 1 FROM pg_roles WHERE rolname='$DELETE_USER'")"
|
||||
|
||||
curl -fsS -b "$COOKIE_JAR" -H 'Content-Type: application/json' \
|
||||
--data "{\"database\":\"$IMAGE_DB\",\"sql\":\"SELECT count(*) FROM smoke_vectors\"}" \
|
||||
"$BASE_URL/api/v1/query" | grep -q '"rowCount":1'
|
||||
|
||||
Reference in New Issue
Block a user