@@ -18,52 +18,27 @@ curl --fail --show-error \
18
18
-H " Authorization: Bearer ${TOKEN} " \
19
19
-H " X-XSRF-TOKEN: $XSRFTOKEN " -H " Cookie: XSRF-TOKEN=$XSRFTOKEN "
20
20
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 \
23
23
" localhost:8080/volumes/api/namespaces/${KF_PROFILE} /pvcs" \
24
24
-H " Authorization: Bearer ${TOKEN} " \
25
25
-H " Content-Type: application/json" \
26
26
-H " X-XSRF-TOKEN: $XSRFTOKEN " -H " Cookie: XSRF-TOKEN=$XSRFTOKEN " \
27
27
-d " {
28
28
\" name\" : \" test-pvc\" ,
29
29
\" 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
+ }"
60
35
61
36
curl --fail --show-error \
62
37
" localhost:8080/volumes/api/namespaces/${KF_PROFILE} /pvcs" \
63
38
-H " Authorization: Bearer ${TOKEN} " \
64
39
-H " X-XSRF-TOKEN: $XSRFTOKEN " -H " Cookie: XSRF-TOKEN=$XSRFTOKEN "
65
40
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}" \
67
42
" localhost:8080/volumes/api/namespaces/${KF_PROFILE} /pvcs" \
68
43
-H " Authorization: Bearer ${UNAUTHORIZED_TOKEN} " )
69
44
[[ " $UNAUTHORIZED_STATUS " == " 403" ]] || exit 1
@@ -78,33 +53,30 @@ curl --fail --show-error -X POST \
78
53
\" name\" : \" api-created-pvc\" ,
79
54
\" namespace\" : \" ${KF_PROFILE} \" ,
80
55
\" type\" : \" new\" ,
81
- \" mode\" : \" rwo \" ,
56
+ \" mode\" : \" ReadWriteOnce \" ,
82
57
\" size\" : \" 1Gi\" ,
83
58
\" class\" : \" ${STORAGE_CLASS_NAME} \"
84
- }" > /dev/null
59
+ }"
85
60
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 \
87
63
" localhost:8080/volumes/api/namespaces/${KF_PROFILE} /pvcs/test-pvc" \
88
64
-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 "
90
67
91
68
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
100
71
fi
101
72
73
+ echo " Deleting test-pvc with authorized request..."
102
74
curl --fail --show-error -X DELETE \
103
75
" localhost:8080/volumes/api/namespaces/${KF_PROFILE} /pvcs/test-pvc" \
104
76
-H " Authorization: Bearer ${TOKEN} " \
105
77
-H " X-XSRF-TOKEN: $XSRFTOKEN " -H " Cookie: XSRF-TOKEN=$XSRFTOKEN "
106
78
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}" \
108
80
" localhost:8080/volumes/api/namespaces/${KF_PROFILE} /pvcs/test-pvc" \
109
81
-H " Authorization: Bearer ${TOKEN} " \
110
82
-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}"
113
85
exit 1
114
86
}
115
87
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 "
117
98
118
99
echo " Test completed successfully!"
0 commit comments