fix(tests): repair framework paths, assertions, and arithmetic

The test suite referenced a Framework-Includes/ directory that does not
exist at the repo root (it is vendored under vendor/.../KNELShellFramework),
and asserted against functions the framework does not export.

- Point all tests at the vendored framework includes via a resolved
  FRAMEWORK_INCLUDES path
- Add print_success/print_warning/print_header shims where the vendored
  PrettyPrint only defines print_info/print_error
- Replace log_info/handle_error assertions with the real API:
  CURRENT_TIMESTAMP/LOGFILENAME variables and error_out/handle_failure
- Fix ((var++)) under set -e (returns 1 when var is 0) by using ((++var))
  across system-requirements, https-enforcement, 2fa-validation, and
  safe-download
- Fix infinite recursion in safe-download test_network_connectivity
  (was calling itself instead of the framework function)
- Make syntax validation shebang-aware so PHP agents (mysql.sh) are
  skipped instead of flagged as bash syntax errors

Framework unit test now passes (exit 0).

🤖 Generated with [Crush](https://github.com/charmassociates/crush)

Assisted-by: GLM-5 via Crush <crush@charm.land>
This commit is contained in:
Charles N Wyble
2026-07-25 13:49:47 -05:00
parent 688b7190e6
commit 5928d96aec
6 changed files with 117 additions and 97 deletions
+13 -12
View File
@@ -5,23 +5,24 @@
set -euo pipefail
PROJECT_ROOT="$(dirname "$(realpath "${BASH_SOURCE[0]}")")/../.."
PROJECT_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
FRAMEWORK_INCLUDES="$PROJECT_ROOT/vendor/git@git.knownelement.com/29418/KNEL/KNELShellFramework/Framework-Includes"
function test_no_http_urls() {
echo "🔍 Checking for HTTP URLs in scripts..."
local http_violations=0
local script_dirs=("ProjectCode" "Framework-Includes" "Project-Includes")
local script_dirs=("$PROJECT_ROOT/ProjectCode" "$FRAMEWORK_INCLUDES" "$PROJECT_ROOT/Project-Includes")
for dir in "${script_dirs[@]}"; do
if [[ -d "$PROJECT_ROOT/$dir" ]]; then
if [[ -d "$dir" ]]; then
# Find HTTP URLs in shell scripts (excluding comments)
while IFS= read -r -d '' file; do
if grep -n "http://" "$file" | grep -v "^[[:space:]]*#" | grep -v "schema.org" | grep -v "xmlns"; then
echo "❌ HTTP URL found in: $file"
((http_violations++))
((++http_violations))
fi
done < <(find "$PROJECT_ROOT/$dir" -name "*.sh" -type f -print0)
done < <(find "$dir" -name "*.sh" -type f -print0)
fi
done
@@ -37,12 +38,12 @@ function test_no_http_urls() {
function test_https_urls_valid() {
echo "🔍 Validating HTTPS URLs are accessible..."
local script_dirs=("ProjectCode" "Framework-Includes" "Project-Includes")
local script_dirs=("$PROJECT_ROOT/ProjectCode" "$FRAMEWORK_INCLUDES" "$PROJECT_ROOT/Project-Includes")
local https_failures=0
# Extract HTTPS URLs from scripts
for dir in "${script_dirs[@]}"; do
if [[ -d "$PROJECT_ROOT/$dir" ]]; then
if [[ -d "$dir" ]]; then
while IFS= read -r -d '' file; do
# Extract HTTPS URLs from non-comment lines
grep -o "https://[^[:space:]\"']*" "$file" | grep -v "schema.org" | while read -r url; do
@@ -51,10 +52,10 @@ function test_https_urls_valid() {
echo "✅ HTTPS URL accessible: $url"
else
echo "❌ HTTPS URL not accessible: $url"
((https_failures++))
((++https_failures))
fi
done
done < <(find "$PROJECT_ROOT/$dir" -name "*.sh" -type f -print0)
done < <(find "$dir" -name "*.sh" -type f -print0)
fi
done
@@ -78,7 +79,7 @@ function test_ssl_certificate_validation() {
echo "✅ SSL certificate valid: $url"
else
echo "❌ SSL certificate validation failed: $url"
((ssl_failures++))
((++ssl_failures))
fi
done