59 lines
1.2 KiB
Bash
Executable File
59 lines
1.2 KiB
Bash
Executable File
#!/bin/sh
|
|
|
|
HOST=$1
|
|
|
|
if [ -z HOST ]; then
|
|
echo "Host not specified, exiting"
|
|
exit 1;
|
|
fi;
|
|
|
|
echo -n 'Resetting DB...'
|
|
|
|
curl -X GET -f -s \
|
|
http://$HOST:12402/reset_users_because_postman_is_dumb_like_that > /dev/null
|
|
|
|
if [ $? -ne 0 ]; then
|
|
echo 'Exiting due to previous error'
|
|
exit 1
|
|
fi
|
|
echo ' Done.'
|
|
|
|
echo -n 'Creating users...'
|
|
for i in $(seq 1); do
|
|
curl -X POST -f -s \
|
|
--data "{\"name\": \"hi$i\"}" \
|
|
--header "Content-Type: application/json" \
|
|
http://$HOST:12402/user > /dev/null;
|
|
|
|
if [ $? -ne 0 ]; then
|
|
echo 'Exiting due to previous error'
|
|
exit 1
|
|
fi
|
|
done
|
|
echo ' Done.'
|
|
|
|
echo -n 'Getting user UUID to delete...'
|
|
DELETION_UUID=$(curl -X GET -f -s \
|
|
http://$HOST:12402/users \
|
|
| jq .[0].uuid);
|
|
|
|
if [ $? -ne 0 ]; then
|
|
echo 'Exiting due to previous error'
|
|
exit 1
|
|
fi
|
|
|
|
DELETION_UUID=${DELETION_UUID#\"}
|
|
DELETION_UUID=${DELETION_UUID%\"}
|
|
|
|
echo " $DELETION_UUID."
|
|
|
|
echo -n "Deleting user $DELETION_UUID..."
|
|
curl -X DELETE -f -s \
|
|
http://$HOST:12402/user/$DELETION_UUID > /dev/null
|
|
|
|
if [ $? -ne 0 ]; then
|
|
echo 'Exiting due to previous error'
|
|
exit 1
|
|
fi
|
|
echo ' Done.'
|