Skip to content
This repository was archived by the owner on Jan 23, 2026. It is now read-only.

remove login method#426

Merged
mangelajo merged 1 commit intojumpstarter-dev:mainfrom
odra:corellium-api-fix
Apr 25, 2025
Merged

remove login method#426
mangelajo merged 1 commit intojumpstarter-dev:mainfrom
odra:corellium-api-fix

Conversation

@odra
Copy link
Copy Markdown
Contributor

@odra odra commented Apr 24, 2025

Changes

  • refactor to remove Corellium's login/session creation and use its API token directly.

Verification

It should work as before, just an internal API improvement.

Summary by CodeRabbit

  • Refactor
    • Simplified authentication by using bearer token directly, removing explicit login and session management.
  • Tests
    • Removed tests related to explicit session handling and login.
    • Updated tests to reflect changes in attribute access and authentication logic.
  • Chores
    • Removed unused session-related code and data structures.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 24, 2025

Walkthrough

The changes remove explicit session management and login logic from the Corellium API client and its associated driver and tests. The Session dataclass and related methods are eliminated, and authentication now relies solely on setting a bearer token in the Authorization header during API client initialization. The driver no longer manages session refresh or login, and the internal API client attribute is made public. Corresponding test code is updated to remove session and login-related logic, and references to the now-public API client attribute are adjusted throughout.

Changes

File(s) Change Summary
corellium/api.py Removed Session usage, eliminated login method, set Authorization header with bearer token in constructor.
corellium/types.py Removed Session dataclass and its as_header() method.
corellium/api_test.py Removed session setup and login-related tests (test_login_ok, test_login_error), adjusted remaining tests.
corellium/driver.py Simplified api property to return _api directly, removed session/login logic and unused imports.
corellium/driver_test.py Updated tests to use api instead of _api, removed Session import, simplified patches and assertions.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant CorelliumDriver
    participant ApiClient
    participant CorelliumAPI

    User ->> CorelliumDriver: Instantiate with host and token
    CorelliumDriver ->> ApiClient: Initialize with host and token
    ApiClient ->> ApiClient: Set Authorization header with bearer token
    User ->> CorelliumDriver: Make API call
    CorelliumDriver ->> ApiClient: Forward API call
    ApiClient ->> CorelliumAPI: Send request with Authorization header
    CorelliumAPI -->> ApiClient: Respond with data
    ApiClient -->> CorelliumDriver: Return response
    CorelliumDriver -->> User: Return result
Loading

Poem

In the warren of code, a session once sat,
But now with a token, authentication’s where it’s at!
No more logins to juggle or sessions to renew,
Just a bearer in headers, sleek and true.
The tests are now lighter, the code is more spry—
A hop and a skip, Corellium’s API!
🐇✨


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f9d5c4f and 100b00c.

📒 Files selected for processing (5)
  • packages/jumpstarter-driver-corellium/jumpstarter_driver_corellium/corellium/api.py (1 hunks)
  • packages/jumpstarter-driver-corellium/jumpstarter_driver_corellium/corellium/api_test.py (1 hunks)
  • packages/jumpstarter-driver-corellium/jumpstarter_driver_corellium/corellium/types.py (1 hunks)
  • packages/jumpstarter-driver-corellium/jumpstarter_driver_corellium/driver.py (1 hunks)
  • packages/jumpstarter-driver-corellium/jumpstarter_driver_corellium/driver_test.py (9 hunks)
✅ Files skipped from review due to trivial changes (1)
  • packages/jumpstarter-driver-corellium/jumpstarter_driver_corellium/driver.py
🚧 Files skipped from review as they are similar to previous changes (4)
  • packages/jumpstarter-driver-corellium/jumpstarter_driver_corellium/corellium/types.py
  • packages/jumpstarter-driver-corellium/jumpstarter_driver_corellium/corellium/api_test.py
  • packages/jumpstarter-driver-corellium/jumpstarter_driver_corellium/driver_test.py
  • packages/jumpstarter-driver-corellium/jumpstarter_driver_corellium/corellium/api.py
⏰ Context from checks skipped due to timeout of 90000ms (4)
  • GitHub Check: e2e
  • GitHub Check: pytest-matrix (3.13)
  • GitHub Check: pytest-matrix (3.11)
  • GitHub Check: pytest-matrix (3.12)
✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@netlify
Copy link
Copy Markdown

netlify Bot commented Apr 24, 2025

Deploy Preview for jumpstarter-docs ready!

Name Link
🔨 Latest commit 100b00c
🔍 Latest deploy log https://app.netlify.com/sites/jumpstarter-docs/deploys/680ab44db7f930000839ae33
😎 Deploy Preview https://deploy-preview-426--jumpstarter-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@odra odra force-pushed the corellium-api-fix branch from 14b82e8 to f9d5c4f Compare April 24, 2025 21:50
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Caution

Inline review comments failed to post. This is likely due to GitHub's limits when posting large numbers of comments. If you are seeing this consistently it is likely a permissions issue. Please check "Moderation" -> "Code review limits" under your organization settings.

Actionable comments posted: 3

🧹 Nitpick comments (2)
packages/jumpstarter-driver-corellium/jumpstarter_driver_corellium/corellium/api.py (1)

15-19: Tighten constructor doc-string

The doc-string ends abruptly (“containing a”). This makes auto-generated documentation look unpolished.

packages/jumpstarter-driver-corellium/jumpstarter_driver_corellium/driver.py (1)

25-26: Public api exposure: double-check encapsulation intent

Changing from private _api to public api increases the surface area: external callers/tests can now mutate internal state freely (e.g. swap out req.headers).
If this is intentional (to ease testing) consider:

  • Annotating with a leading underscore and adding @property read-only accessor, or
  • Documenting that the field is public and MUST NOT be reassigned.

Also applies to: 61-62

🛑 Comments failed to post (3)
packages/jumpstarter-driver-corellium/jumpstarter_driver_corellium/corellium/api.py (1)

21-24: ⚠️ Potential issue

Remove dead session attribute and trailing-whitespace line

self.session is now an unused vestige of the old login flow and can be misleading for maintainers.
Line 31 contains only whitespace and is triggering Ruff W293.

-        self.session = None
         self.req = requests.Session()
         self.req.headers.update({'Authorization': f'Bearer {self.token}'})
-
+

Also applies to: 31-31

packages/jumpstarter-driver-corellium/jumpstarter_driver_corellium/driver_test.py (2)

101-108: ⚠️ Potential issue

Wrong method invoked – calling off() in power-on error test

test_driver_power_on_error should exercise power.on(), not power.off(), otherwise it’s validating the wrong path.

-            power.off()
+            power.on()
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

    with pytest.raises((CorelliumApiException, ValueError)):
        with (patch.object(root.api, 'get_project',
                           **mock_data.get('get_project', {'return_value': project})),
              patch.object(root.api, 'get_instance',
                           **mock_data.get('get_instance', {'return_value': instance})),
              patch.object(root.api, 'create_instance',
                           **mock_data.get('create_instance', {'return_value': instance}))):
            power.on()

187-191: ⚠️ Potential issue

Copy-paste issue: patching the wrong method name

The last patch nests get_instance_console_id twice; the second one should target get_instance_console_url.

-              patch.object(root.api, 'get_instance_console_id',
-                           **mock_data.get('get_instance_console_url', {'return_value': 'ws://mock'}))):
+              patch.object(root.api, 'get_instance_console_url',
+                           **mock_data.get('get_instance_console_url', {'return_value': 'ws://mock'}))):

Without this, the mock dict key is ignored and the context manager raises AttributeError.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

              patch.object(root.api, 'get_instance_console_id',
                           **mock_data.get('get_instance_console_id', {'return_value': 'uart7-cons'})),
              patch.object(root.api, 'get_instance_console_url',
                           **mock_data.get('get_instance_console_url', {'return_value': 'ws://mock'}))):
            assert console.url

Signed-off-by: Leonardo Rossetti <lrossett@redhat.com>
@odra odra force-pushed the corellium-api-fix branch from f9d5c4f to 100b00c Compare April 24, 2025 21:59
@mangelajo mangelajo merged commit 35f6819 into jumpstarter-dev:main Apr 25, 2025
15 checks passed
@mangelajo mangelajo added this to the 0.6.0 milestone May 8, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants