insightfy-bloom-ms-mpms / test_enhanced_login_api.sh
MukeshKapoor25's picture
feat(auth): Enhance Login API with Access Menu Support
5836efd
#!/bin/bash
# Test script for enhanced merchant login API
# This script demonstrates the enhanced login endpoint with access menu
echo "Testing Enhanced Merchant Login API"
echo "===================================="
# API endpoint
BASE_URL="http://127.0.0.1:8000"
LOGIN_ENDPOINT="$BASE_URL/merchant/login"
# Test credentials (same as your curl request)
LOGIN_INPUT="mk@bookmyservice.tech"
OTP="777777"
echo "Endpoint: $LOGIN_ENDPOINT"
echo "Login Input: $LOGIN_INPUT"
echo "OTP: $OTP"
echo ""
echo "Making login request..."
echo "----------------------"
# Make the enhanced login request
response=$(curl -s -X 'POST' \
"$LOGIN_ENDPOINT" \
-H 'accept: application/json' \
-H 'Content-Type: application/json' \
-d "{
\"login_input\": \"$LOGIN_INPUT\",
\"otp\": \"$OTP\"
}")
echo "Response received:"
echo "$response" | jq '.'
echo ""
echo "Analyzing response..."
echo "--------------------"
# Check if access_menu is present
if echo "$response" | jq -e '.access_menu' > /dev/null 2>&1; then
echo "✅ Access menu is present in response"
# Extract access menu details
permissions_count=$(echo "$response" | jq '.access_menu.permissions | length')
widgets_count=$(echo "$response" | jq '.access_menu.accessible_widgets | length')
menu_items_count=$(echo "$response" | jq '.access_menu.menu_items | length')
role_name=$(echo "$response" | jq -r '.access_menu.role_info.role_name')
echo " - Permissions: $permissions_count"
echo " - Accessible Widgets: $widgets_count"
echo " - Menu Items: $menu_items_count"
echo " - Role: $role_name"
# Show sample permissions
echo ""
echo "Sample Permissions:"
echo "$response" | jq -r '.access_menu.permissions[]' | head -5 | while read perm; do
echo " - $perm"
done
# Show menu items
echo ""
echo "Menu Items:"
echo "$response" | jq -r '.access_menu.menu_items[] | " - \(.label) (\(.route))"'
else
echo "❌ Access menu is not present in response"
fi
# Check for warnings
if echo "$response" | jq -e '.warnings' > /dev/null 2>&1; then
echo ""
echo "⚠️ Warnings found:"
echo "$response" | jq -r '.warnings[]' | while read warning; do
echo " - $warning"
done
fi
# Check API version
api_version=$(echo "$response" | jq -r '.api_version // "1.0"')
echo ""
echo "API Version: $api_version"
if [ "$api_version" = "2.0" ]; then
echo "✅ Enhanced API version detected"
else
echo "ℹ️ Using legacy API version"
fi
echo ""
echo "Test completed!"