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

Merged

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 :)

@mholt
Copy link
Member

mholt commented Feb 12, 2025

We're glad for the contribution, thank you! I've just been very busy.

I haven't reviewed the change super thoroughly, but it looks acceptable at a glance. Generally, we welcome more tests!

Copy link
Member

@mholt mholt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the PR -- sorry again for the wait. Welcome back to open source, then!

We'll get this merged momentarily.

Copy link
Member

@mohammed90 mohammed90 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for adding the tests! They seem good.

@mohammed90 mohammed90 enabled auto-merge (squash) February 12, 2025 11:29
@mohammed90 mohammed90 merged commit d7621fd into caddyserver:master Feb 12, 2025
32 of 33 checks passed
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.

4 participants