Add unit tests for error handling and authorization checks by devin-ai-integration[bot] · Pull Request #12 · jack-killian/Deere_OperationsCenterAPI-OAuth2-Java · GitHub
Skip to content

Add unit tests for error handling and authorization checks#12

Closed
devin-ai-integration[bot] wants to merge 1 commit into
masterfrom
devin/1768916755-add-error-handling-auth-tests
Closed

Add unit tests for error handling and authorization checks#12
devin-ai-integration[bot] wants to merge 1 commit into
masterfrom
devin/1768916755-add-error-handling-auth-tests

Conversation

@devin-ai-integration

Copy link
Copy Markdown

Summary

Adds unit tests to cover error handling and authorization scenarios that were previously missing from the test suite. This includes tests for HTTP error responses (400, 404, 422, 500, 503) and authorization failures (401 Unauthorized, 403 Forbidden).

Changes:

  • Added JUnit 5 and Mockito test dependencies to pom.xml
  • Added maven-surefire-plugin for running JUnit 5 tests
  • Created 3 test classes with 22 total tests:
    • RequestExceptionTest - Verifies exception message formatting for various HTTP error codes
    • LoggingInterceptorTest - Tests error handling in the HTTP interceptor for 4xx/5xx responses
    • AuthorizationTest - Tests 401 (missing/expired/malformed tokens) and 403 (private transaction access, insufficient scope, cross-org access) scenarios

Review & Testing Checklist for Human

  • pom.xml indentation: The maven-compiler-plugin and maven-surefire-plugin have inconsistent indentation (extra spaces) - verify this doesn't cause build issues
  • Test coverage alignment: Verify the authorization tests adequately cover "commenting on private transactions" as originally requested - the tests mock this scenario but don't test actual comment functionality
  • Run mvn clean test locally to confirm all 22 tests pass

Test Plan

  1. Run mvn clean test - should see 22 tests pass
  2. Review test names in each file to confirm they match expected error handling scenarios

Notes

  • These are unit tests using Mockito mocks - they verify the exception handling logic works correctly but don't make actual API calls
  • All tests passed locally before PR creation

Link to Devin run: https://app.devin.ai/sessions/d14feb55c19d44f984fa1948afb60ec8
Requested by: Jack (@jack-killian)

- Add JUnit 5 and Mockito test dependencies to pom.xml
- Add maven-surefire-plugin for running JUnit 5 tests
- Add RequestExceptionTest: tests for error handling with various HTTP status codes (400, 404, 422, 500, 503)
- Add LoggingInterceptorTest: tests for error handling in HTTP interceptor
- Add AuthorizationTest: tests for 401 Unauthorized and 403 Forbidden scenarios including:
  - Missing/expired/malformed tokens
  - Commenting on private transactions without permission
  - Accessing resources from other organizations
  - Insufficient scope errors
  - Read-only transaction modifications

Total: 22 tests covering error handling and authorization scenarios
Co-Authored-By: Jack <jack.l.killian@gmail.com>
@devin-ai-integration

Copy link
Copy Markdown
Author

@devin-ai-integration

Copy link
Copy Markdown
Author

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.

0 participants