fix: correct line endings, paths, and syntax in all lab01 test scripts
This commit is contained in:
@@ -4,6 +4,9 @@
|
|||||||
|
|
||||||
set -euo pipefail
|
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
|
# Helper function for incrementing counters that works with set -e
|
||||||
inc_pass() { ((pass_count++)) || true; }
|
inc_pass() { ((pass_count++)) || true; }
|
||||||
inc_fail() { ((fail_count++)) || true; }
|
inc_fail() { ((fail_count++)) || true; }
|
||||||
@@ -20,7 +23,7 @@ fail_count=0
|
|||||||
CONTAINER_NAME="lab01-test-container"
|
CONTAINER_NAME="lab01-test-container"
|
||||||
|
|
||||||
test_non_root_dockerfile_exists() {
|
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
|
if [ -f "$dockerfile" ]; then
|
||||||
echo -e "${GREEN}PASS${NC}: Test Dockerfile exists"
|
echo -e "${GREEN}PASS${NC}: Test Dockerfile exists"
|
||||||
@@ -78,8 +81,8 @@ test_container_user_configured() {
|
|||||||
|
|
||||||
if [ -z "$user_config" ]; then
|
if [ -z "$user_config" ]; then
|
||||||
# Check compose file for user directive (may override Dockerfile)
|
# Check compose file for user directive (may override Dockerfile)
|
||||||
if [ -f "labs/lab-01-iam/docker-compose.yml" ]; then
|
if [ -f "$PROJECT_ROOT/labs/lab-01-iam/docker-compose.yml" ]; then
|
||||||
if grep -q "user:" 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"
|
echo -e "${GREEN}PASS${NC}: User directive found in docker-compose.yml"
|
||||||
inc_pass
|
inc_pass
|
||||||
return 0
|
return 0
|
||||||
@@ -98,7 +101,7 @@ test_container_user_configured() {
|
|||||||
|
|
||||||
test_no_container_runs_as_root() {
|
test_no_container_runs_as_root() {
|
||||||
# INF-01 requirement: NO container should run 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
|
if [ ! -f "$compose_file" ]; then
|
||||||
echo -e "${YELLOW}SKIP${NC}: docker-compose.yml not created yet"
|
echo -e "${YELLOW}SKIP${NC}: docker-compose.yml not created yet"
|
||||||
|
|||||||
@@ -5,6 +5,9 @@
|
|||||||
|
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||||
|
PROJECT_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)"
|
||||||
|
|
||||||
RED='\033[0;31m'
|
RED='\033[0;31m'
|
||||||
GREEN='\033[0;32m'
|
GREEN='\033[0;32m'
|
||||||
YELLOW='\033[1;33m'
|
YELLOW='\033[1;33m'
|
||||||
@@ -49,7 +52,7 @@ echo ""
|
|||||||
|
|
||||||
# Test 3: Non-root container execution (INF-01)
|
# Test 3: Non-root container execution (INF-01)
|
||||||
echo -e "${BLUE}[3/3] Checking non-root container execution (INF-01)...${NC}"
|
echo -e "${BLUE}[3/3] Checking non-root container execution (INF-01)...${NC}"
|
||||||
cd labs/lab-01-iam
|
cd "$PROJECT_ROOT/labs/lab-01-iam"
|
||||||
compose_file="docker-compose.yml"
|
compose_file="docker-compose.yml"
|
||||||
if [ ! -f "$compose_file" ]; then
|
if [ ! -f "$compose_file" ]; then
|
||||||
echo -e " ${YELLOW}○${NC} docker-compose.yml not found"
|
echo -e " ${YELLOW}○${NC} docker-compose.yml not found"
|
||||||
|
|||||||
Reference in New Issue
Block a user