-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-auth.bat
More file actions
148 lines (126 loc) · 3.54 KB
/
test-auth.bat
File metadata and controls
148 lines (126 loc) · 3.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
@echo off
setlocal enabledelayedexpansion
echo 🔐 Azure PostgreSQL Authentication Test Suite (Windows)
echo =======================================================
echo.
:test_prerequisites
echo 📋 Testing Prerequisites
echo ---------------------------------
rem Check Java
java -version >nul 2>&1
if %errorlevel% == 0 (
echo [SUCCESS] Java is installed
java -version
) else (
echo [ERROR] Java not found. Please install JDK 17 or higher.
pause
exit /b 1
)
echo.
rem Check Gradle
gradle --version >nul 2>&1
if %errorlevel% == 0 (
echo [SUCCESS] Gradle is installed
gradle --version | findstr "Gradle"
) else (
echo [WARNING] Gradle not found. Using gradlew if available.
)
echo.
rem Check Azure CLI
az --version >nul 2>&1
if %errorlevel% == 0 (
echo [SUCCESS] Azure CLI is installed
az --version | findstr "azure-cli"
) else (
echo [ERROR] Azure CLI not found. Please install Azure CLI.
pause
exit /b 1
)
echo.
rem Check Azure authentication
az account show >nul 2>&1
if %errorlevel% == 0 (
echo [SUCCESS] Azure CLI is authenticated:
az account show --query "{name:name, user:user.name}" -o table
) else (
echo [WARNING] Azure CLI is not authenticated. Run 'az login' to authenticate.
set /p response="Would you like to login now? (y/n): "
if /i "!response!"=="y" (
az login
)
)
echo.
:show_menu
echo 🎯 Select Test Option:
echo 1^) Test Azure Plugin Approach (Recommended)
echo 2^) Test Manual Token Approach
echo 3^) Test Both Approaches
echo 4^) Run Prerequisites Check Only
echo 5^) Exit
echo.
set /p choice="Enter your choice (1-5): "
if "%choice%"=="1" goto test_plugin
if "%choice%"=="2" goto test_manual
if "%choice%"=="3" goto test_both
if "%choice%"=="4" goto test_prerequisites
if "%choice%"=="5" goto exit_script
echo [ERROR] Invalid choice. Please select 1-5.
goto show_menu
:test_plugin
echo.
echo 🧪 Testing Azure Plugin Approach
echo =============================================
call :run_approach "azure-plugin-approach" "Azure Plugin Approach"
goto continue
:test_manual
echo.
echo 🧪 Testing Manual Token Approach
echo =============================================
call :run_approach "manual-token-approach" "Manual Token Approach"
goto continue
:test_both
echo.
echo 🔄 Testing Both Approaches
echo =============================================
call :run_approach "azure-plugin-approach" "Azure Plugin Approach"
echo.
call :run_approach "manual-token-approach" "Manual Token Approach"
echo.
echo 📊 Summary
echo =============================================
echo [SUCCESS] Azure Plugin Approach: Automatic token management
echo [SUCCESS] Manual Token Approach: Full control over tokens
echo.
echo 🔧 Key Differences:
echo Azure Plugin: Uses azure-identity-extensions:1.1.14
echo Manual Token: Uses azure-identity:1.12.0
echo Azure Plugin: Plugin handles token refresh automatically
echo Manual Token: Manual token acquisition and management
goto continue
:run_approach
set approach=%~1
set approach_name=%~2
if not exist "%approach%" (
echo [ERROR] Directory %approach% not found!
exit /b 1
)
cd "%approach%"
echo [INFO] Building and running %approach_name%...
echo.
gradle run --quiet
if %errorlevel% neq 0 (
echo [ERROR] Failed to run %approach_name%
cd ..
exit /b 1
)
cd ..
echo [SUCCESS] %approach_name% test completed!
exit /b 0
:continue
echo.
pause
goto show_menu
:exit_script
echo Goodbye!
pause
exit /b 0