-RESULT="json:{\"title\": \"Duplicate, the policy json already exists.\", \"status\": 400, \"instance\": \"pi2\"}"
-do_curl PUT /A1-P/v2/policytypes/STD_1/policies/pi2 400 jsonfiles/pi1_updated.json
+if [ $DUP_CHECK == 1 ]; then
+ #Fail with dupl check
+ RESULT="json:{\"title\": \"Duplicate, the policy json already exists.\", \"status\": 400, \"instance\": \"pi2\"}"
+ do_curl PUT /A1-P/v2/policytypes/STD_1/policies/pi2 400 jsonfiles/pi1_updated.json
+else
+ #OK without dupl check
+ res=$(cat jsonfiles/pi1_updated.json)
+ RESULT="json:$res"
+ do_curl PUT /A1-P/v2/policytypes/STD_1/policies/pi2 201 jsonfiles/pi1_updated.json
+
+ if [ $EXT_SRV_EXIST == 1 ]; then
+ echo "=== External server, get a pi2 policy: pi2 ==="
+ res=$(cat jsonfiles/pi1_updated.json)
+ RESULT="json:$res"
+ do_curl_ext_srv GET /a1policy/pi2 200
+ fi
+
+ echo "=== API: DELETE policy instance pi2 ==="
+ RESULT=""
+ do_curl DELETE /A1-P/v2/policytypes/STD_1/policies/pi2 204
+
+ if [ $EXT_SRV_EXIST == 1 ]; then
+ echo "=== External server, get a pi2 policy: policy instance not found ==="
+ RESULT="json:{\"title\": \"The A1 policy requested does not exist.\", \"status\": 404, \"instance\": \"pi2\"}"
+ do_curl_ext_srv GET /a1policy/pi2 404
+ fi
+fi