Skip to content

Commit 13857eb

Browse files
committed
fixed the access mode values
Signed-off-by: kunal-511 <[email protected]>
1 parent 7316156 commit 13857eb

File tree

1 file changed

+28
-47
lines changed

1 file changed

+28
-47
lines changed

tests/gh-actions/test_volumes_web_application.sh

+28-47
Original file line numberDiff line numberDiff line change
@@ -18,52 +18,27 @@ curl --fail --show-error \
1818
-H "Authorization: Bearer ${TOKEN}" \
1919
-H "X-XSRF-TOKEN: $XSRFTOKEN" -H "Cookie: XSRF-TOKEN=$XSRFTOKEN"
2020

21-
echo "Attempting to create test-pvc..."
22-
RESPONSE=$(curl -v -X POST \
21+
echo "Creating test-pvc..."
22+
curl --fail --show-error -X POST \
2323
"localhost:8080/volumes/api/namespaces/${KF_PROFILE}/pvcs" \
2424
-H "Authorization: Bearer ${TOKEN}" \
2525
-H "Content-Type: application/json" \
2626
-H "X-XSRF-TOKEN: $XSRFTOKEN" -H "Cookie: XSRF-TOKEN=$XSRFTOKEN" \
2727
-d "{
2828
\"name\": \"test-pvc\",
2929
\"namespace\": \"${KF_PROFILE}\",
30-
\"spec\": {
31-
\"accessModes\": [\"ReadWriteOnce\"],
32-
\"resources\": {
33-
\"requests\": {
34-
\"storage\": \"1Gi\"
35-
}
36-
},
37-
\"storageClassName\": \"${STORAGE_CLASS_NAME}\"
38-
}
39-
}" 2>&1)
40-
41-
echo "Response from PVC creation attempt:"
42-
echo "$RESPONSE"
43-
44-
if [[ "$RESPONSE" == *"400"* ]]; then
45-
echo "First attempt failed with 400 error, trying alternative format..."
46-
curl --fail --show-error -X POST \
47-
"localhost:8080/volumes/api/namespaces/${KF_PROFILE}/pvcs" \
48-
-H "Authorization: Bearer ${TOKEN}" \
49-
-H "Content-Type: application/json" \
50-
-H "X-XSRF-TOKEN: $XSRFTOKEN" -H "Cookie: XSRF-TOKEN=$XSRFTOKEN" \
51-
-d "{
52-
\"name\": \"test-pvc\",
53-
\"namespace\": \"${KF_PROFILE}\",
54-
\"type\": \"new\",
55-
\"mode\": \"rwo\",
56-
\"size\": \"1Gi\",
57-
\"class\": \"${STORAGE_CLASS_NAME}\"
58-
}"
59-
fi
30+
\"type\": \"new\",
31+
\"mode\": \"ReadWriteOnce\",
32+
\"size\": \"1Gi\",
33+
\"class\": \"${STORAGE_CLASS_NAME}\"
34+
}"
6035

6136
curl --fail --show-error \
6237
"localhost:8080/volumes/api/namespaces/${KF_PROFILE}/pvcs" \
6338
-H "Authorization: Bearer ${TOKEN}" \
6439
-H "X-XSRF-TOKEN: $XSRFTOKEN" -H "Cookie: XSRF-TOKEN=$XSRFTOKEN"
6540

66-
UNAUTHORIZED_STATUS=$(curl --fail --silent --show-error -o /dev/null -w "%{http_code}" \
41+
UNAUTHORIZED_STATUS=$(curl --silent --output /dev/null -w "%{http_code}" \
6742
"localhost:8080/volumes/api/namespaces/${KF_PROFILE}/pvcs" \
6843
-H "Authorization: Bearer ${UNAUTHORIZED_TOKEN}")
6944
[[ "$UNAUTHORIZED_STATUS" == "403" ]] || exit 1
@@ -78,33 +53,30 @@ curl --fail --show-error -X POST \
7853
\"name\": \"api-created-pvc\",
7954
\"namespace\": \"${KF_PROFILE}\",
8055
\"type\": \"new\",
81-
\"mode\": \"rwo\",
56+
\"mode\": \"ReadWriteOnce\",
8257
\"size\": \"1Gi\",
8358
\"class\": \"${STORAGE_CLASS_NAME}\"
84-
}" > /dev/null
59+
}"
8560

