feat: Add unit and its tests#4
Conversation
|
Warning Rate limit exceeded
⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThis pull request introduces a GitHub Actions workflow for automated testing on the Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~22 minutes Poem
🚥 Pre-merge checks | ✅ 1 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (1 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
…n permissions Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (1)
.github/workflows/maven.yml (1)
11-15: Consider addingworkflow_dispatchfor manual workflow runs.While the current triggers are appropriate for CI, adding
workflow_dispatchallows developers to manually trigger the build when needed for testing or troubleshooting.🔧 Proposed enhancement
on: push: branches: [ "main" ] pull_request: branches: [ "main" ] + workflow_dispatch:🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In @.github/workflows/maven.yml around lines 11 - 15, Update the GitHub Actions triggers in the "on" block to allow manual runs by adding workflow_dispatch; modify the existing on: push/pull_request configuration (the top-level "on" stanza) to include workflow_dispatch so developers can trigger the maven workflow manually from the Actions UI.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In @.github/workflows/maven.yml:
- Around line 17-35: The job-level permissions are missing for the GITHUB_TOKEN
in the "build" job; add a permissions block under the build job (near the
runs-on / steps) that sets the minimal required scopes and explicitly grants
contents: write for the "Update dependency graph" action
(advanced-security/maven-dependency-submission-action@571e99aab1055c2e71a1e2309b9691de18d6b7d6)
while restricting other permissions to least privilege (e.g., read where
needed); place this permissions stanza at the job level so the build job and its
steps (including "Update dependency graph") use the specified, limited token
scopes.
- Line 35: Update the pinned action reference for
advanced-security/maven-dependency-submission-action used on the workflow step
(the line containing "uses:
advanced-security/maven-dependency-submission-action@571e99aab1055c2e71a1e2309b9691de18d6b7d6"):
replace the old SHA pin with the latest stable release tag (for example v5.0.0)
or update the SHA to the latest commit matching that stable tag to keep pinning
while getting the newest fixes and security improvements.
---
Nitpick comments:
In @.github/workflows/maven.yml:
- Around line 11-15: Update the GitHub Actions triggers in the "on" block to
allow manual runs by adding workflow_dispatch; modify the existing on:
push/pull_request configuration (the top-level "on" stanza) to include
workflow_dispatch so developers can trigger the maven workflow manually from the
Actions UI.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 12a3f6e4-e5b5-4aff-b7ba-873710b1b531
📒 Files selected for processing (1)
.github/workflows/maven.yml
…ovAngel-patch-1 # Conflicts: # .github/workflows/maven.yml
…n permissions Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
There was a problem hiding this comment.
🧹 Nitpick comments (2)
.github/workflows/test.yml (2)
94-100: Consider handling the "cancelled" state as well.The check only handles "failure" but jobs can also be "cancelled". You might want to treat cancelled jobs as failures for completeness:
- name: Check test results run: | - if [[ "${{ needs.unit-tests.result }}" == "failure" || "${{ needs.integration-tests.result }}" == "failure" ]]; then + if [[ "${{ needs.unit-tests.result }}" != "success" || "${{ needs.integration-tests.result }}" != "success" ]]; then echo "Tests failed!" exit 1 fi echo "All tests passed!"🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In @.github/workflows/test.yml around lines 94 - 100, The "Check test results" step currently treats only "failure" as a failing job; update the conditional that inspects needs.unit-tests.result and needs.integration-tests.result to also treat the "cancelled" state as a failure (e.g., check for == "failure" OR == "cancelled" for each dependency) so that cancelled jobs cause the step to echo "Tests failed!" and exit 1; update the conditional logic that references needs.unit-tests.result and needs.integration-tests.result accordingly.
1-14: Add explicit permissions block to limitGITHUB_TOKENscope.The workflow lacks a
permissionsblock, which means it uses the default token permissions. Following the principle of least privilege, explicitly restrict permissions. Since this workflow only needs to read the repository contents, add:name: Tests on: push: branches: [ "main" ] paths: - 'backend/**' - '.github/workflows/test.yml' pull_request: branches: [ "main" ] paths: - 'backend/**' - '.github/workflows/test.yml' +permissions: + contents: read + jobs:🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In @.github/workflows/test.yml around lines 1 - 14, The workflow "Tests" currently relies on default GITHUB_TOKEN permissions; add a top-level permissions block to restrict the token to least privilege by specifying permissions: contents: read (so the workflow can only read the repository), placed alongside the existing name and on keys; reference the workflow name "Tests" and the GITHUB_TOKEN usage to locate where to insert the new permissions block.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In @.github/workflows/test.yml:
- Around line 94-100: The "Check test results" step currently treats only
"failure" as a failing job; update the conditional that inspects
needs.unit-tests.result and needs.integration-tests.result to also treat the
"cancelled" state as a failure (e.g., check for == "failure" OR == "cancelled"
for each dependency) so that cancelled jobs cause the step to echo "Tests
failed!" and exit 1; update the conditional logic that references
needs.unit-tests.result and needs.integration-tests.result accordingly.
- Around line 1-14: The workflow "Tests" currently relies on default
GITHUB_TOKEN permissions; add a top-level permissions block to restrict the
token to least privilege by specifying permissions: contents: read (so the
workflow can only read the repository), placed alongside the existing name and
on keys; reference the workflow name "Tests" and the GITHUB_TOKEN usage to
locate where to insert the new permissions block.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: a3bc6afe-c2f8-4e0c-9076-7ba1eaf946a4
📒 Files selected for processing (4)
.github/workflows/test.ymlbackend/pom.xmlbackend/src/test/java/com/angel/autonow/ExampleControllerTest.javabackend/src/test/java/com/angel/autonow/security/TestSecurityConfig.java
💤 Files with no reviewable changes (1)
- backend/src/test/java/com/angel/autonow/security/TestSecurityConfig.java
✅ Files skipped from review due to trivial changes (1)
- backend/pom.xml
* Add initial commit * Add initial commit #2 * Add foundation * Add gitignore * Add menu * Add language support * Delete validation Rely only on backend * Move token * Add security * Address code review * Address code review #2 * Address code review #3 * Address code review #4 * Fix the api calling problem * Add some logs * Add debug logs * Remove hardcoded tab * Address sonar issue * Address email exposure * Add cors for the test application properties * Add cors for the test application properties #2 --------- Co-authored-by: Stoynov <angel.stoynov@sap.com>
Summary by CodeRabbit
Tests
Chores