diff --git a/server/routes.py b/server/routes.py index f89807a4..e9a265c8 100644 --- a/server/routes.py +++ b/server/routes.py @@ -1,11 +1,14 @@ -from flask import redirect, request, jsonify, abort, send_from_directory import re +from flask import abort, jsonify, redirect, request, send_from_directory -from . import app, talisman, render_template, url_for +from . import app +from . import faq as faq_util +from . import render_template from . import reports as report_util +from . import talisman from . import techreport as tech_report_util -from . import faq as faq_util +from . import url_for def safe_int(value, default=1): @@ -88,6 +91,10 @@ def techreportlanding(page_id): # Get the settings for the current page active_tech_report = tech_report.get("pages").get(page_id) + # Check if the page exists + if active_tech_report is None: + abort(404) + # Add the technologies requested in the URL to the filters # Use the default configured techs as fallback # Use ["ALL"] if there is nothing configured diff --git a/server/tests/routes_test.py b/server/tests/routes_test.py index 51c2303d..abf34cc6 100644 --- a/server/tests/routes_test.py +++ b/server/tests/routes_test.py @@ -12,9 +12,10 @@ # See the License for the specific language governing permissions and # limitations under the License. -from server import app, talisman import pytest +from server import app, talisman + # Create test client without https redirect # (normally taken care of by running in debug) @@ -257,6 +258,31 @@ def test_tech_report_category_pages_fallback(client): assert response.status_code == 200 +def test_tech_report_landing_valid_page(client): + response = client.get("/reports/techreport/landing") + assert response.status_code == 200 + + +def test_tech_report_drilldown_page(client): + response = client.get("/reports/techreport/drilldown") + assert response.status_code == 200 + + +def test_tech_report_comparison_page(client): + response = client.get("/reports/techreport/comparison") + assert response.status_code == 200 + + +def test_tech_report_category_page(client): + response = client.get("/reports/techreport/category") + assert response.status_code == 200 + + +def test_tech_report_invalid_page(client): + response = client.get("/reports/techreport/invalid_page_id") + assert response.status_code == 404 + + def test_well_known_atproto_did(client): response = client.get("/.well-known/atproto-did") assert response.status_code == 200 diff --git a/templates/error/404.html b/templates/error/404.html index 73177a38..ed41867d 100644 --- a/templates/error/404.html +++ b/templates/error/404.html @@ -4,9 +4,5 @@ {% block error %}Page Not Found{% endblock %} {% block custom %} -
- We've recently launched a new version of the HTTP Archive. - Some URLs may have been updated, please take a look at our new site! - If the information you're looking for is missing, please let us know. -
+If the information you're looking for is missing, please let us know.
{% endblock %} diff --git a/tools/scripts/set_lighthouse_urls.sh b/tools/scripts/set_lighthouse_urls.sh index 3e122b6f..51bb68de 100755 --- a/tools/scripts/set_lighthouse_urls.sh +++ b/tools/scripts/set_lighthouse_urls.sh @@ -60,7 +60,7 @@ elif [ "${RUN_TYPE}" == "pull_request" ] && [ "${COMMIT_SHA}" != "" ]; then git pull --quiet git checkout main # Then get the changes - CHANGED_FILES=$(git diff --name-only "main...${COMMIT_SHA}" --diff-filter=d templates config/reports.json | grep -v base.html | grep -v main.html | grep -v ejs | grep -v base_ | grep -v sitemap | grep -v error.html | grep -v techreport/components | grep -v techreport/templates | grep -v techreport/report | grep -v techreport/techreport) + CHANGED_FILES=$(git diff --name-only "main...${COMMIT_SHA}" --diff-filter=d templates config/reports.json | grep -v base.html | grep -v main.html | grep -v ejs | grep -v base_ | grep -v sitemap | grep -v error.html | grep -v techreport/components | grep -v techreport/templates | grep -v techreport/report | grep -v techreport/techreport | grep -v 404) echo "${CHANGED_FILES}" # Then back to the pull request changes