mirror of
https://github.com/Stirling-Tools/Stirling-PDF.git
synced 2025-09-14 07:29:24 +00:00
cookie for session
This commit is contained in:
parent
ec2caa4134
commit
0154e46c8a
@ -49,9 +49,7 @@ public class EndpointInterceptor implements HandlerInterceptor {
|
|||||||
|| request.getRequestURI().contains("/images/")
|
|| request.getRequestURI().contains("/images/")
|
||||||
|| request.getRequestURI().contains("/favicon")
|
|| request.getRequestURI().contains("/favicon")
|
||||||
|| request.getRequestURI().contains("/error")
|
|| request.getRequestURI().contains("/error")
|
||||||
|| request.getRequestURI().contains("/session/status")
|
|| request.getRequestURI().contains("/session")
|
||||||
|| request.getRequestURI().contains("/session/expire")
|
|
||||||
|| request.getRequestURI().contains("/session/expire/")
|
|
||||||
|| request.getRequestURI().endsWith(".js")
|
|| request.getRequestURI().endsWith(".js")
|
||||||
|| request.getRequestURI().endsWith(".png")
|
|| request.getRequestURI().endsWith(".png")
|
||||||
|| request.getRequestURI().endsWith(".webmanifest")
|
|| request.getRequestURI().endsWith(".webmanifest")
|
||||||
|
@ -43,7 +43,7 @@ check_health() {
|
|||||||
capture_file_list() {
|
capture_file_list() {
|
||||||
local container_name=$1
|
local container_name=$1
|
||||||
local output_file=$2
|
local output_file=$2
|
||||||
|
|
||||||
echo "Capturing file list from $container_name..."
|
echo "Capturing file list from $container_name..."
|
||||||
# Get all files in one command, output directly from Docker to avoid path issues
|
# Get all files in one command, output directly from Docker to avoid path issues
|
||||||
# Skip proc, sys, dev, and the specified LibreOffice config directory
|
# Skip proc, sys, dev, and the specified LibreOffice config directory
|
||||||
@ -60,12 +60,12 @@ capture_file_list() {
|
|||||||
-not -path '*/tmp/lu*' \
|
-not -path '*/tmp/lu*' \
|
||||||
-not -path '*/tmp/tmp*' \
|
-not -path '*/tmp/tmp*' \
|
||||||
2>/dev/null | xargs -I{} sh -c 'stat -c \"%n %s %Y\" \"{}\" 2>/dev/null || true' | sort" > "$output_file"
|
2>/dev/null | xargs -I{} sh -c 'stat -c \"%n %s %Y\" \"{}\" 2>/dev/null || true' | sort" > "$output_file"
|
||||||
|
|
||||||
# Check if the output file has content
|
# Check if the output file has content
|
||||||
if [ ! -s "$output_file" ]; then
|
if [ ! -s "$output_file" ]; then
|
||||||
echo "WARNING: Failed to capture file list or container returned empty list"
|
echo "WARNING: Failed to capture file list or container returned empty list"
|
||||||
echo "Trying alternative approach..."
|
echo "Trying alternative approach..."
|
||||||
|
|
||||||
# Alternative simpler approach - just get paths as a fallback
|
# Alternative simpler approach - just get paths as a fallback
|
||||||
docker exec $container_name sh -c "find / -type f \
|
docker exec $container_name sh -c "find / -type f \
|
||||||
-not -path '*/proc/*' \
|
-not -path '*/proc/*' \
|
||||||
@ -79,14 +79,14 @@ capture_file_list() {
|
|||||||
-not -path '*/tmp/lu*' \
|
-not -path '*/tmp/lu*' \
|
||||||
-not -path '*/tmp/tmp*' \
|
-not -path '*/tmp/tmp*' \
|
||||||
2>/dev/null | sort" > "$output_file"
|
2>/dev/null | sort" > "$output_file"
|
||||||
|
|
||||||
if [ ! -s "$output_file" ]; then
|
if [ ! -s "$output_file" ]; then
|
||||||
echo "ERROR: All attempts to capture file list failed"
|
echo "ERROR: All attempts to capture file list failed"
|
||||||
# Create a dummy entry to prevent diff errors
|
# Create a dummy entry to prevent diff errors
|
||||||
echo "NO_FILES_FOUND 0 0" > "$output_file"
|
echo "NO_FILES_FOUND 0 0" > "$output_file"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "File list captured to $output_file"
|
echo "File list captured to $output_file"
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -96,24 +96,24 @@ compare_file_lists() {
|
|||||||
local after_file=$2
|
local after_file=$2
|
||||||
local diff_file=$3
|
local diff_file=$3
|
||||||
local container_name=$4 # Added container_name parameter
|
local container_name=$4 # Added container_name parameter
|
||||||
|
|
||||||
echo "Comparing file lists..."
|
echo "Comparing file lists..."
|
||||||
|
|
||||||
# Check if files exist and have content
|
# Check if files exist and have content
|
||||||
if [ ! -s "$before_file" ] || [ ! -s "$after_file" ]; then
|
if [ ! -s "$before_file" ] || [ ! -s "$after_file" ]; then
|
||||||
echo "WARNING: One or both file lists are empty."
|
echo "WARNING: One or both file lists are empty."
|
||||||
|
|
||||||
if [ ! -s "$before_file" ]; then
|
if [ ! -s "$before_file" ]; then
|
||||||
echo "Before file is empty: $before_file"
|
echo "Before file is empty: $before_file"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! -s "$after_file" ]; then
|
if [ ! -s "$after_file" ]; then
|
||||||
echo "After file is empty: $after_file"
|
echo "After file is empty: $after_file"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Create empty diff file
|
# Create empty diff file
|
||||||
> "$diff_file"
|
> "$diff_file"
|
||||||
|
|
||||||
# Check if we at least have the after file to look for temp files
|
# Check if we at least have the after file to look for temp files
|
||||||
if [ -s "$after_file" ]; then
|
if [ -s "$after_file" ]; then
|
||||||
echo "Checking for temp files in the after snapshot..."
|
echo "Checking for temp files in the after snapshot..."
|
||||||
@ -128,23 +128,23 @@ compare_file_lists() {
|
|||||||
echo "No temporary files found in the after snapshot."
|
echo "No temporary files found in the after snapshot."
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Both files exist and have content, proceed with diff
|
# Both files exist and have content, proceed with diff
|
||||||
diff "$before_file" "$after_file" > "$diff_file"
|
diff "$before_file" "$after_file" > "$diff_file"
|
||||||
|
|
||||||
if [ -s "$diff_file" ]; then
|
if [ -s "$diff_file" ]; then
|
||||||
echo "Detected changes in files:"
|
echo "Detected changes in files:"
|
||||||
cat "$diff_file"
|
cat "$diff_file"
|
||||||
|
|
||||||
# Extract only added files (lines starting with ">")
|
# Extract only added files (lines starting with ">")
|
||||||
grep "^>" "$diff_file" > "${diff_file}.added" || true
|
grep "^>" "$diff_file" > "${diff_file}.added" || true
|
||||||
if [ -s "${diff_file}.added" ]; then
|
if [ -s "${diff_file}.added" ]; then
|
||||||
echo "New files created during test:"
|
echo "New files created during test:"
|
||||||
cat "${diff_file}.added" | sed 's/^> //'
|
cat "${diff_file}.added" | sed 's/^> //'
|
||||||
|
|
||||||
# Check for tmp files
|
# Check for tmp files
|
||||||
grep -i "tmp\|temp" "${diff_file}.added" > "${diff_file}.tmp" || true
|
grep -i "tmp\|temp" "${diff_file}.added" > "${diff_file}.tmp" || true
|
||||||
if [ -s "${diff_file}.tmp" ]; then
|
if [ -s "${diff_file}.tmp" ]; then
|
||||||
@ -155,7 +155,7 @@ compare_file_lists() {
|
|||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Extract only removed files (lines starting with "<")
|
# Extract only removed files (lines starting with "<")
|
||||||
grep "^<" "$diff_file" > "${diff_file}.removed" || true
|
grep "^<" "$diff_file" > "${diff_file}.removed" || true
|
||||||
if [ -s "${diff_file}.removed" ]; then
|
if [ -s "${diff_file}.removed" ]; then
|
||||||
@ -165,7 +165,7 @@ compare_file_lists() {
|
|||||||
else
|
else
|
||||||
echo "No file changes detected during test."
|
echo "No file changes detected during test."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -212,8 +212,8 @@ main() {
|
|||||||
|
|
||||||
cd "$PROJECT_ROOT"
|
cd "$PROJECT_ROOT"
|
||||||
|
|
||||||
export DOCKER_CLI_EXPERIMENTAL=enabled
|
export DOCKER_CLI_EXPERIMENTAL=enabled
|
||||||
export COMPOSE_DOCKER_CLI_BUILD=0
|
export COMPOSE_DOCKER_CLI_BUILD=0
|
||||||
export DOCKER_ENABLE_SECURITY=false
|
export DOCKER_ENABLE_SECURITY=false
|
||||||
# Run the gradlew build command and check if it fails
|
# Run the gradlew build command and check if it fails
|
||||||
if ! ./gradlew clean build; then
|
if ! ./gradlew clean build; then
|
||||||
@ -282,27 +282,27 @@ main() {
|
|||||||
# Create directory for file snapshots if it doesn't exist
|
# Create directory for file snapshots if it doesn't exist
|
||||||
SNAPSHOT_DIR="$PROJECT_ROOT/testing/file_snapshots"
|
SNAPSHOT_DIR="$PROJECT_ROOT/testing/file_snapshots"
|
||||||
mkdir -p "$SNAPSHOT_DIR"
|
mkdir -p "$SNAPSHOT_DIR"
|
||||||
|
|
||||||
# Capture file list before running behave tests
|
# Capture file list before running behave tests
|
||||||
BEFORE_FILE="$SNAPSHOT_DIR/files_before_behave.txt"
|
BEFORE_FILE="$SNAPSHOT_DIR/files_before_behave.txt"
|
||||||
AFTER_FILE="$SNAPSHOT_DIR/files_after_behave.txt"
|
AFTER_FILE="$SNAPSHOT_DIR/files_after_behave.txt"
|
||||||
DIFF_FILE="$SNAPSHOT_DIR/files_diff.txt"
|
DIFF_FILE="$SNAPSHOT_DIR/files_diff.txt"
|
||||||
|
|
||||||
# Define container name variable for consistency
|
# Define container name variable for consistency
|
||||||
CONTAINER_NAME="Stirling-PDF-Security-Fat-with-login"
|
CONTAINER_NAME="Stirling-PDF-Security-Fat-with-login"
|
||||||
|
|
||||||
capture_file_list "$CONTAINER_NAME" "$BEFORE_FILE"
|
capture_file_list "$CONTAINER_NAME" "$BEFORE_FILE"
|
||||||
|
|
||||||
cd "testing/cucumber"
|
cd "testing/cucumber"
|
||||||
if python -m behave; then
|
if python -m behave; then
|
||||||
# Wait 10 seconds before capturing the file list after tests
|
# Wait 10 seconds before capturing the file list after tests
|
||||||
echo "Waiting 5 seconds for any file operations to complete..."
|
echo "Waiting 5 seconds for any file operations to complete..."
|
||||||
sleep 5
|
sleep 5
|
||||||
|
|
||||||
# Capture file list after running behave tests
|
# Capture file list after running behave tests
|
||||||
cd "$PROJECT_ROOT"
|
cd "$PROJECT_ROOT"
|
||||||
capture_file_list "$CONTAINER_NAME" "$AFTER_FILE"
|
capture_file_list "$CONTAINER_NAME" "$AFTER_FILE"
|
||||||
|
|
||||||
# Compare file lists
|
# Compare file lists
|
||||||
if compare_file_lists "$BEFORE_FILE" "$AFTER_FILE" "$DIFF_FILE" "$CONTAINER_NAME"; then
|
if compare_file_lists "$BEFORE_FILE" "$AFTER_FILE" "$DIFF_FILE" "$CONTAINER_NAME"; then
|
||||||
echo "No unexpected temporary files found."
|
echo "No unexpected temporary files found."
|
||||||
@ -311,19 +311,19 @@ main() {
|
|||||||
echo "WARNING: Unexpected temporary files detected after behave tests!"
|
echo "WARNING: Unexpected temporary files detected after behave tests!"
|
||||||
failed_tests+=("Stirling-PDF-Regression-Temp-Files")
|
failed_tests+=("Stirling-PDF-Regression-Temp-Files")
|
||||||
fi
|
fi
|
||||||
|
|
||||||
passed_tests+=("Stirling-PDF-Regression")
|
passed_tests+=("Stirling-PDF-Regression")
|
||||||
else
|
else
|
||||||
failed_tests+=("Stirling-PDF-Regression")
|
failed_tests+=("Stirling-PDF-Regression")
|
||||||
echo "Printing docker logs of failed regression"
|
echo "Printing docker logs of failed regression"
|
||||||
docker logs "$CONTAINER_NAME"
|
docker logs "$CONTAINER_NAME"
|
||||||
echo "Printed docker logs of failed regression"
|
echo "Printed docker logs of failed regression"
|
||||||
|
|
||||||
# Still capture file list after failure for analysis
|
# Still capture file list after failure for analysis
|
||||||
# Wait 10 seconds before capturing the file list
|
# Wait 10 seconds before capturing the file list
|
||||||
echo "Waiting 5 seconds before capturing file list..."
|
echo "Waiting 5 seconds before capturing file list..."
|
||||||
sleep 10
|
sleep 10
|
||||||
|
|
||||||
cd "$PROJECT_ROOT"
|
cd "$PROJECT_ROOT"
|
||||||
capture_file_list "$CONTAINER_NAME" "$AFTER_FILE"
|
capture_file_list "$CONTAINER_NAME" "$AFTER_FILE"
|
||||||
compare_file_lists "$BEFORE_FILE" "$AFTER_FILE" "$DIFF_FILE" "$CONTAINER_NAME"
|
compare_file_lists "$BEFORE_FILE" "$AFTER_FILE" "$DIFF_FILE" "$CONTAINER_NAME"
|
||||||
@ -360,4 +360,4 @@ main() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
main
|
main
|
||||||
|
@ -9,7 +9,7 @@ check_webpage() {
|
|||||||
local result_file="$3"
|
local result_file="$3"
|
||||||
|
|
||||||
# Use curl to fetch the page with timeout
|
# Use curl to fetch the page with timeout
|
||||||
response=$(curl -s -w "\n%{http_code}" --max-time $timeout "$full_url")
|
response=$(curl -b cookies.txt -s -w "\n%{http_code}" --max-time $timeout "$full_url")
|
||||||
if [ $? -ne 0 ]; then
|
if [ $? -ne 0 ]; then
|
||||||
echo "FAILED - Connection error or timeout $full_url" >> "$result_file"
|
echo "FAILED - Connection error or timeout $full_url" >> "$result_file"
|
||||||
return 1
|
return 1
|
||||||
@ -75,13 +75,13 @@ test_all_urls() {
|
|||||||
|
|
||||||
((total_count++))
|
((total_count++))
|
||||||
((url_index++))
|
((url_index++))
|
||||||
|
|
||||||
# Run the check in background
|
# Run the check in background
|
||||||
test_url "$url" "$base_url" "$tmp_dir" "$url_index" &
|
test_url "$url" "$base_url" "$tmp_dir" "$url_index" &
|
||||||
|
|
||||||
# Track the job
|
# Track the job
|
||||||
((active_jobs++))
|
((active_jobs++))
|
||||||
|
|
||||||
# If we've reached max_parallel, wait for a job to finish
|
# If we've reached max_parallel, wait for a job to finish
|
||||||
if [ $active_jobs -ge $max_parallel ]; then
|
if [ $active_jobs -ge $max_parallel ]; then
|
||||||
wait -n # Wait for any child process to exit
|
wait -n # Wait for any child process to exit
|
||||||
@ -97,7 +97,7 @@ test_all_urls() {
|
|||||||
if [ -f "${tmp_dir}/result_${i}.txt" ]; then
|
if [ -f "${tmp_dir}/result_${i}.txt" ]; then
|
||||||
cat "${tmp_dir}/result_${i}.txt"
|
cat "${tmp_dir}/result_${i}.txt"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -f "${tmp_dir}/failed_${i}" ]; then
|
if [ -f "${tmp_dir}/failed_${i}" ]; then
|
||||||
failed_count=$((failed_count + $(cat "${tmp_dir}/failed_${i}")))
|
failed_count=$((failed_count + $(cat "${tmp_dir}/failed_${i}")))
|
||||||
fi
|
fi
|
||||||
@ -158,6 +158,9 @@ main() {
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
curl -s $base_url/session/expire/all
|
||||||
|
curl -s -c cookies.txt $base_url/session
|
||||||
|
|
||||||
# Run tests using the URL list
|
# Run tests using the URL list
|
||||||
if test_all_urls "$url_file" "$base_url" "$max_parallel"; then
|
if test_all_urls "$url_file" "$base_url" "$max_parallel"; then
|
||||||
echo "All webpage tests passed!"
|
echo "All webpage tests passed!"
|
||||||
@ -171,4 +174,4 @@ main() {
|
|||||||
# Run main if script is executed directly
|
# Run main if script is executed directly
|
||||||
if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
|
if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
|
||||||
main "$@"
|
main "$@"
|
||||||
fi
|
fi
|
||||||
|
Loading…
x
Reference in New Issue
Block a user