Loading .pre-commit-config.yaml +1 −1 Original line number Diff line number Diff line Loading @@ -96,4 +96,4 @@ repos: args: ["--config-file=.lint.cfg"] additional_dependencies: - types-requests - git+https://code.kodo.org.uk/dom/behave-utils.git@v0.2#behave-utils - behave-utils ~=0.3.2 tests/regression-20.feature 0 → 100644 +15 −0 Original line number Diff line number Diff line Feature: Return favicons when requests Regression check for "#20": Fix/remove favicon.ico intercept in Nginx An icon should always be served when requesting "/favicon.ico", either one added by the owner, or a default icon. Scenario: Default icon When /favicon.ico is requested Then 302 is returned And the "Location" header's value is "http://test.example.com/wp-includes/images/w-logo-blue-white-bg.png" Scenario: Owner supplied icon Given /app/static/favicon.ico exists in the frontend When /favicon.ico is requested Then 200 is returned tests/requirements.txt +1 −1 Original line number Diff line number Diff line Python ~=3.9; python_version < '3.9' behave git+https://code.kodo.org.uk/dom/behave-utils.git@v0.2#behave-utils behave-utils ~=0.3.2 requests ~=2.26 tests/steps/request_steps.py +5 −1 Original line number Diff line number Diff line # Copyright 2021 Dominik Sekotill <dom.sekotill@kodo.org.uk> # Copyright 2021-2022 Dominik Sekotill <dom.sekotill@kodo.org.uk> # # This Source Code Form is subject to the terms of the Mozilla Public # License, v. 2.0. If a copy of the MPL was not distributed with this Loading @@ -19,6 +19,8 @@ from behave.runner import Context from behave_utils import URL from behave_utils import PatternEnum SAMPLE_SITE_NAME = "http://test.example.com" class Method(PatternEnum): """ Loading Loading @@ -120,6 +122,8 @@ def assert_header(context: Context, header_name: str, header_value: str) -> None """ Assert that an expected header was received during a previous step """ if SAMPLE_SITE_NAME in header_value: header_value = header_value.replace(SAMPLE_SITE_NAME, context.site.url) headers = context.response.headers assert header_name in headers, \ f"Expected header not found in response: {header_name!r}" Loading tests/steps/static.py 0 → 100644 +39 −0 Original line number Diff line number Diff line # Copyright 2022 Dominik Sekotill <dom.sekotill@kodo.org.uk> # # This Source Code Form is subject to the terms of the Mozilla Public # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. """ Step implementations involving creating files in containers """ from __future__ import annotations from typing import Iterator from behave import fixture from behave import given from behave import use_fixture from behave.runner import Context from behave_utils.docker import Cli @given("{path} exists in the {container}") def step_impl(context: Context, path: str, container: str) -> None: """ Create a file in the named container """ use_fixture(container_file, context, path, container) @fixture def container_file(context: Context, path: str, container_name: str) -> Iterator[None]: """ Create a file in a named container as a fixture """ container = getattr(context.site, container_name) run = Cli(container) run("tee", path, input=getattr(context, "text", "This is a data file!")) yield run("rm", path) Loading
.pre-commit-config.yaml +1 −1 Original line number Diff line number Diff line Loading @@ -96,4 +96,4 @@ repos: args: ["--config-file=.lint.cfg"] additional_dependencies: - types-requests - git+https://code.kodo.org.uk/dom/behave-utils.git@v0.2#behave-utils - behave-utils ~=0.3.2
tests/regression-20.feature 0 → 100644 +15 −0 Original line number Diff line number Diff line Feature: Return favicons when requests Regression check for "#20": Fix/remove favicon.ico intercept in Nginx An icon should always be served when requesting "/favicon.ico", either one added by the owner, or a default icon. Scenario: Default icon When /favicon.ico is requested Then 302 is returned And the "Location" header's value is "http://test.example.com/wp-includes/images/w-logo-blue-white-bg.png" Scenario: Owner supplied icon Given /app/static/favicon.ico exists in the frontend When /favicon.ico is requested Then 200 is returned
tests/requirements.txt +1 −1 Original line number Diff line number Diff line Python ~=3.9; python_version < '3.9' behave git+https://code.kodo.org.uk/dom/behave-utils.git@v0.2#behave-utils behave-utils ~=0.3.2 requests ~=2.26
tests/steps/request_steps.py +5 −1 Original line number Diff line number Diff line # Copyright 2021 Dominik Sekotill <dom.sekotill@kodo.org.uk> # Copyright 2021-2022 Dominik Sekotill <dom.sekotill@kodo.org.uk> # # This Source Code Form is subject to the terms of the Mozilla Public # License, v. 2.0. If a copy of the MPL was not distributed with this Loading @@ -19,6 +19,8 @@ from behave.runner import Context from behave_utils import URL from behave_utils import PatternEnum SAMPLE_SITE_NAME = "http://test.example.com" class Method(PatternEnum): """ Loading Loading @@ -120,6 +122,8 @@ def assert_header(context: Context, header_name: str, header_value: str) -> None """ Assert that an expected header was received during a previous step """ if SAMPLE_SITE_NAME in header_value: header_value = header_value.replace(SAMPLE_SITE_NAME, context.site.url) headers = context.response.headers assert header_name in headers, \ f"Expected header not found in response: {header_name!r}" Loading
tests/steps/static.py 0 → 100644 +39 −0 Original line number Diff line number Diff line # Copyright 2022 Dominik Sekotill <dom.sekotill@kodo.org.uk> # # This Source Code Form is subject to the terms of the Mozilla Public # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. """ Step implementations involving creating files in containers """ from __future__ import annotations from typing import Iterator from behave import fixture from behave import given from behave import use_fixture from behave.runner import Context from behave_utils.docker import Cli @given("{path} exists in the {container}") def step_impl(context: Context, path: str, container: str) -> None: """ Create a file in the named container """ use_fixture(container_file, context, path, container) @fixture def container_file(context: Context, path: str, container_name: str) -> Iterator[None]: """ Create a file in a named container as a fixture """ container = getattr(context.site, container_name) run = Cli(container) run("tee", path, input=getattr(context, "text", "This is a data file!")) yield run("rm", path)