Skip to content

Commit

Permalink
COSI-52: e2e-test-for-revoke-bucket-access
Browse files Browse the repository at this point in the history
  • Loading branch information
anurag4DSB committed Dec 10, 2024
1 parent ce0a3bf commit 1163bf0
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
3 changes: 1 addition & 2 deletions .github/scripts/cleanup_cosi_resources.sh
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,7 @@ for BUCKET_NAME in $BUCKET_NAMES; do
log_and_run kubectl patch bucket "$BUCKET_NAME" -p '{"metadata":{"finalizers":[]}}' --type=merge || { echo "Finalizers not found for bucket: $BUCKET_NAME" | tee -a "$LOG_FILE"; }
done

log_and_run echo "Deleting Bucket Access and Bucket Access Class..."
log_and_run kubectl delete -f cosi-examples/bucketaccess.yaml || { echo "No BucketAccess resources found." | tee -a "$LOG_FILE"; }
log_and_run echo "Deleting Bucket Access Class..."
log_and_run kubectl delete -f cosi-examples/bucketaccessclass.yaml --all || { echo "No BucketAccessClass resources found." | tee -a "$LOG_FILE"; }

log_and_run echo "Deleting Bucket Class and Bucket Claim..."
Expand Down
27 changes: 27 additions & 0 deletions .github/scripts/e2e_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -212,4 +212,31 @@ if [[ "$ACTUAL_PROTOCOLS" != "$EXPECTED_PROTOCOLS" ]]; then
exit 1
fi

# Step 11: Delete Bucket Access Resource
log_and_run echo "Deleting Bucket Access Resource..."
log_and_run kubectl delete -f cosi-examples/bucketaccess.yaml

# Step 12: Verify IAM User Deletion
log_and_run echo "Verifying IAM user '$IAM_USER_NAME' deletion..."
log_and_run aws --endpoint-url "$IAM_ENDPOINT" iam get-user --user-name "$IAM_USER_NAME"

# Retry logic for checking user deletion

for ((i=1; i<=$ATTEMPTS; i++)); do
USER_EXISTS="$(aws --endpoint-url "$IAM_ENDPOINT" iam get-user --user-name "$IAM_USER_NAME" 2>&1 || true)"

if [[ "$USER_EXISTS" == *"NoSuchEntity"* ]]; then
log_and_run echo "IAM user '$IAM_USER_NAME' successfully deleted."
break
else
log_and_run echo "Attempt $i: IAM user '$IAM_USER_NAME' still exists. Retrying in $DELETE_DELAY seconds..."
sleep $DELAY
fi
done

if [[ "$USER_EXISTS" != *"NoSuchEntity"* ]]; then
log_and_run echo "IAM user '$IAM_USER_NAME' was not deleted."
exit 1
fi

log_and_run echo "All verifications for object-storage-access-secret passed successfully."

0 comments on commit 1163bf0

Please sign in to comment.