This pull request introduces a significant refactor to app.test.js to incorporate authentication via JWT tokens for testing secured endpoints. Previously, the tests did not authenticate requests, which limited our ability to fully test the API's security features. By adding a login step before the tests run, we can now obtain a token and use it to authenticate requests to endpoints that require authentication.
Summary
Added a before hook to log in and obtain a JWT token.
Stored the obtained token in a variable for use in subsequent requests.
Modified POST, PUT, and DELETE requests in tests to include the Authorization header, using the Bearer ${token} scheme.
Ensured all tests pass with the new authentication flow.
Aimed to enhance the security testing coverage of the Book API endpoints in test/app.test.js.
This refactor ensures that our tests more accurately reflect real-world usage scenarios where endpoints are protected by authentication.
Fixes #109.
🎉 Latest improvements to Sweep:
New dashboard launched for real-time tracking of Sweep issues, covering all stages from search to coding.
Integration of OpenAI's latest Assistant API for more efficient and reliable code planning and editing, improving speed by 3x.
PR Feedback (click)
Description
This pull request introduces a significant refactor to
app.test.js
to incorporate authentication via JWT tokens for testing secured endpoints. Previously, the tests did not authenticate requests, which limited our ability to fully test the API's security features. By adding a login step before the tests run, we can now obtain a token and use it to authenticate requests to endpoints that require authentication.Summary
before
hook to log in and obtain a JWT token.token
in a variable for use in subsequent requests.Authorization
header, using theBearer ${token}
scheme.Book API
endpoints intest/app.test.js
.This refactor ensures that our tests more accurately reflect real-world usage scenarios where endpoints are protected by authentication.
Fixes #109.
🎉 Latest improvements to Sweep:
💡 To get Sweep to edit this pull request, you can:
This is an automated message generated by Sweep AI.