1
0
mirror of https://github.com/apache/httpd.git synced 2026-10-23 22:49:01 +03:00
Files
apache/test/modules/aaa/test_006_config_errors.py
Joe Orton 899294692f mod_auth_digest: Widen the one-time-nonce counter to 64 bits and move
inside the client hash table:

* modules/aaa/mod_auth_digest.c (struct hash_table): Hold the counter here
  as a 64-bit otn_counter, issued under client_lock like next_id rather
  than with 32-bit atomics (apr_atomic_inc64 is not available on the
  minimum APR).
  (initialize_tables): Seed it; drop its separate shared-memory allocation.
  (gen_nonce): Issue the ordinal under client_lock.
  (set_shmem_size): Account for two allocations rather than three.

* test/modules/aaa/test_006_config_errors.py
  (test_digest_069_shmemsize_no_room_for_entry_rejected): Adjust for the
  smaller minimum.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
GitHub: close #787


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1939038 13f79535-47bb-0310-9956-ffa450edef68
2026-10-11 13:55:33 +00:00

105 lines
4.1 KiB
Python

"""Config-time validation for directives whose *documented* syntax (see
docs/manual/mod/mod_auth_digest.xml) is broader than what this build's
mod_auth_digest.c actually implements: AuthDigestQop only accepts "auth"
(qop=none/auth-int are rejected -- the "Open Issues" comment in the source
notes MD5-sess and auth-int were removed as incomplete), AuthDigestAlgorithm
only accepts "MD5", and AuthDigestShmemSize enforces a minimum size. These
are all checked with `httpd -t` against a throwaway config so the shared
package server is never disturbed.
"""
from .env import AAATestEnv
class TestDigestConfigErrors:
def test_digest_060_qop_none_rejected(self, env):
r = env.configtest([
'AuthType Digest',
f'AuthName "{AAATestEnv.REALM}"',
'AuthDigestProvider file',
f'AuthUserFile "{env.digest_pwfile}"',
'AuthDigestQop none',
'Require valid-user',
])
assert r.exit_code != 0
assert "AuthDigestQop" in r.stderr
def test_digest_061_qop_auth_int_rejected(self, env):
r = env.configtest([
'AuthType Digest',
f'AuthName "{AAATestEnv.REALM}"',
'AuthDigestProvider file',
f'AuthUserFile "{env.digest_pwfile}"',
'AuthDigestQop auth-int',
'Require valid-user',
])
assert r.exit_code != 0
assert "AuthDigestQop" in r.stderr
def test_digest_062_qop_auth_accepted(self, env):
# the only value actually supported must still work.
r = env.configtest([
'AuthType Digest',
f'AuthName "{AAATestEnv.REALM}"',
'AuthDigestProvider file',
f'AuthUserFile "{env.digest_pwfile}"',
'AuthDigestQop auth',
'Require valid-user',
])
assert r.exit_code == 0
def test_digest_063_algorithm_md5_sess_rejected(self, env):
r = env.configtest([
'AuthType Digest',
f'AuthName "{AAATestEnv.REALM}"',
'AuthDigestProvider file',
f'AuthUserFile "{env.digest_pwfile}"',
'AuthDigestAlgorithm MD5-sess',
'Require valid-user',
])
assert r.exit_code != 0
assert "Unsupported algorithm" in r.stderr
def test_digest_064_algorithm_md5_accepted(self, env):
r = env.configtest([
'AuthType Digest',
f'AuthName "{AAATestEnv.REALM}"',
'AuthDigestProvider file',
f'AuthUserFile "{env.digest_pwfile}"',
'AuthDigestAlgorithm MD5',
'Require valid-user',
])
assert r.exit_code == 0
def test_digest_065_shmemsize_too_small_rejected(self, env):
r = env.configtest([], extra_top_lines=["AuthDigestShmemSize 10"])
assert r.exit_code != 0
assert "AuthDigestShmemSize" in r.stderr
def test_digest_066_shmemsize_valid_accepted(self, env):
r = env.configtest([], extra_top_lines=["AuthDigestShmemSize 1000"])
assert r.exit_code == 0
def test_digest_067_shmemsize_units_accepted(self, env):
r = env.configtest([], extra_top_lines=["AuthDigestShmemSize 64K"])
assert r.exit_code == 0
def test_digest_068_shmemsize_trailing_junk_rejected(self, env):
# Junk after the unit character must be rejected, not silently
# ignored (which read "64Kfoo" as 64K).
r = env.configtest([], extra_top_lines=["AuthDigestShmemSize 64Kfoo"])
assert r.exit_code != 0
assert "AuthDigestShmemSize" in r.stderr
def test_digest_069_shmemsize_no_room_for_entry_rejected(self, env):
# A size which would hold the table and an entry by their bare
# struct sizes, but not once the per-allocation rmm overhead is
# counted, must be rejected: otherwise every request needing an
# entry gets a 503 the config check did not warn about. 120 bytes is
# above those struct sizes but below the overhead-aware minimum on
# both 32- and 64-bit.
r = env.configtest([], extra_top_lines=["AuthDigestShmemSize 120"])
assert r.exit_code != 0
assert "AuthDigestShmemSize" in r.stderr