diff options
author | lj1412 <lji@research.att.com> | 2017-02-14 13:08:07 +0000 |
---|---|---|
committer | lj1412 <lji@research.att.com> | 2017-02-14 13:08:09 +0000 |
commit | dd7aeafdb1d7596c1e825c7c12b2ab672bba25b9 (patch) | |
tree | 3940b973ba9f7a1014ebfde125938c9ba0b1e6f8 /docker_files/ljitest/test.sh | |
parent | 5a71eb2ee585d917e941e4cea886a2f90c628083 (diff) |
init
Change-Id: I4578bf7bc6b1b8a1f74730c01b47bb3f3371f2be
Signed-off-by: lj1412 <lji@research.att.com>
Diffstat (limited to 'docker_files/ljitest/test.sh')
-rw-r--r-- | docker_files/ljitest/test.sh | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/docker_files/ljitest/test.sh b/docker_files/ljitest/test.sh new file mode 100644 index 0000000..0e06d5a --- /dev/null +++ b/docker_files/ljitest/test.sh @@ -0,0 +1,50 @@ +#!/bin/bash +# lji: this is basically what Dom has in his regtest. re-do it in bash instead of ksh + +HOSTPORT="127.0.0.1:3904" +ANONTOPIC="anon-topic-$RANDOM" +APITOPIC="api-topic-$RANDOM" +APIKEYFILE="/tmp/key" + +echo "blah" > /tmp/sample.txt + +if [ ! -e /usr/bin/jq ]; then + apt-get update && apt-get -y install jq +fi + + +# list topics +curl http://${HOSTPORT}/topics + +# publish to an anonymous topic (first publish creats the topic) +curl -H "Content-Type:text/plain" -X POST -d @/tmp/sample.txt http://${HOSTPORT}/events/$ANONTOPIC + +# subscribe to an anonymous topic +curl -H "Content-Type:text/plain" -X GET http://${HOSTPORT}/events/$ANONTOPIC/group1/C1?timeout=5000 & +curl -H "Content-Type:text/plain" -X POST -d @/tmp/sample.txt http://${HOSTPORT}/events/$ANONTOPIC + + + + +# create api key +echo '{"email":"no email","description":"API key and secret both in reponse"}' > /tmp/input.txt +curl -s -o ${APIKEYFILE} -H "Content-Type:application/json" -X POST -d @/tmp/input.txt http://${HOSTPORT}/apiKeys/create +UEBAPIKEYSECRET=`cat ${APIKEYFILE} |jq -r ".secret"` +UEBAPIKEYKEY=`cat ${APIKEYFILE} |jq -r ".key"` + +# create an api key secured topic +# pay attendtion to replication count +echo '{"topicName":"'${APITOPIC}'","topicDescription":"This is an API key securedTopic","partitionCount":"1","replicationCount":"1","transactionEnabled":"true"}' > /tmp/topicname.txt +time=`date --iso-8601=seconds` +signature=$(echo -n "$time" | openssl sha1 -hmac $UEBAPIKEYSECRET -binary | openssl base64) +xAuth=$UEBAPIKEYKEY:$signature +xDate="$time" +curl -i -H "Content-Type: application/json" -H "X-CambriaAuth:$xAuth" -H "X-CambriaDate:$xDate" -X POST -d @/tmp/topicname.txt http://${HOSTPORT}/topics/create + +# first subscribe and run it in bg. then publish. +time=`date --iso-8601=seconds` +signature=$(echo -n "$time" | openssl sha1 -hmac $UEBAPIKEYSECRET -binary | openssl base64) +xAuth=$UEBAPIKEYKEY:$signature +xDate="$time" +curl -H "X-CambriaAuth:$xAuth" -H "X-CambriaDate:$xDate" -X GET http://${HOSTPORT}/events/${APITOPIC}/g0/u1 & +curl -H "Content-Type:text/plain" -H "X-CambriaAuth:$xAuth" -H "X-CambriaDate:$xDate" -X POST -d @/tmp/sample.txt http://${HOSTPORT}/events/${APITOPIC} |