Skip to content

feat: add OCPI 2.3.0 support to push functionality#20

Merged
alfonsosastre merged 3 commits intomainfrom
feat/push-v2-3-0-support
Feb 24, 2026
Merged

feat: add OCPI 2.3.0 support to push functionality#20
alfonsosastre merged 3 commits intomainfrom
feat/push-v2-3-0-support

Conversation

@alfonsosastre
Copy link
Copy Markdown
Contributor

Summary

  • send_push_request now matches endpoints by RECEIVER role for 2.3.x versions, consistent with the existing 2.2.x behaviour. Previously, 2.3.0 pushes would silently use an empty base_url because the version check only covered startswith("2.2").
  • Token encoding already handled correctly for 2.3.x (base64) via the existing else branch — added a clarifying comment.

Root cause

# Before — 2.3.0 never matched, base_url stayed ""
if version.value.startswith("2.2") and endpoint["role"] == InterfaceRole.receiver:
    ...

# After
if (version.value.startswith("2.2") or version.value.startswith("2.3")) and ...:
    ...

Test plan

  • New test test_push_v_2_3_0_uses_receiver_role_and_base64_token verifies:
    • RECEIVER endpoint is selected (SENDER is ignored)
    • Auth token is base64-encoded
    • Correct URL is used for the push request
  • All 451 tests pass

🤖 Generated with Claude Code

Alfonso Sastre and others added 3 commits February 23, 2026 14:03
send_push_request now matches endpoints by RECEIVER role for 2.3.x
(same as 2.2.x), and push_object already base64-encodes tokens for
any version beyond 2.1.x. Previously 2.3.0 pushes would silently
use an empty base_url because the version check only covered "2.2".

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Replace explicit startswith("2.2") or startswith("2.3") with
a negated check, so any version beyond 2.0.x/2.1.x automatically
uses RECEIVER role filtering without needing code changes.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@alfonsosastre alfonsosastre merged commit 22e5032 into main Feb 24, 2026
4 checks passed
alfonsosastre added a commit that referenced this pull request Feb 24, 2026
* feat: add OCPI 2.3.0 support to push functionality (#20)

* feat: add OCPI 2.3.0 support to push functionality

send_push_request now matches endpoints by RECEIVER role for 2.3.x
(same as 2.2.x), and push_object already base64-encodes tokens for
any version beyond 2.1.x. Previously 2.3.0 pushes would silently
use an empty base_url because the version check only covered "2.2".

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* refactor: future-proof push endpoint version check

Replace explicit startswith("2.2") or startswith("2.3") with
a negated check, so any version beyond 2.0.x/2.1.x automatically
uses RECEIVER role filtering without needing code changes.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* style: apply ruff format to push.py

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Alfonso Sastre <alfonso@elumobility.com>
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>

* fix: handle OCPI version negotiation in push_object

push_object now accepts both a versions URL and a version details URL
as endpoints_url. When a versions list is returned (data is a list),
it automatically picks the best mutual version and fetches the details
URL to discover endpoints. This follows the proper OCPI spec flow:

1. GET /versions → list of supported versions with details URLs
2. Pick best mutual version
3. GET /{version}/details → list of endpoints
4. Push to the correct module endpoint

Co-authored-by: Cursor <cursoragent@cursor.com>

---------

Co-authored-by: Alfonso Sastre <alfonso@elumobility.com>
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
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.

1 participant