🧪 Add input validation for --run-as flag#599
Conversation
Signed-off-by: Nandini Chandra <nachandr@redhat.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
🚧 Files skipped from review as they are similar to previous changes (2)
📝 WalkthroughWalkthroughAdds ChangesRunAs validation and suite startup
Estimated code review effort: 1 (Trivial) | ~5 minutes Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
Test Coverage ReportTotal: 47.8% Per-package coverage
Full function-level detailsPosted by CI |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@e2e-tests/config/config.go`:
- Around line 19-30: The ValidateAndLogRunAsFlag function is exiting the process
directly on invalid input, which prevents Ginkgo from reporting the failure
normally. Change this helper to return an error instead of calling log.Fatalf,
and update the BeforeSuite callers in the tier0 and tier1 suites to assert
success (for example via Fail/Expect) so invalid --run-as values are surfaced as
reportable suite failures while still keeping the existing log messages for the
valid admin and non-admin paths.
- Around line 19-30: Add a focused unit test for ValidateAndLogRunAsFlag in
e2e-tests/config that exercises the empty RunAs, "admin", and invalid value
branches without relying on full e2e suites. Use the existing RunAs global and
validate that the function logs the expected mode for empty and admin values,
and that an invalid value triggers the fatal path (for example by running it in
a subprocess or equivalent test-safe fatal handling).
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 7e17ca5a-5e1c-4a9c-8cc8-5de03a3e9f49
📒 Files selected for processing (3)
e2e-tests/config/config.goe2e-tests/tests/tier0/e2e_suite_test.goe2e-tests/tests/tier1/e2e_suite_test.go
Signed-off-by: Nandini Chandra <nachandr@redhat.com>
Summary by CodeRabbit
run-assetting so invalid values stop the test run early.The --run-as flag accepts any string, but only "admin" has special behavior. Typos like --run-as=admon or --run-as=adming do nothing and fall back to non-admin mode and the test is run as non-admin. Users get unexpected behavior without any error message
Example of the problem:
$ User makes a typo
$ ginkgo run -v --focus="\[MTA-850\]" e2e-tests/tests/tier1 -- --k8sdeploy-bin=~/k8s-apps-deployer/venv/bin/k8sdeploy --crane-bin=~/migtools-crane/crane/crane --source-context=kind-source-cluster --target-context=kind-dest-cluster --source-nonadmin-context=crane-source-context --target-nonadmin-context=crane-dest-context --run-as=admonSolution:
Fail fast with a clear error message:
Invalid --run-as value: "admon". Valid values: "admin" or empty string (for non-admin mode)
Summary by CodeRabbit
run-asvalues are caught early.