Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat/tests: tests for error handling & metrics in admin endpoints #6805

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

gdhameeja
Copy link
Contributor

@gdhameeja gdhameeja commented Jan 24, 2025

  • TestAdminHandlerErrorHandling - Tests the handler.handleError()
    functionality by directly verifying error response formatting
    • TestAdminHandlerBuiltinRouteErrors - Tests the error
      handling pathway by using real admin server routes and verifying
      both error responses and prometheus metrics increments
    • provisionAdminRouters: add unit tests for admin handler registration and routing for admin.api
    • TestAllowedOriginsUnixSocket: checks unix socket with default origins are added
    • TestReplaceRemoteAdminServer: test for replaceRemoteAdminServer with certificate validation, custom origins and cleanup
    • TestManageIdentity: tests the manageIdentity function to test identifiers with configs.

this increases the test coverage of admin.go from 31% to 59%.
Increases total coverage from 37.9% to 47%.

I added this PR as a way to learn more about caddy's codebase and to contribute to caddy. I'd love to contribute more of these tests if such contributions are welcome.

@CLAassistant
Copy link

CLAassistant commented Jan 24, 2025

CLA assistant check
All committers have signed the CLA.

@gdhameeja gdhameeja force-pushed the feat/test-admin-error-handling branch from 80816c6 to 704394d Compare January 24, 2025 22:18
@mholt mholt requested a review from mohammed90 January 30, 2025 18:25
@mholt
Copy link
Member

mholt commented Jan 30, 2025

Thanks for the PR! Maybe @mohammed90 or @hairyhenderson would be suitable for reviewing this if they have a few minutes. 👍

- TestAdminHandlerErrorHandling - Tests the handler.handleError()
   functionality by directly verifying error response formatting
- TestAdminHandlerBuiltinRouteErrors - Tests the error
   handling pathway by using real admin server routes and verifying
   both error responses and prometheus metrics increments
- provisionAdminRouters: add unit tests for admin handler registration and routing for admin.api
- TestAllowedOriginsUnixSocket: checks unix socket with default origins are added
- TestReplaceRemoteAdminServer: test for replaceRemoteAdminServer with certificate validation, custom origins and cleanup
@gdhameeja gdhameeja force-pushed the feat/test-admin-error-handling branch from 6364add to cacbe17 Compare February 3, 2025 07:55
@gdhameeja
Copy link
Contributor Author

@mholt @mohammed90 Just pushed a couple more tests for admin. Please review the same and let me know if any fixes are required. Thanks :)

@gdhameeja gdhameeja force-pushed the feat/test-admin-error-handling branch 2 times, most recently from 4486cb9 to 6138fe1 Compare February 3, 2025 09:45
@gdhameeja gdhameeja force-pushed the feat/test-admin-error-handling branch from 6138fe1 to cc504eb Compare February 3, 2025 09:47
@gdhameeja
Copy link
Contributor Author

@mholt @mohammed90 gentle reminder to review this PR. Would love to see this merged as it is my first open source contribution after a long time :)

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.

3 participants