1
0
secret-sender/test-api.sh

45 lines
1.1 KiB
Bash
Raw Normal View History

2024-10-27 03:43:07 +00:00
#!/bin/bash
HTTPPORT=3081
EMAILNOTIFY="${1}"
EMAILOTP="${2}"
echo "Create secret ..."
CREATEDATA='{'
CREATEDATA+=' "senderName": "Me"'
CREATEDATA+=', "subject": "Votre code"'
CREATEDATA+=', "message": "Hello"'
CREATEDATA+=', "secret": "My Secret"'
if [ "${EMAILNOTIFY}" != "" ]; then
CREATEDATA+=', "emailNotify": "'${EMAILNOTIFY}'"'
fi
if [ "${EMAILOTP}" != "" ]; then
CREATEDATA+=', "emailOTP": "'${EMAILOTP}'"'
fi
CREATEDATA+=' }'
echo "${CREATEDATA}"
NEWSECRET=$(curl -s -X POST -H "Content-Type: application/json" \
-d "${CREATEDATA}" \
http://localhost:${HTTPPORT}/api/create)
echo "New secret :"
echo "${NEWSECRET}" | jq
PUBLICID=$(echo "${NEWSECRET}" | jq -r .publicID)
echo ""
echo "Get Link"
curl -s http://localhost:${HTTPPORT}/api/getlink/"${PUBLICID}" | jq
echo ""
echo "Create OTLink"
OTLINKID=$(curl -s http://localhost:${HTTPPORT}/api/createOTLink/"${PUBLICID}" | jq -r .otLinkID)
echo "${OTLINKID}"
echo ""
echo "Read secret first time :"
curl -s http://localhost:${HTTPPORT}/api/read/"${OTLINKID}" | jq
echo "Read secret second time :"
curl -s http://localhost:${HTTPPORT}/api/read/"${OTLINKID}" | jq