Skip to content

mod_authn_socache: add test coverage, fix a crash with AuthnCacheProvideFor in htaccess - #1046

Merged
notroj merged 5 commits into
apache:trunkfrom
notroj:test-authn-socache
Nov 16, 2026
Merged

notroj merged 5 commits into
apache:trunkfrom
notroj:test-authn-socache

Conversation

@notroj

@notroj notroj commented Nov 16, 2026 •

Copy link
Copy Markdown
Collaborator

Adds pytest coverage for mod_authn_socache, which had none, and fixes bugs found along the way.

  • AuthnCacheProvideFor in an htaccess file crashed the child process if caching was not enabled anywhere in the main configuration. It is now ignored there, which is what the AuthnCacheEnable documentation already describes.
  • mod_socache_dbm reported a missing key as a generic failure rather than APR_NOTFOUND, so with AuthnCacheSOCache dbm every cache miss logged "Error accessing authentication cache" at error level.
  • The code in mod_socache_dbm for APR-util 1.7 was never compiled, because the file tested APU_MAJOR_VERSION without including apu_version.h, and it did not compile once enabled.

The tests cannot see from a response whether the cache answered, so they make the cache and the password file disagree: log in, rewrite the file with a different password, and check which of the two passwords is then accepted. They run against the default provider and shmcb, not dbm.

The two tests using different password files within one directory are based on those in #930. They cover only what is unchanged by that PR; its test that a different AuthName separates entries is not included, since that is not the behaviour on trunk.

Also replaces the dead link to r957072 in the mod_authn_socache manual page with a description of ap_authn_cache_store and an example of its use.

🤖 Generated with Claude Code

@arturobernalg arturobernalg left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

notroj and others added 5 commits November 16, 2026 18:08
  (TestAuthnSocache.test_authn_socache_173_files_share_directory_context,
  TestAuthnSocache.test_authn_socache_174_files_context): Based on
  tests by Hafiar <289389248+0xABCD01 users.noreply.github.com> in
  GitHub PR apache#930.

* test/modules/aaa/env.py (AAATestSetup.__init__): Load
  mod_authn_socache.
  (AAATestEnv.__init__): Log mod_authn_socache.
  (AAATestEnv.write_basic_pwfile, AAATestEnv.write_digest_pwfile,
  AAATestEnv.preserved_test_conf): New.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
  and its use in place of a link to r957072.

[skip ci]

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
without AuthnCacheEnable:

* modules/aaa/mod_authn_socache.c (authn_cache_setprovider): Don't
  set configured from an htaccess file.

* test/modules/aaa/test_016_authn_socache.py
  (TestAuthnSocacheHtaccess): Test without AuthnCacheEnable.

* changes-entries/authn_socache_htaccess.txt: New file.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
  APR_NOTFOUND for a missing key.

* changes-entries/socache_dbm_notfound.txt: New file.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
compiled:

* modules/cache/mod_socache_dbm.c: Include apu_version.h.
  (socache_dbm_init, socache_dbm_store, socache_dbm_retrieve,
  socache_dbm_remove, socache_dbm_expire, socache_dbm_status,
  socache_dbm_iterate): Fix parentheses in the apr_dbm_get_driver()
  test.
  (socache_dbm_retrieve): Use rc, not rv.
  (socache_dbm_expire): Don't return a value.

Fixes: 95592b5 (SVN r1891019)

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@notroj
notroj force-pushed the test-authn-socache branch from 05bad09 to 3dadb40 Compare November 16, 2026 18:12
@notroj

notroj commented Nov 16, 2026

Copy link
Copy Markdown
Collaborator Author

mod_socache_dbm testing was tripping ASAN at shutdown/restart, will come back to that.

@notroj
notroj merged commit b7e2112 into apache:trunk Nov 16, 2026
46 checks passed
@notroj
notroj deleted the test-authn-socache branch November 16, 2026 19:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants