blob: 0e06d5a5cdf6048c122fe004e71f976f34d822eb [file] [log] [blame]
su622bf5b68992018-04-23 12:02:24 -04001#!/bin/bash
2# lji: this is basically what Dom has in his regtest. re-do it in bash instead of ksh
3
4HOSTPORT="127.0.0.1:3904"
5ANONTOPIC="anon-topic-$RANDOM"
6APITOPIC="api-topic-$RANDOM"
7APIKEYFILE="/tmp/key"
8
9echo "blah" > /tmp/sample.txt
10
11if [ ! -e /usr/bin/jq ]; then
12 apt-get update && apt-get -y install jq
13fi
14
15
16# list topics
17curl http://${HOSTPORT}/topics
18
19# publish to an anonymous topic (first publish creats the topic)
20curl -H "Content-Type:text/plain" -X POST -d @/tmp/sample.txt http://${HOSTPORT}/events/$ANONTOPIC
21
22# subscribe to an anonymous topic
23curl -H "Content-Type:text/plain" -X GET http://${HOSTPORT}/events/$ANONTOPIC/group1/C1?timeout=5000 &
24curl -H "Content-Type:text/plain" -X POST -d @/tmp/sample.txt http://${HOSTPORT}/events/$ANONTOPIC
25
26
27
28
29# create api key
30echo '{"email":"no email","description":"API key and secret both in reponse"}' > /tmp/input.txt
31curl -s -o ${APIKEYFILE} -H "Content-Type:application/json" -X POST -d @/tmp/input.txt http://${HOSTPORT}/apiKeys/create
32UEBAPIKEYSECRET=`cat ${APIKEYFILE} |jq -r ".secret"`
33UEBAPIKEYKEY=`cat ${APIKEYFILE} |jq -r ".key"`
34
35# create an api key secured topic
36# pay attendtion to replication count
37echo '{"topicName":"'${APITOPIC}'","topicDescription":"This is an API key securedTopic","partitionCount":"1","replicationCount":"1","transactionEnabled":"true"}' > /tmp/topicname.txt
38time=`date --iso-8601=seconds`
39signature=$(echo -n "$time" | openssl sha1 -hmac $UEBAPIKEYSECRET -binary | openssl base64)
40xAuth=$UEBAPIKEYKEY:$signature
41xDate="$time"
42curl -i -H "Content-Type: application/json" -H "X-CambriaAuth:$xAuth" -H "X-CambriaDate:$xDate" -X POST -d @/tmp/topicname.txt http://${HOSTPORT}/topics/create
43
44# first subscribe and run it in bg. then publish.
45time=`date --iso-8601=seconds`
46signature=$(echo -n "$time" | openssl sha1 -hmac $UEBAPIKEYSECRET -binary | openssl base64)
47xAuth=$UEBAPIKEYKEY:$signature
48xDate="$time"
49curl -H "X-CambriaAuth:$xAuth" -H "X-CambriaDate:$xDate" -X GET http://${HOSTPORT}/events/${APITOPIC}/g0/u1 &
50curl -H "Content-Type:text/plain" -H "X-CambriaAuth:$xAuth" -H "X-CambriaDate:$xDate" -X POST -d @/tmp/sample.txt http://${HOSTPORT}/events/${APITOPIC}