Storyboard 02

From Alistair Mann / csi18n
Jump to: navigation, search
  1. Check can see own keyhole status
  2. Check can see same when using 'me' instead of SID
  3. Check cannot see someone else's keyhole status
  4. Check cannot change someone else's status
  5. Check open keyhole can see private material read by outsiders
  6. Check closed keyhole makes private material inaccessible to outsiders
  7. Check can close a keyhole
  8. Check can reopen a keyhole
#!/bin/bash
source acceptance_tests/predefined_codes.sh
 
#
# Prove keyholing acceptable
#
 
echo "testKeyhole should be able to GET own status";
RV=$(curl -i -X GET -H 'Accept: application/json' -H 'Connection: close' -H 'X-APIKey: 798e31c43d6b9f03aa504a6f88cb4550' -u 'testKeyhole:test' https://rest.mpsvr.com:443/subscribers/11/keyhole | grep "HTTP/1.1" | grep -v "X-Testing-Dupe: " | cut -c 10-12)
if [[ "$RV" != "200" ]]; then
    echo ""
    echo "First GET failed :-(";
    echo $RV
    exit;
fi;
 
echo "testKeyhole should be able to GET own status using 'me'";
RV=$(curl -i -X GET -H 'Accept: application/json' -H 'Connection: close' -H 'X-APIKey: 798e31c43d6b9f03aa504a6f88cb4550' -u 'testKeyhole:test' https://rest.mpsvr.com:443/subscribers/me/keyhole | grep "HTTP/1.1" | grep -v "X-Testing-Dupe: " | cut -c 10-12)
if [[ "$RV" != "200" ]]; then
    echo ""
    echo "First 'me' GET failed :-(";
    echo $RV
    exit;
fi;
 
echo "test05 should not be able to GET testKeyhole's status";
RV=$(curl -i -X GET -H 'Accept: application/json' -H 'Connection: close' -H 'X-APIKey: 798e31c43d6b9f03aa504a6f88cb4550' -u 'test05:test' https://rest.mpsvr.com:443/subscribers/11/keyhole | grep "HTTP/1.1" | grep -v "X-Testing-Dupe: " | cut -c 10-12)
if [[ "$RV" != "401" ]]; then
    echo ""
    echo "Second GET failed :-(";
    echo $RV
    exit;
fi;
 
echo "test05 should not be able to PUT testKeyhole's status";
RV=$(curl -i -X PUT -H 'Connection: close' -H 'X-APIKey: 798e31c43d6b9f03aa504a6f88cb4550' -H 'Content-Type: application/json;v=1.0' -u 'test05:test' --data '{"keyhole_status":"true"}' https://rest.mpsvr.com:443/subscribers/11/keyhole | grep "HTTP/1.1" | grep -v "X-Testing-Dupe: " | cut -c 10-12)
if [[ "$RV" != "401" ]]; then
    echo ""
    echo "First PUT failed :-(\n";
    echo $RV
    echo $LOCATION
    exit;
fi;
 
echo "test05 should be able to see testKeyhole private"
curl -i -X POST -H 'Connection: close' -H 'X-APIKey: 798e31c43d6b9f03aa504a6f88cb4550' -H 'Content-Type: application/json;v=1.0' -u 'testKeyhole:test' --data '{"csi18n_xlate_resource":{"language":"en-CA","translation":"Congraturation - A winrar is you","visibility":"private"}}' https://rest.mpsvr.com:443/newmarks/11/A-winner-is-you >/tmp/x
RV=$(cat /tmp/x | grep "HTTP/1.1" | grep -v "X-Testing-Dupe: " | cut -c 10-12)
if [[ "$RV" != "201"  &&  "$RV" != "301" ]]; then
    echo ""
    echo "First POST failed :-(";
    echo $RV
    exit;
fi;
LOCATION=$(cat /tmp/x | grep "Location: " | sed 's|Location: ||' | sed 's|.$||')
if [[ "$LOCATION" == "" ]]; then
    echo ""
    echo "\nFirst POST didn't find a Location :-(\n";
    cat /tmp/x
    exit;
fi;
RV=$(curl -i -X GET -H 'Accept: application/json' -H 'Connection: close' -H 'X-APIKey: 798e31c43d6b9f03aa504a6f88cb4550' -u 'test05:test' https://rest.mpsvr.com:443/newmarks/11/A-winner-is-you/en-CA | grep "HTTP/1.1" | grep -v "X-Testing-Dupe: " | cut -c 10-12)
if [[ "$RV" != "200" ]]; then
    echo ""
    echo "Third GET failed :-(";
    echo $RV
    exit;
fi;
 
echo "testKeyhole should not be able to see test05 private"
curl -i -X POST -H 'Connection: close' -H 'X-APIKey: 798e31c43d6b9f03aa504a6f88cb4550' -H 'Content-Type: application/json;v=1.0' -u 'test05:test' --data '{"csi18n_xlate_resource":{"language":"en-CA","translation":"Congraturation - A winrar is you","visibility":"private"}}' https://rest.mpsvr.com:443/newmarks/1/storyboard02 >/tmp/x
RV=$(cat /tmp/x | grep "HTTP/1.1" | grep -v "X-Testing-Dupe: " | cut -c 10-12)
if [[ "$RV" != "201"  &&  "$RV" != "301" ]]; then
    echo ""
    echo "Second POST failed :-(";
    echo $RV
    exit;
fi;
LOCATION=$(cat /tmp/x | grep "Location: " | sed 's|Location: ||' | sed 's|.$||')
if [[ "$LOCATION" == "" ]]; then
    echo ""
    echo "\nSecond POST didn't find a Location :-(\n";
    cat /tmp/x
    exit;
fi;
RV=$(curl -i -X GET -H 'Accept: application/json' -H 'Connection: close' -H 'X-APIKey: 798e31c43d6b9f03aa504a6f88cb4550' -u 'testKeyhole:test' https://rest.mpsvr.com:443/newmarks/1/storyboard02/en-CA | grep "HTTP/1.1" | grep -v "X-Testing-Dupe: " | cut -c 10-12)
if [[ "$RV" != "404" ]]; then
    echo ""
    echo "Fourth GET failed :-(";
    echo $RV
    exit;
fi;
 
echo "testKeyhole should be able to PUT testKeyhole's status to false";
RV=$(curl -i -X PUT -H 'Connection: close' -H 'X-APIKey: 798e31c43d6b9f03aa504a6f88cb4550' -H 'Content-Type: application/json;v=1.0' -u 'testKeyhole:test' --data '{"keyhole_status":"false"}' https://rest.mpsvr.com:443/subscribers/11/keyhole | grep "HTTP/1.1" | grep -v "X-Testing-Dupe: " | cut -c 10-12)
if [[ "$RV" != "201" ]]; then
    echo ""
    echo "Second PUT failed :-(\n";
    echo $RV
    echo $LOCATION
    exit;
fi;
 
echo "testKeyhole should be able to PUT testKeyhole's status back to true";
RV=$(curl -i -X PUT -H 'Connection: close' -H 'X-APIKey: 798e31c43d6b9f03aa504a6f88cb4550' -H 'Content-Type: application/json;v=1.0' -u 'testKeyhole:test' --data '{"keyhole_status":"true"}' https://rest.mpsvr.com:443/subscribers/11/keyhole | grep "HTTP/1.1" | grep -v "X-Testing-Dupe: " | cut -c 10-12)
if [[ "$RV" != "201" ]]; then
    echo ""
    echo "Third PUT failed :-(\n";
    echo $RV
    echo $LOCATION
    exit;
fi;
 
 
echo "Completed successfully"