From 3e216872ce20305182d520186cf3e09a1d49649e Mon Sep 17 00:00:00 2001 From: Anthony Stirling <77850077+Frooodle@users.noreply.github.com> Date: Tue, 14 Jan 2025 13:47:16 +0000 Subject: [PATCH] test all pages load correctly (#2699) # Description Please provide a summary of the changes, including relevant motivation and context. Closes #(issue_number) ## Checklist - [ ] I have read the [Contribution Guidelines](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/CONTRIBUTING.md) - [ ] I have performed a self-review of my own code - [ ] I have attached images of the change if it is UI based - [ ] I have commented my code, particularly in hard-to-understand areas - [ ] If my code has heavily changed functionality I have updated relevant docs on [Stirling-PDFs doc repo](https://github.com/Stirling-Tools/Stirling-Tools.github.io/blob/main/docs/) - [ ] My changes generate no new warnings - [ ] I have read the section [Add New Translation Tags](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/HowToAddNewLanguage.md#add-new-translation-tags) (for new translation tags only) --- .github/workflows/build.yml | 1 + cucumber/test_webpages.sh | 97 +++++++++++++++++++ cucumber/webpage_urls.txt | 54 +++++++++++ .../SPDF/config/EndpointConfiguration.java | 1 - test.sh | 9 ++ 5 files changed, 161 insertions(+), 1 deletion(-) create mode 100644 cucumber/test_webpages.sh create mode 100644 cucumber/webpage_urls.txt diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index affa1b13..c0656e7a 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -109,5 +109,6 @@ jobs: - name: Run Docker Compose Tests run: | + chmod +x ./cucumber/test_webpages.sh chmod +x ./test.sh ./test.sh diff --git a/cucumber/test_webpages.sh b/cucumber/test_webpages.sh new file mode 100644 index 00000000..df97d08d --- /dev/null +++ b/cucumber/test_webpages.sh @@ -0,0 +1,97 @@ +#!/bin/bash + +# Function to check a single webpage +check_webpage() { + local url=$1 + local base_url=${2:-"http://localhost:8080"} + local full_url="${base_url}${url}" + local timeout=10 + + echo -n "Testing $full_url ... " + + # Use curl to fetch the page with timeout + response=$(curl -s -w "\n%{http_code}" --max-time $timeout "$full_url") + if [ $? -ne 0 ]; then + echo "FAILED - Connection error or timeout" + return 1 + fi + + # Split response into body and status code + HTTP_STATUS=$(echo "$response" | tail -n1) + BODY=$(echo "$response" | sed '$d') + + # Check HTTP status + if [ "$HTTP_STATUS" != "200" ]; then + echo "FAILED - HTTP Status: $HTTP_STATUS" + return 1 + fi + + # Check if response contains HTML + if ! echo "$BODY" | grep -q "\|