forked from krkn-chaos/krkn
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Tullio Sebastiani <[email protected]> test fix Signed-off-by: Tullio Sebastiani <[email protected]> fix Signed-off-by: Tullio Sebastiani <[email protected]> fixed test Signed-off-by: Tullio Sebastiani <[email protected]> fix Signed-off-by: Tullio Sebastiani <[email protected]> fix test Signed-off-by: Tullio Sebastiani <[email protected]> fixed funtest Signed-off-by: Tullio Sebastiani <[email protected]> funtest fix Signed-off-by: Tullio Sebastiani <[email protected]> minor nit Signed-off-by: Tullio Sebastiani <[email protected]> added explicit curl method Signed-off-by: Tullio Sebastiani <[email protected]> push Signed-off-by: Tullio Sebastiani <[email protected]> fix Signed-off-by: Tullio Sebastiani <[email protected]> restored all funtests Signed-off-by: Tullio Sebastiani <[email protected]> added mime type test Signed-off-by: Tullio Sebastiani <[email protected]> fixed pipeline Signed-off-by: Tullio Sebastiani <[email protected]>
- Loading branch information
1 parent
804b38e
commit 4a98cc4
Showing
5 changed files
with
141 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
apiVersion: v1 | ||
kind: Pod | ||
metadata: | ||
name: nginx | ||
labels: | ||
app.kubernetes.io/name: proxy | ||
spec: | ||
containers: | ||
- name: nginx | ||
image: nginx:stable | ||
ports: | ||
- containerPort: 80 | ||
name: http-web-svc | ||
|
||
--- | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: nginx-service | ||
spec: | ||
selector: | ||
app.kubernetes.io/name: proxy | ||
type: NodePort | ||
ports: | ||
- name: name-of-service-port | ||
protocol: TCP | ||
port: 80 | ||
targetPort: http-web-svc | ||
nodePort: 30036 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
set -xeEo pipefail | ||
|
||
source CI/tests/common.sh | ||
|
||
trap error ERR | ||
trap finish EXIT | ||
# port mapping has been configured in kind-config.yml | ||
SERVICE_URL=http://localhost:8888 | ||
PAYLOAD_GET_1="{ \ | ||
\"status\":\"internal server error\" \ | ||
}" | ||
STATUS_CODE_GET_1=500 | ||
|
||
PAYLOAD_PATCH_1="resource patched" | ||
STATUS_CODE_PATCH_1=201 | ||
|
||
PAYLOAD_POST_1="{ \ | ||
\"status\": \"unauthorized\" \ | ||
}" | ||
STATUS_CODE_POST_1=401 | ||
|
||
PAYLOAD_GET_2="{ \ | ||
\"status\":\"resource created\" \ | ||
}" | ||
STATUS_CODE_GET_2=201 | ||
|
||
PAYLOAD_PATCH_2="bad request" | ||
STATUS_CODE_PATCH_2=400 | ||
|
||
PAYLOAD_POST_2="not found" | ||
STATUS_CODE_POST_2=404 | ||
|
||
JSON_MIME="application/json" | ||
TEXT_MIME="text/plain" | ||
|
||
function functional_test_service_hijacking { | ||
|
||
export scenario_type="service_hijacking" | ||
export scenario_file="scenarios/kube/service_hijacking.yaml" | ||
export post_config="" | ||
envsubst < CI/config/common_test_config.yaml > CI/config/service_hijacking.yaml | ||
python3 -m coverage run -a run_kraken.py -c CI/config/service_hijacking.yaml > /dev/null 2>&1 & | ||
PID=$! | ||
while [ `curl -X GET -s -o /dev/null -I -w "%{http_code}" $SERVICE_URL/list/index.php` == 404 ]; do echo "waiting scenario to kick in."; sleep 1; done; | ||
OUT_GET="`curl -X GET -s $SERVICE_URL/list/index.php`" | ||
OUT_CONTENT=`curl -X GET -s -o /dev/null -I -w "%{content_type}" $SERVICE_URL/list/index.php` | ||
OUT_STATUS_CODE=`curl -X GET -s -o /dev/null -I -w "%{http_code}" $SERVICE_URL/list/index.php` | ||
[ "${PAYLOAD_GET_1//[$'\t\r\n ']}" == "${OUT_GET//[$'\t\r\n ']}" ] && echo "Step 1 GET Payload OK" || (echo "Payload did not match. Test failed." && exit 1) | ||
[ "$OUT_STATUS_CODE" == "$STATUS_CODE_GET_1" ] && echo "Step 1 GET Status Code OK" || (echo " Step 1 GET status code did not match. Test failed." && exit 1) | ||
[ "$OUT_CONTENT" == "$JSON_MIME" ] && echo "Step 1 GET MIME OK" || (echo " Step 1 GET MIME did not match. Test failed." && exit 1) | ||
|
||
OUT_POST="`curl -s -X POST $SERVICE_URL/list/index.php`" | ||
OUT_STATUS_CODE=`curl -X POST -s -o /dev/null -I -w "%{http_code}" $SERVICE_URL/list/index.php` | ||
OUT_CONTENT=`curl -X POST -s -o /dev/null -I -w "%{content_type}" $SERVICE_URL/list/index.php` | ||
[ "${PAYLOAD_POST_1//[$'\t\r\n ']}" == "${OUT_POST//[$'\t\r\n ']}" ] && echo "Step 1 POST Payload OK" || (echo "Payload did not match. Test failed." && exit 1) | ||
[ "$OUT_STATUS_CODE" == "$STATUS_CODE_POST_1" ] && echo "Step 1 POST Status Code OK" || (echo "Step 1 POST status code did not match. Test failed." && exit 1) | ||
[ "$OUT_CONTENT" == "$JSON_MIME" ] && echo "Step 1 POST MIME OK" || (echo " Step 1 POST MIME did not match. Test failed." && exit 1) | ||
|
||
OUT_PATCH="`curl -s -X PATCH $SERVICE_URL/patch`" | ||
OUT_STATUS_CODE=`curl -X PATCH -s -o /dev/null -I -w "%{http_code}" $SERVICE_URL/patch` | ||
OUT_CONTENT=`curl -X PATCH -s -o /dev/null -I -w "%{content_type}" $SERVICE_URL/patch` | ||
[ "${PAYLOAD_PATCH_1//[$'\t\r\n ']}" == "${OUT_PATCH//[$'\t\r\n ']}" ] && echo "Step 1 PATCH Payload OK" || (echo "Payload did not match. Test failed." && exit 1) | ||
[ "$OUT_STATUS_CODE" == "$STATUS_CODE_PATCH_1" ] && echo "Step 1 PATCH Status Code OK" || (echo "Step 1 PATCH status code did not match. Test failed." && exit 1) | ||
[ "$OUT_CONTENT" == "$TEXT_MIME" ] && echo "Step 1 PATCH MIME OK" || (echo " Step 1 PATCH MIME did not match. Test failed." && exit 1) | ||
# wait for the next step | ||
sleep 16 | ||
|
||
OUT_GET="`curl -X GET -s $SERVICE_URL/list/index.php`" | ||
OUT_CONTENT=`curl -X GET -s -o /dev/null -I -w "%{content_type}" $SERVICE_URL/list/index.php` | ||
OUT_STATUS_CODE=`curl -X GET -s -o /dev/null -I -w "%{http_code}" $SERVICE_URL/list/index.php` | ||
[ "${PAYLOAD_GET_2//[$'\t\r\n ']}" == "${OUT_GET//[$'\t\r\n ']}" ] && echo "Step 2 GET Payload OK" || (echo "Step 2 GET Payload did not match. Test failed." && exit 1) | ||
[ "$OUT_STATUS_CODE" == "$STATUS_CODE_GET_2" ] && echo "Step 2 GET Status Code OK" || (echo "Step 2 GET status code did not match. Test failed." && exit 1) | ||
[ "$OUT_CONTENT" == "$JSON_MIME" ] && echo "Step 2 GET MIME OK" || (echo " Step 2 GET MIME did not match. Test failed." && exit 1) | ||
|
||
OUT_POST="`curl -s -X POST $SERVICE_URL/list/index.php`" | ||
OUT_CONTENT=`curl -X POST -s -o /dev/null -I -w "%{content_type}" $SERVICE_URL/list/index.php` | ||
OUT_STATUS_CODE=`curl -X POST -s -o /dev/null -I -w "%{http_code}" $SERVICE_URL/list/index.php` | ||
[ "${PAYLOAD_POST_2//[$'\t\r\n ']}" == "${OUT_POST//[$'\t\r\n ']}" ] && echo "Step 2 POST Payload OK" || (echo "Step 2 POST Payload did not match. Test failed." && exit 1) | ||
[ "$OUT_STATUS_CODE" == "$STATUS_CODE_POST_2" ] && echo "Step 2 POST Status Code OK" || (echo "Step 2 POST status code did not match. Test failed." && exit 1) | ||
[ "$OUT_CONTENT" == "$TEXT_MIME" ] && echo "Step 2 POST MIME OK" || (echo " Step 2 POST MIME did not match. Test failed." && exit 1) | ||
|
||
OUT_PATCH="`curl -s -X PATCH $SERVICE_URL/patch`" | ||
OUT_CONTENT=`curl -X PATCH -s -o /dev/null -I -w "%{content_type}" $SERVICE_URL/patch` | ||
OUT_STATUS_CODE=`curl -X PATCH -s -o /dev/null -I -w "%{http_code}" $SERVICE_URL/patch` | ||
[ "${PAYLOAD_PATCH_2//[$'\t\r\n ']}" == "${OUT_PATCH//[$'\t\r\n ']}" ] && echo "Step 2 PATCH Payload OK" || (echo "Step 2 PATCH Payload did not match. Test failed." && exit 1) | ||
[ "$OUT_STATUS_CODE" == "$STATUS_CODE_PATCH_2" ] && echo "Step 2 PATCH Status Code OK" || (echo "Step 2 PATCH status code did not match. Test failed." && exit 1) | ||
[ "$OUT_CONTENT" == "$TEXT_MIME" ] && echo "Step 2 PATCH MIME OK" || (echo " Step 2 PATCH MIME did not match. Test failed." && exit 1) | ||
wait $PID | ||
echo "Service Hijacking Chaos test: Success" | ||
} | ||
|
||
|
||
functional_test_service_hijacking |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters