Skip to content

Instantly share code, notes, and snippets.

@fityanos
Created September 12, 2018 11:00
Show Gist options
  • Save fityanos/0b16037e6431ac9abbb7b36f036bdd23 to your computer and use it in GitHub Desktop.
Save fityanos/0b16037e6431ac9abbb7b36f036bdd23 to your computer and use it in GitHub Desktop.
exampleShellApi
#!/usr/bin/env bash
source ../../UI/Colors.sh # Colors
source ../../TestData/BaseUrl.sh # baseUrls
source ../../TestData/SearchParamData.sh # iataCodes
source ../../TestData/DatesGenerator.sh # dates
UserAgent=`cat ././../../Headers/UserAgent.txt`
Accept=`cat ././../../Headers/Accept.txt`
ContentType=`cat ././../../Headers/ContentType.txt`
Token=`cat ././../../Headers/Token.txt`
# ~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-
# ~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-
# random endpoint call with Http header
STATUS=$(curl -w '%{http_code}' ''${BASE_URL_DEV}'search/fares?query='${ORIGINS_RAND}'-'${DESTINATIONS_RAND}'/'${DATE_ONE}'/cabin/pax' \
-H "User-Agent:${UserAgent}" \
-H "Accept:${Accept}" \
-H "Content-Type:${ContentType}" \
-H "Authorization:${Token}" --create-dirs -o ././../../Logs/GenericSearchLog.json)
echo
echo -e "${Purple}search query form => ${ORIGINS_RAND} to => ${DESTINATIONS_RAND} on ${DATE_ONE} ${White}"
echo
# fetch search query to compare and assert
function assertQuery {
jq -r .request.query ././../../Logs/GenericSearchLog.json
}
# assert that search query is as expected
if [ `assertQuery` == "${IATA_ORIGINS_RAND}-${IATA_DESTINATIONS_RAND}/${DATE_ONE}/Economy/1Adult" ]; then
echo -e "${Green}True${White}"
else
echo -e "${Red}False${White}"
exit
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment