Skip to content

[19.0][FIX] password_security: avoid crash in password rules when no test is running - #1051

Open
jacar-javi wants to merge 1 commit into
OCA:19.0from
jacar-javi:19.0-fix-password_security-rules-no-test
Open

jacar-javi wants to merge 1 commit into
OCA:19.0from
jacar-javi:19.0-fix-password_security-rules-no-test

Conversation

@jacar-javi

Copy link
Copy Markdown

With tests enabled (--test-enable) but no test running yet, odoo.modules.module.current_test is a boolean instead of a test case.

e36eb70 already made _check_password_policy read test_module with getattr for this reason, but _check_password_rules still reads current_test.test_module directly. Called in that state (for instance from the signup controller, PasswordSecurityHome.do_signup), it fails with:

AttributeError: 'bool' object has no attribute 'test_module'

This reads test_module the same way in both places, and adds a test that patches current_test to False (it fails without the fix).

Found while running the tests of a project that depends on password_security with --test-enable.

This change was prepared with AI assistance (Claude) and reviewed by me.

…s running

With tests enabled but no test running yet, `current_test` is a boolean
instead of a test case. `_check_password_policy` already reads
`test_module` with `getattr` for this reason (e36eb70), but
`_check_password_rules` still reads it directly, so calling it in that
state (e.g. from the signup controller) fails with an AttributeError.

Read `test_module` the same way in both places.

Assisted-by: Claude Opus 5.5

@polcerverapyming polcerverapyming left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

mod:password_security Module password_security series:19.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants