Skip to content

Instantly share code, notes, and snippets.

@mchugh19
Created February 18, 2016 19:50
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save mchugh19/61cd93440660ccbfc709 to your computer and use it in GitHub Desktop.
Save mchugh19/61cd93440660ccbfc709 to your computer and use it in GitHub Desktop.
quick salt api curl test
#!/bin/sh
JSON='[{"arg":["sleep 14; echo testing"],"client":"local","expr_form":"glob","fun":"cmd.run","tgt":"*"}]'
RESPONSE=`curl -ik https://localhost:8000/login -H 'Content-Type: application/json' -d '[{"eauth":"pam","password":"SOMEPASSWORD","username":"SOMEUSERNAME"}]' 2>/dev/null`
TOKEN=`echo $RESPONSE | grep -oP "[[:alnum:]]{40}" | uniq`
RESPONSE=`curl -ik https://localhost:8000/minions -H 'Accept: application/json' -H "X-Auth-Token: $TOKEN" -H 'Content-Type: application/json' -d "$JSON" 2>/dev/null`
JID=`echo $RESPONSE | grep -oP "[0-9]{20}" | uniq`
#echo GOT $JID
curl -ik https://localhost:8000/jobs/$JID -H "X-Auth-Token: $TOKEN" 2>/dev/null
echo ""
echo ""
sleep 15
curl -ik https://localhost:8000/jobs/$JID -H "X-Auth-Token: $TOKEN" 2>/dev/null
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment