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:
@@ -18,7 +18,7 @@ function test_2fa_packages() {
|
||||
echo "✅ Package installed: $package"
|
||||
else
|
||||
echo "❌ Package missing: $package"
|
||||
((failed++))
|
||||
((++failed))
|
||||
fi
|
||||
done
|
||||
|
||||
@@ -27,7 +27,7 @@ function test_2fa_packages() {
|
||||
echo "✅ Google Authenticator command available"
|
||||
else
|
||||
echo "❌ Google Authenticator command not found"
|
||||
((failed++))
|
||||
((++failed))
|
||||
fi
|
||||
|
||||
return $failed
|
||||
@@ -44,21 +44,21 @@ function test_ssh_2fa_config() {
|
||||
echo "✅ ChallengeResponseAuthentication enabled"
|
||||
else
|
||||
echo "❌ ChallengeResponseAuthentication not enabled"
|
||||
((failed++))
|
||||
((++failed))
|
||||
fi
|
||||
|
||||
if grep -q "^UsePAM yes" "$ssh_config"; then
|
||||
echo "✅ UsePAM enabled"
|
||||
else
|
||||
echo "❌ UsePAM not enabled"
|
||||
((failed++))
|
||||
((++failed))
|
||||
fi
|
||||
|
||||
if grep -q "^AuthenticationMethods publickey,keyboard-interactive" "$ssh_config"; then
|
||||
echo "✅ AuthenticationMethods configured for 2FA"
|
||||
else
|
||||
echo "❌ AuthenticationMethods not configured for 2FA"
|
||||
((failed++))
|
||||
((++failed))
|
||||
fi
|
||||
|
||||
return $failed
|
||||
@@ -75,7 +75,7 @@ function test_pam_2fa_config() {
|
||||
echo "✅ PAM Google Authenticator module configured"
|
||||
else
|
||||
echo "❌ PAM Google Authenticator module not configured"
|
||||
((failed++))
|
||||
((++failed))
|
||||
fi
|
||||
|
||||
# Check if nullok is present (allows users without 2FA setup)
|
||||
@@ -106,7 +106,7 @@ function test_cockpit_2fa_config() {
|
||||
echo "✅ Cockpit configuration file exists"
|
||||
else
|
||||
echo "❌ Cockpit configuration file missing"
|
||||
((failed++))
|
||||
((++failed))
|
||||
fi
|
||||
|
||||
# Check Cockpit PAM configuration
|
||||
@@ -114,7 +114,7 @@ function test_cockpit_2fa_config() {
|
||||
echo "✅ Cockpit PAM 2FA configured"
|
||||
else
|
||||
echo "❌ Cockpit PAM 2FA not configured"
|
||||
((failed++))
|
||||
((++failed))
|
||||
fi
|
||||
|
||||
return $failed
|
||||
@@ -137,14 +137,14 @@ function test_webmin_2fa_config() {
|
||||
echo "✅ Webmin TOTP provider configured"
|
||||
else
|
||||
echo "❌ Webmin TOTP provider not configured"
|
||||
((failed++))
|
||||
((++failed))
|
||||
fi
|
||||
|
||||
if grep -q "^twofactor=1" "$webmin_config"; then
|
||||
echo "✅ Webmin 2FA enabled"
|
||||
else
|
||||
echo "❌ Webmin 2FA not enabled"
|
||||
((failed++))
|
||||
((++failed))
|
||||
fi
|
||||
|
||||
return $failed
|
||||
@@ -163,7 +163,7 @@ function test_user_2fa_setup() {
|
||||
echo "✅ 2FA setup script exists for user: $user"
|
||||
else
|
||||
echo "❌ 2FA setup script missing for user: $user"
|
||||
((failed++))
|
||||
((++failed))
|
||||
fi
|
||||
|
||||
# Check if instructions exist
|
||||
@@ -171,7 +171,7 @@ function test_user_2fa_setup() {
|
||||
echo "✅ 2FA instructions exist for user: $user"
|
||||
else
|
||||
echo "❌ 2FA instructions missing for user: $user"
|
||||
((failed++))
|
||||
((++failed))
|
||||
fi
|
||||
else
|
||||
echo "⚠️ User $user not found, skipping"
|
||||
@@ -191,7 +191,7 @@ function test_service_status() {
|
||||
echo "✅ SSH service is running"
|
||||
else
|
||||
echo "❌ SSH service is not running"
|
||||
((failed++))
|
||||
((++failed))
|
||||
fi
|
||||
|
||||
# Test SSH configuration
|
||||
@@ -199,7 +199,7 @@ function test_service_status() {
|
||||
echo "✅ SSH configuration is valid"
|
||||
else
|
||||
echo "❌ SSH configuration is invalid"
|
||||
((failed++))
|
||||
((++failed))
|
||||
fi
|
||||
|
||||
# Test Cockpit service if installed
|
||||
@@ -208,7 +208,7 @@ function test_service_status() {
|
||||
echo "✅ Cockpit service is running"
|
||||
else
|
||||
echo "❌ Cockpit service is not running"
|
||||
((failed++))
|
||||
((++failed))
|
||||
fi
|
||||
fi
|
||||
|
||||
@@ -218,7 +218,7 @@ function test_service_status() {
|
||||
echo "✅ Webmin service is running"
|
||||
else
|
||||
echo "❌ Webmin service is not running"
|
||||
((failed++))
|
||||
((++failed))
|
||||
fi
|
||||
fi
|
||||
|
||||
@@ -242,7 +242,7 @@ function test_backup_existence() {
|
||||
fi
|
||||
else
|
||||
echo "❌ Backup directory does not exist"
|
||||
((failed++))
|
||||
((++failed))
|
||||
fi
|
||||
|
||||
return $failed
|
||||
|
||||
Reference in New Issue
Block a user