@@ -129,104 +129,4 @@ done
129129if [[ $FOUND == 0 ]]; then
130130 echo " Did not find any policy events after 10 attempts..."
131131 exit 1
132- fi
133-
134-
135- #
136- # Test it again with policy API V1
137- #
138-
139- # Delete all policies and then get them. There should be none.
140- $SCRIPTDIR /../examples/delete_all_policies_v1.py $PYTHON_SDC_TEST_API_TOKEN
141- OUT=` $SCRIPTDIR /../examples/list_policies_v1.py $PYTHON_SDC_TEST_API_TOKEN `
142- if [[ $OUT != * " \" policies\" : []" * ]]; then
143- echo " Unexpected output after deleting all policies V1"
144- exit 1
145- fi
146-
147- # Create the default set of policies and then get them. There should
148- # be 1, corresponding to the system falco rule.
149- $SCRIPTDIR /../examples/create_default_policies_v1.py $PYTHON_SDC_TEST_API_TOKEN
150- OUT=` $SCRIPTDIR /../examples/list_policies_v1.py $PYTHON_SDC_TEST_API_TOKEN `
151- if [[ $OUT != * " \" name\" : \" Write below binary dir\" " * ]]; then
152- echo " Unexpected output after creating default policies V1"
153- exit 1
154- fi
155-
156- # Get that policy, change the name, and create a new duplicate policy.
157- OUT=` $SCRIPTDIR /../examples/get_policy_v1.py $PYTHON_SDC_TEST_API_TOKEN " Write below binary dir" `
158- MY_POLICY=$OUT
159- if [[ $OUT != * " \" name\" : \" Write below binary dir\" " * ]]; then
160- echo " Could not fetch policy V1 with name \" Write below binary dir\" "
161- exit 1
162- fi
163-
164- 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/' `
165- OUT=` echo $NEW_POLICY | $SCRIPTDIR /../examples/add_policy_v1.py $PYTHON_SDC_TEST_API_TOKEN `
166- if [[ $OUT != * " \" name\" : \" Copy Of Write below binary dir\" " * ]]; then
167- echo " Could not create new policy V1"
168- exit 1
169- fi
170-
171- # Change the description of the new policy and update it.
172- MODIFIED_POLICY=` echo $MY_POLICY | sed -e " s/an attempt to write to any file below a set of binary directories/My New Description/g" `
173- OUT=` echo $MODIFIED_POLICY | $SCRIPTDIR /../examples/update_policy_v1.py $PYTHON_SDC_TEST_API_TOKEN `
174- if [[ $OUT != * " \" description\" : \" My New Description\" " * ]]; then
175- echo " Could not update policy V1 \" Copy Of Write below binary dir\" "
176- exit 1
177- fi
178-
179- # Delete the new policy.
180- OUT=` $SCRIPTDIR /../examples/delete_policy_v1.py --name " Copy Of Write below binary dir" $PYTHON_SDC_TEST_API_TOKEN `
181- if [[ $OUT != * " \" name\" : \" Copy Of Write below binary dir\" " * ]]; then
182- echo " Could not delete policy V1 \" Copy Of Write below binary dir\" "
183- exit 1
184- fi
185-
186- OUT=` $SCRIPTDIR /../examples/list_policies_v1.py $PYTHON_SDC_TEST_API_TOKEN `
187- if [[ $OUT = * " \" name\" : \" Copy Of Write below binary dir\" " * ]]; then
188- echo " After deleting policy V1 Copy Of Write below binary dir, policy was still present?"
189- exit 1
190- fi
191-
192- # Make a copy again, but this time delete by id
193- 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/' `
194- OUT=` echo $NEW_POLICY | $SCRIPTDIR /../examples/add_policy_v1.py $PYTHON_SDC_TEST_API_TOKEN `
195- if [[ $OUT != * " \" name\" : \" Another Copy Of Write below binary dir\" " * ]]; then
196- echo " Could not create new policy V1"
197- exit 1
198- fi
199-
200- ID=` echo $OUT | grep -E -o ' "id": [^,]+,' | awk ' {print $2}' | awk -F, ' {print $1}' `
201-
202- OUT=` $SCRIPTDIR /../examples/delete_policy_v1.py --id $ID $PYTHON_SDC_TEST_API_TOKEN `
203- if [[ $OUT != * " \" name\" : \" Another Copy Of Write below binary dir\" " * ]]; then
204- echo " Could not delete policy V1 \" Copy Of Write below binary dir\" "
205- exit 1
206- fi
207-
208- OUT=` $SCRIPTDIR /../examples/list_policies_v1.py $PYTHON_SDC_TEST_API_TOKEN `
209- if [[ $OUT = * " \" name\" : \" Another Copy Of Write below binary dir\" " * ]]; then
210- echo " After deleting policy V1 Another Copy Of Write below binary dir, policy was still present?"
211- exit 1
212- fi
213-
214-
215- WRITE_BELOW_BINARY_POS=` $SCRIPTDIR /../examples/list_policies_v1.py $PYTHON_SDC_TEST_API_TOKEN | grep -b " \" name\" : \" Write below binary dir" | awk -F: ' {print $1}' `
216-
217- # Get the list of policy ids only, reverse the list, and set the order
218- OUT=` $SCRIPTDIR /../examples/list_policies_v1.py -o $PYTHON_SDC_TEST_API_TOKEN | jq reverse | $SCRIPTDIR /../examples/set_policy_order_v1.py $PYTHON_SDC_TEST_API_TOKEN `
219-
220- if [ $? != 0 ]; then
221- echo " Could not set policy order?"
222- exit 1
223- fi
224-
225- NEW_WRITE_BELOW_BINARY_POS=` $SCRIPTDIR /../examples/list_policies_v1.py $PYTHON_SDC_TEST_API_TOKEN | grep -b " \" name\" : \" Write below binary dir" | awk -F: ' {print $1}' `
226-
227- if [[ $NEW_WRITE_BELOW_BINARY_POS -lt $WRITE_BELOW_BINARY_POS ]]; then
228- echo " After reordering policies, Write Below Binary Dir policy did not move to the end?"
229- exit 1
230- fi
231-
232- echo $OUT
132+ fi
0 commit comments