3 # depends on jq - https://stedolan.github.io/jq/ 
 
  10 URL=$PROTOCOL://$FQDN:$PORT
 
  16 #       echo "[debug] compare $1 to $2"
 
  27 echo "SUITE $SUITE: List topics"
 
  32 rc=`curl -s -w "%{http_code}" -o out/$TC.out $URL/topics`
 
  33 results $rc $expect $TC "list"
 
  34 StartTopicCount=`cat out/$TC.out | wc -l`
 
  39 echo "SUITE $SUITE: APIKEY authenticated topic"
 
  45 echo '{ "email": "no.email", "description": "request for direct response KEY" }' > key.req
 
  46 rc=`curl -s -w "%{http_code}" -o out/$TC.out -X POST -H "Content-Type: application/json" -d @key.req $URL/apiKeys/create`
 
  47 results $rc $expect $SUITE.$TN "gen apikey " 
 
  50 SECRET=$(jq ".secret" $OUT | cut -f 2 -d \")
 
  51 KEY=$(jq ".key" $OUT | cut -f 2 -d \")
 
  52 TIME=`date --iso-8601=seconds`
 
  53 SIG=$(echo -n "$TIME" | openssl sha1 -hmac $SECRET -binary | openssl base64)
 
  55 #echo "[debug] $SECRET  $KEY  $TIME $SIG $xAUTH"
 
  57 echo "{ \"topicName\": \"$TOPIC\", \"topicDescription\": \"topic for test $TC\", \"partitionCount\": \"1\", \"replicationCount\": \"1\", \"transactionEnabled\": \"true\" }" > $DATA
 
  58 rc=`curl -s -w "%{http_code}" -o out/$TC.out -X POST -H "Content-Type: application/json" -H "X-CambriaAuth: $xAUTH" -H "X-CambriaDate: $TIME" -d @$DATA $URL/topics/create`
 
  59 results $rc $expect $SUITE.$TN "create topic" 
 
  63 rc=`curl -s -w "%{http_code}" -o out/$TC.out $URL/topics`
 
  64 results $rc $expect $TC "list "
 
  65 TopicCnt=`cat out/$TC.out | wc -l`
 
  66 results $TopicCnt $((StartTopicCount + 1)) $TC "topic count"
 
  70 rc=`curl -s -w "%{http_code}" -o out/$TC.out $URL/topics/$TOPIC`
 
  71 results $rc $expect $TC "list $TOPIC"
 
  75 echo "{ \"datestamp\": \"`date`\", \"appkey\": \"x100\", \"appval\": \"some value\" }" > $DATA
 
  76 rc=`curl -s -w "%{http_code}" -o out/$TC.out -X POST -H "Content-Type: application/json" -H "X-CambriaAuth: $xAUTH" -H "X-CambriaDate: $TIME" -d @$DATA $URL/events/$TOPIC`
 
  77 results $rc $expect $SUITE.$TN "pub APIKEY topic" 
 
  80 rc=`curl -s -w "%{http_code}" -o out/$TC.out -X GET -H "Content-Type: application/json" -H "X-CambriaAuth: $xAUTH" -H "X-CambriaDate: $TIME" $URL/events/$TOPIC/g0/u1`
 
  81 results $rc $expect $SUITE.$TN "sub APIKEY topic" 
 
  86 echo "SUITE $SUITE: anonymous topic"
 
  92 echo "datestamp: `date`, key: $TC, value: this is a test " > $DATA
 
  94 rc=`curl -s -w "%{http_code}" -o out/$TC.out -X POST -H "Content-Type: text/plain" -d @$DATA $URL/events/$TOPIC`
 
  95 results $rc $expect $SUITE.$TN "pub text/plain" 
 
  99 rc=`curl -s -w "%{http_code}" -o out/$TC.out $URL/events/$TOPIC/group1/u$$?timeout=1000`
 
 100 results $rc $expect $SUITE.$TN "sub text/plain" 
 
 104 echo "{ \"datestamp\": \"`date`\", \"key\": \"$TC\", \"value\": \"this is a test\" }" > $DATA
 
 106 rc=`curl -s -w "%{http_code}" -o out/$TC.out -X POST -H "Content-Type: application/json" -d @$DATA $URL/events/$TOPIC`
 
 107 results $rc $expect $SUITE.$TN "pub json" 
 
 111 rc=`curl -s -w "%{http_code}" -o out/$TC.out $URL/events/$TOPIC/group1/u$$?timeout=1000`
 
 112 results $rc $expect $SUITE.$TN "sub json"