Creating test cases for secured API and web components
All applications in Chapter 9 implement the authentication methods essential to small-, middle-, or large-scale Flask applications. pytest
can test secured components, both standard and asynchronous ones. This chapter will cover testing Cross-Site Request Forgery- or CSRF-protected views running on an HTTPS with flask-session
managing the user session, HTTP basic authenticated views, and web views secured by the flask-login
extension module.
Testing secured API functions
Chapter 9 showcases a Vaccine Reporting and Management system with web-based and API-based versions. The ch09-web-passphrase
project is a web version of the prototype with views protected by a custom authentication mechanism using the flask-session
module, web forms that are CSRF-protected, and all components running on an HTTPS protocol.
The /ch09/login/auth
route is the entry point to the application, where users must log in using their username
and...