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