Revert response code logic

Signed-off-by: Christian König <github@yubiuser.dev>
This commit is contained in:
Christian König
2025-05-04 21:45:44 +02:00
parent 1bea6db50a
commit fc103af050

View File

@@ -57,34 +57,33 @@ TestAPIAvailability() {
authData=$(printf %s "${authResponse%???}") authData=$(printf %s "${authResponse%???}")
# Test if http status code was 200 (OK) or 401 (authentication required) # Test if http status code was 200 (OK) or 401 (authentication required)
if [ ! "${authStatus}" = 200 ] && [ ! "${authStatus}" = 401 ]; then if [ "${authStatus}" = 200 ]; then
# API is not available at this port/protocol combination # API is available without authentication
apiAvailable=false apiAvailable=true
else needAuth=false
# API is available at this URL combination break
if [ "${authStatus}" = 200 ]; then
# API is available without authentication
needAuth=false
fi
elif [ "${authStatus}" = 401 ]; then
# API is available with authentication
apiAvailable=true
needAuth=true
# Check if 2FA is required # Check if 2FA is required
needTOTP=$(echo "${authData}"| jq --raw-output .session.totp 2>/dev/null) needTOTP=$(echo "${authData}"| jq --raw-output .session.totp 2>/dev/null)
apiAvailable=true
break break
fi
# Remove the first URL from the list else
local last_api_list # API is not available at this port/protocol combination
last_api_list="${chaos_api_list}" apiAvailable=false
chaos_api_list="${chaos_api_list#* }" # Remove the first URL from the list
local last_api_list
last_api_list="${chaos_api_list}"
chaos_api_list="${chaos_api_list#* }"
# If the list did not change, we are at the last element # If the list did not change, we are at the last element
if [ "${last_api_list}" = "${chaos_api_list}" ]; then if [ "${last_api_list}" = "${chaos_api_list}" ]; then
# Remove the last element # Remove the last element
chaos_api_list="" chaos_api_list=""
fi
fi fi
done done