1
0
mirror of https://github.com/apache/httpd.git synced 2026-10-23 22:49:01 +03:00
Files
apache/test/modules/metadata/env.py
Joe Orton 47717ee2e4 mod_remoteip: Apply RemoteIP{Trusted,Internal}ProxyList to the virtual host
they are configured in, and fix merging.

* modules/metadata/mod_remoteip.c
  (merge_remoteip_server_config): When both the main server and the virtual
  host have proxymatch_ip entries, merge the two arrays.
  (remoteip_hook_post_config): Log a warning (APLOGNO 10633) for each
  virtual host whose proxy entries were merged with the main server's.
  (remoteip_cmds): Drop EXEC_ON_READ from RemoteIPTrustedProxyList and
  RemoteIPInternalProxyList so the directives apply in the server/vhost
  scope they are configured in, rather than globally at config read time.

* test/modules/metadata/test_004_remoteip.py: New test.

* test/modules/metadata/env.py
  (MetadataTestSetup.__init__): Add remoteip to the optional modules.

PR: 70207
Submitted by: Arturo Bernal <abernal apache.org>
GitHub: closes #793


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1938908 13f79535-47bb-0310-9956-ffa450edef68
2026-10-08 08:31:23 +00:00

41 lines
1.5 KiB
Python

import inspect
import logging
import os
from pyhttpd.env import HttpdTestEnv, HttpdTestSetup
log = logging.getLogger(__name__)
class MetadataTestSetup(HttpdTestSetup):
def __init__(self, env: 'HttpdTestEnv'):
super().__init__(env=env)
self.add_source_dir(os.path.dirname(inspect.getfile(MetadataTestSetup)))
self.add_modules(["mime", "mime_magic", "env", "include"])
# mod_mime_libmagic needs libmagic at build time, so it must not
# be a hard requirement; its tests skip when it is absent.
self.add_optional_modules(["mime_libmagic", "remoteip"])
class MetadataTestEnv(HttpdTestEnv):
def __init__(self, pytestconfig=None):
super().__init__(pytestconfig=pytestconfig)
# Only raise the log level for mod_mime_libmagic when it is built:
# a LogLevel for an unloaded module is a fatal config error, which
# would break the whole suite (including the mod_mime_magic tests)
# on platforms without libmagic, such as Windows.
log_modules = ["mime_magic", "env", "include", "core"]
if self.has_libmagic_module:
log_modules.insert(1, "mime_libmagic")
self.add_httpd_log_modules(log_modules)
def setup_httpd(self, setup: HttpdTestSetup = None):
super().setup_httpd(setup=MetadataTestSetup(env=self))
@property
def has_libmagic_module(self) -> bool:
"""Whether mod_mime_libmagic was built."""
return self.has_shared_module("mime_libmagic")