Skip to content

Conversation

@stephenredhat
Copy link
Contributor

@stephenredhat stephenredhat commented Jul 1, 2025

Describe your changes

This PR resolves inconsistent test behavior in test_authorization.cpp by explicitly setting key configuration values in all authorize_req-related unit tests. Specifically, each test now directly configures:

local_pre_authorize

local_authorize_offline

WebSocket connection status via ON_CALL(...).WillByDefault(...)

These changes ensure that test results are deterministic and isolated from global or default state, as described in issue #1042.

Issue ticket number and link

Fixes #1042
#1042

Checklist before requesting a review

  • I have performed a self-review of my code
  • I have made corresponding changes to the documentation
  • If OCPP 2.0.1 or OCPP2.1: I have updated the OCPP 2.x status document
  • I read the contribution documentation and made sure that my changes meet its requirements

@stephenredhat stephenredhat force-pushed the fix-1042-auth-test-cleanup branch from 93b66d1 to 6047d80 Compare July 1, 2025 12:06
@mlitre mlitre self-assigned this Jul 1, 2025
Copy link
Contributor

@mlitre mlitre left a comment

Choose a reason for hiding this comment

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

Thanks for picking up this issue! I think there are several other tests where we could be more explicit, such as: validate_token_local_auth_list_enabled_accepted, validate_token_local_auth_list_enabled_unknown_no_remote_authorization, validate_token_local_auth_list_enabled_unknown_websocket_disconnected, validate_token_local_auth_list_enabled_connectivity_manager_connected_accepted, validate_token_emaid_offline_no_certificate_contract_validation_offline_allowed_certificate_valid_no_authorize_offline, validate_token_emaid_offline_no_certificate_contract_validation_offline_allowed_certificate_valid_localauthlistctrlr_enabled, validate_token_emaid_offline_no_certificate_contract_validation_offline_allowed_certificate_expired and validate_token_auth_cache_lifetime_expired.
Once those tests are also updated, I think everything should be good. Please make sure to run clang-format after your modifications, I saw some format changes that could cause issues in the CI.

@stephenredhat stephenredhat force-pushed the fix-1042-auth-test-cleanup branch 2 times, most recently from 6330f09 to fd19e41 Compare July 3, 2025 15:22
@stephenredhat
Copy link
Contributor Author

Hi @mlitre
Thanks for the feedback I've updated all the mentioned tests to explicitly set the relevant configuration values and ran clang-format to fix formatting issues. Also cleaned up the PR to remove unrelated commits. Let me know if anything else is needed.

@mlitre
Copy link
Contributor

mlitre commented Jul 3, 2025

Hi @stephenredhat looks good to me, if you could just fix the tests by adding the missing device model argument in some of the calls to set the variables. Thanks!

@stephenredhat
Copy link
Contributor Author

stephenredhat commented Aug 7, 2025

Hi @mlitre I’ve updated all set_local_pre_authorize and set_local_authorize_offline calls to explicitly include device_model, as suggested. The changes are now committed and pushed. Let me know if there’s anything else you'd like to see. Thanks again for your help!

@mlitre
Copy link
Contributor

mlitre commented Aug 8, 2025

Hi @stephenredhat, thanks for taking the time to contribute! The changes look good to me, but could you please fix the issues seen in the CI? I believe there is format error, a dco error (please sign off your commits as per the contributing guidelines) and there seems to be a test that fails, if you could rectify that as well thank you!

@stephenredhat stephenredhat force-pushed the fix-1042-auth-test-cleanup branch from 13751e4 to f6f9ce0 Compare August 11, 2025 11:48
- Added explicit config setup for initial authorization tests
- Added explicit config setup for remaining authorization unit tests

Signed-off-by: Stephen Oresanya <soresany@redhat.com>
@stephenredhat stephenredhat force-pushed the fix-1042-auth-test-cleanup branch from f6f9ce0 to 8def1d1 Compare August 11, 2025 11:51
…fline calls to match new signature

Signed-off-by: Stephen Oresanya <soresany@redhat.com>
…tion tests

Ensures calls match function definitions by including the device_model argument.
Also reformatted with clang-format for CI compliance.

Signed-off-by: Stephen Oresanya <soresany@redhat.com>
@mlitre
Copy link
Contributor

mlitre commented Aug 14, 2025

Hi @stephenredhat thanks for updating everything, things look almost perfect now! Could you just take a look at the failing test case and see if there is a fix required in the code or if the test case is wrong?

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.

OCPP2.X: Inconsistent checks for authorization unit tests

2 participants