[INT-3877] Read test API key from ONFLEET_API_KEY env var - #68
Open
joao-onfleet wants to merge 1 commit into
Open
joao-onfleet wants to merge 1 commit into
joao-onfleet wants to merge 1 commit into
Conversation
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
There was a problem hiding this comment.
1 issue found across 1 file
Confidence score: 4/5
test/test_onfleet.pyno longer runs the documented Docker test workflow when invoked without environment variables, sodocker-compose up --buildcan 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
| # 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") |
There was a problem hiding this comment.
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Improvement 1, step 2 of INT-3877: remove the hardcoded API key from
test/test_onfleet.py.ONFLEET_API_KEYenvironment variable.setUpskips the live-API tests instead of failing. This lets offline CI run without the secret (ticket step 10).GET /api/v2/auth/testreturns HTTP 401.Pending: no value set for
ONFLEET_API_KEYyetWe 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
git filter-repo --replace-text+ force-push) runs after this PR merges, so the rewritten tip contains this fix.Test plan
python -m unittest discover -s test -vfrom the repo root withoutONFLEET_API_KEY: all 5 tests skip, exit 0.🤖 Generated with Claude Code
https://claude.ai/code/session_01UmWS7B7g3HKpoenKRaGnNu