Skip to content

[INT-3877] Read test API key from ONFLEET_API_KEY env var - #68

Open
joao-onfleet wants to merge 1 commit into
masterfrom
INT-3877
Open

joao-onfleet wants to merge 1 commit into
masterfrom
INT-3877

Conversation

@joao-onfleet

@joao-onfleet joao-onfleet commented Sep 17, 2026

Copy link
Copy Markdown
Contributor

Summary

Improvement 1, step 2 of INT-3877: remove the hardcoded API key from test/test_onfleet.py.

  • The suite reads the key from the ONFLEET_API_KEY environment variable.
  • When the variable is not set, setUp skips the live-API tests instead of failing. This lets offline CI run without the secret (ticket step 10).
  • The exposed key is revoked: GET /api/v2/auth/test returns HTTP 401.

Pending: no value set for ONFLEET_API_KEY yet

We did not create the replacement API key yet. We are pending access to a new production account to create it. Until then, the variable stays empty and the live-API tests skip. This is intentional and safe: the suite exits green with all tests skipped. When the key exists, store it as the GitHub Actions secret ONFLEET_API_KEY — do not commit it.

Notes

  • The git history purge (git filter-repo --replace-text + force-push) runs after this PR merges, so the rewritten tip contains this fix.
  • Use a key from a dedicated test organization: the suite performs real writes.

Test plan

  • python -m unittest discover -s test -v from the repo root without ONFLEET_API_KEY: all 5 tests skip, exit 0.

🤖 Generated with Claude Code

https://claude.ai/code/session_01UmWS7B7g3HKpoenKRaGnNu

Remove the hardcoded API key from test/test_onfleet.py. The suite now
reads ONFLEET_API_KEY and skips live-API tests when it is not set.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UmWS7B7g3HKpoenKRaGnNu

@cubic-dev-ai cubic-dev-ai Bot 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.

1 issue found across 1 file

Confidence score: 4/5

  • test/test_onfleet.py no longer runs the documented Docker test workflow when invoked without environment variables, so docker-compose up --build can pass without exercising tests; update the Docker workflow or test entry point to ensure the suite executes.
Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="test/test_onfleet.py">

<violation number="1" location="test/test_onfleet.py:20">
P2: The documented Docker test workflow now runs zero tests. README's "Unit testing using Docker" (`docker-compose up --build`) executes `python test/test_onfleet.py` with no env vars set, so after this change all tests silently skip and exit 0 instead of exercising the API. Pass ONFLEET_API_KEY into the container (e.g., `environment:` in docker-compose.yml, `ARG`/`ENV` in the Dockerfile, or an explicit `-e ONFLEET_API_KEY=...` in the README command), or update the README to state the key is required, otherwise this documented flow no-ops.</violation>
</file>

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread test/test_onfleet.py
# real writes (creates and deletes admins, workers, hubs, teams).
self.api_key = os.environ.get("ONFLEET_API_KEY")
if (not self.api_key):
self.skipTest("ONFLEET_API_KEY environment variable is not set")

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2: The documented Docker test workflow now runs zero tests. README's "Unit testing using Docker" (docker-compose up --build) executes python test/test_onfleet.py with no env vars set, so after this change all tests silently skip and exit 0 instead of exercising the API. Pass ONFLEET_API_KEY into the container (e.g., environment: in docker-compose.yml, ARG/ENV in the Dockerfile, or an explicit -e ONFLEET_API_KEY=... in the README command), or update the README to state the key is required, otherwise this documented flow no-ops.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At test/test_onfleet.py, line 20:

<comment>The documented Docker test workflow now runs zero tests. README's "Unit testing using Docker" (`docker-compose up --build`) executes `python test/test_onfleet.py` with no env vars set, so after this change all tests silently skip and exit 0 instead of exercising the API. Pass ONFLEET_API_KEY into the container (e.g., `environment:` in docker-compose.yml, `ARG`/`ENV` in the Dockerfile, or an explicit `-e ONFLEET_API_KEY=...` in the README command), or update the README to state the key is required, otherwise this documented flow no-ops.</comment>

<file context>
@@ -11,8 +12,12 @@
+        # real writes (creates and deletes admins, workers, hubs, teams).
+        self.api_key = os.environ.get("ONFLEET_API_KEY")
+        if (not self.api_key):
+            self.skipTest("ONFLEET_API_KEY environment variable is not set")
         self.api = onfleet.Onfleet(api_key=self.api_key)
 
</file context>

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