Skip to content

Commit 8996c1e

Browse files
haresh-sureshDavide Schiera
authored andcommitted
Fixing v1 - v2 policy response checks (#106)
1 parent ffce2d6 commit 8996c1e

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

test/test_secure_apis.sh

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -45,26 +45,26 @@ if [[ $OUT != *"\"policies\": []"* ]]; then
4545
exit 1
4646
fi
4747

48-
# Create the default set of policies and then get them. There should
48+
# Create the default set of policies and then fetch them. There should
4949
# be 1, corresponding to the system falco rule.
5050
$SCRIPTDIR/../examples/create_default_policies.py $PYTHON_SDC_TEST_API_TOKEN
5151
OUT=`$SCRIPTDIR/../examples/list_policies.py $PYTHON_SDC_TEST_API_TOKEN`
52-
if [[ $OUT != *"\"name\": \"Write below binary dir\""* ]]; then
52+
if [[ $OUT != *"\"Write below binary dir\""* ]]; then
5353
echo "Unexpected output after creating default policies"
5454
exit 1
5555
fi
5656

5757
# Get that policy, change the name, and create a new duplicate policy.
5858
OUT=`$SCRIPTDIR/../examples/get_policy.py $PYTHON_SDC_TEST_API_TOKEN "Write below binary dir"`
5959
MY_POLICY=$OUT
60-
if [[ $OUT != *"\"name\": \"Write below binary dir\""* ]]; then
60+
if [[ $OUT != *"\"Write below binary dir\""* ]]; then
6161
echo "Could not fetch policy with name \"Write below binary dir\""
6262
exit 1
6363
fi
6464

6565
NEW_POLICY=`echo $MY_POLICY | sed -e "s/Write below binary dir/Copy Of Write below binary dir/g" | sed -e 's/"id": [0-9]*,//' | sed -e 's/"version": [0-9]*/"version": null/'`
6666
OUT=`echo $NEW_POLICY | $SCRIPTDIR/../examples/add_policy.py $PYTHON_SDC_TEST_API_TOKEN`
67-
if [[ $OUT != *"\"name\": \"Copy Of Write below binary dir\""* ]]; then
67+
if [[ $OUT != *"\"Copy Of Write below binary dir\""* ]]; then
6868
echo "Could not create new policy"
6969
exit 1
7070
fi
@@ -79,35 +79,35 @@ fi
7979

8080
# Delete the new policy.
8181
OUT=`$SCRIPTDIR/../examples/delete_policy.py --name "Copy Of Write below binary dir" $PYTHON_SDC_TEST_API_TOKEN`
82-
if [[ $OUT != *"\"name\": \"Copy Of Write below binary dir\""* ]]; then
82+
if [[ $OUT != *"\"Copy Of Write below binary dir\""* ]]; then
8383
echo "Could not delete policy \"Copy Of Write below binary dir\""
8484
exit 1
8585
fi
8686

8787
OUT=`$SCRIPTDIR/../examples/list_policies.py $PYTHON_SDC_TEST_API_TOKEN`
88-
if [[ $OUT = *"\"name\": \"Copy Of Write below binary dir\""* ]]; then
88+
if [[ $OUT = *"\"Copy Of Write below binary dir\""* ]]; then
8989
echo "After deleting policy Copy Of Write below binary dir, policy was still present?"
9090
exit 1
9191
fi
9292

9393
# Make a copy again, but this time delete by id
9494
NEW_POLICY=`echo $MY_POLICY | sed -e "s/Write below binary dir/Another Copy Of Write below binary dir/g" | sed -e 's/"id": [0-9]*,//' | sed -e 's/"version": [0-9]*/"version": null/'`
9595
OUT=`echo $NEW_POLICY | $SCRIPTDIR/../examples/add_policy.py $PYTHON_SDC_TEST_API_TOKEN`
96-
if [[ $OUT != *"\"name\": \"Another Copy Of Write below binary dir\""* ]]; then
96+
if [[ $OUT != *"\"Another Copy Of Write below binary dir\""* ]]; then
9797
echo "Could not create new policy"
9898
exit 1
9999
fi
100100

101101
ID=`echo $OUT | grep -E -o '"id": [^,]+,' | awk '{print $2}' | awk -F, '{print $1}'`
102102

103103
OUT=`$SCRIPTDIR/../examples/delete_policy.py --id $ID $PYTHON_SDC_TEST_API_TOKEN`
104-
if [[ $OUT != *"\"name\": \"Another Copy Of Write below binary dir\""* ]]; then
104+
if [[ $OUT != *"\"Another Copy Of Write below binary dir\""* ]]; then
105105
echo "Could not delete policy \"Copy Of Write below binary dir\""
106106
exit 1
107107
fi
108108

109109
OUT=`$SCRIPTDIR/../examples/list_policies.py $PYTHON_SDC_TEST_API_TOKEN`
110-
if [[ $OUT = *"\"name\": \"Another Copy Of Write below binary dir\""* ]]; then
110+
if [[ $OUT = *"\"Another Copy Of Write below binary dir\""* ]]; then
111111
echo "After deleting policy Another Copy Of Write below binary dir, policy was still present?"
112112
exit 1
113113
fi

0 commit comments

Comments
 (0)