fix: correct line endings, paths, and syntax in all lab01 test scripts

This commit is contained in:
Luca Sacchi Ricciardi
2026-04-09 12:27:57 +02:00
parent 19fdb650ad
commit b3b9c10d68
2 changed files with 11 additions and 5 deletions
+7 -4
View File
@@ -4,6 +4,9 @@
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PROJECT_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)"
# Helper function for incrementing counters that works with set -e
inc_pass() { ((pass_count++)) || true; }
inc_fail() { ((fail_count++)) || true; }
@@ -20,7 +23,7 @@ fail_count=0
CONTAINER_NAME="lab01-test-container"
test_non_root_dockerfile_exists() {
local dockerfile="labs/lab-01-iam/Dockerfile.test"
local dockerfile="$PROJECT_ROOT/labs/lab-01-iam/Dockerfile.test"
if [ -f "$dockerfile" ]; then
echo -e "${GREEN}PASS${NC}: Test Dockerfile exists"
@@ -78,8 +81,8 @@ test_container_user_configured() {
if [ -z "$user_config" ]; then
# Check compose file for user directive (may override Dockerfile)
if [ -f "labs/lab-01-iam/docker-compose.yml" ]; then
if grep -q "user:" labs/lab-01-iam/docker-compose.yml; then
if [ -f "$PROJECT_ROOT/labs/lab-01-iam/docker-compose.yml" ]; then
if grep -q "user:" $PROJECT_ROOT/labs/lab-01-iam/docker-compose.yml; then
echo -e "${GREEN}PASS${NC}: User directive found in docker-compose.yml"
inc_pass
return 0
@@ -98,7 +101,7 @@ test_container_user_configured() {
test_no_container_runs_as_root() {
# INF-01 requirement: NO container should run as root
local compose_file="labs/lab-01-iam/docker-compose.yml"
local compose_file="$PROJECT_ROOT/labs/lab-01-iam/docker-compose.yml"
if [ ! -f "$compose_file" ]; then
echo -e "${YELLOW}SKIP${NC}: docker-compose.yml not created yet"