86-
curl --fail --show-error -X DELETE \
61+
echo "Testing unauthorized deletion..."
62+
UNAUTH_DELETE_STATUS=$(curl --silent --output /dev/null -w "%{http_code}" -X DELETE \
8763
"localhost:8080/volumes/api/namespaces/${KF_PROFILE}/pvcs/test-pvc" \
8864
-H "Authorization: Bearer ${UNAUTHORIZED_TOKEN}" \
89-
-H "X-XSRF-TOKEN: $XSRFTOKEN" -H "Cookie: XSRF-TOKEN=$XSRFTOKEN" || true
65+
-H "X-XSRF-TOKEN: $XSRFTOKEN" -H "Cookie: XSRF-TOKEN=$XSRFTOKEN")
66+
[[ "$UNAUTH_DELETE_STATUS" == "403" ]] || echo "Warning: Unexpected status code for unauthorized delete: $UNAUTH_DELETE_STATUS"
9067

9168
if ! kubectl get pvc test-pvc -n $KF_PROFILE > /dev/null 2>&1; then
92-
UNAUTHORIZED_DELETE_RESPONSE=$(curl --fail --silent --show-error \
93-
"localhost:8080/volumes/api/namespaces/${KF_PROFILE}/pvcs/test-pvc" \
94-
-H "Authorization: Bearer ${TOKEN}" \
95-
-H "X-XSRF-TOKEN: $XSRFTOKEN" -H "Cookie: XSRF-TOKEN=$XSRFTOKEN")
96-
if [[ "$UNAUTHORIZED_DELETE_RESPONSE" == *"not found"* || "$UNAUTHORIZED_DELETE_RESPONSE" == *"\"code\":404"* ]]; then
97-
echo "ERROR: PVC was deleted by unauthorized request or is missing"
98-
exit 1
99-
fi
69+
echo "ERROR: PVC 'test-pvc' not found after unauthorized deletion attempt"
70+
exit 1
10071
fi
10172

73+
echo "Deleting test-pvc with authorized request..."
10274
curl --fail --show-error -X DELETE \
10375
"localhost:8080/volumes/api/namespaces/${KF_PROFILE}/pvcs/test-pvc" \
10476
-H "Authorization: Bearer ${TOKEN}" \
10577
-H "X-XSRF-TOKEN: $XSRFTOKEN" -H "Cookie: XSRF-TOKEN=$XSRFTOKEN"
10678

107-
DELETE_STATUS=$(curl --fail --silent --show-error -o /dev/null -w "%{http_code}" \
79+
DELETE_STATUS=$(curl --silent --output /dev/null -w "%{http_code}" \
10880
"localhost:8080/volumes/api/namespaces/${KF_PROFILE}/pvcs/test-pvc" \
10981
-H "Authorization: Bearer ${TOKEN}" \
11082
-H "X-XSRF-TOKEN: $XSRFTOKEN" -H "Cookie: XSRF-TOKEN=$XSRFTOKEN")
@@ -113,6 +85,15 @@ DELETE_STATUS=$(curl --fail --silent --show-error -o /dev/null -w "%{http_code}"
11385
exit 1
11486
}
11587

116-
kubectl get pvc test-pvc -n $KF_PROFILE 2>/dev/null && exit 1
88+
kubectl get pvc test-pvc -n $KF_PROFILE 2>/dev/null && {
89+
echo "ERROR: PVC 'test-pvc' still exists after deletion"
90+
exit 1
91+
} || true
92+
93+
echo "Cleaning up api-created-pvc..."
94+
curl --fail --show-error -X DELETE \
95+
"localhost:8080/volumes/api/namespaces/${KF_PROFILE}/pvcs/api-created-pvc" \
96+
-H "Authorization: Bearer ${TOKEN}" \
97+
-H "X-XSRF-TOKEN: $XSRFTOKEN" -H "Cookie: XSRF-TOKEN=$XSRFTOKEN"
11798

11899
echo "Test completed successfully!"

0 commit comments

Comments
 (0)