Basic HTTP Authentication in Elixir/Phoenix
If our server responds with 401 Unauthorized response including WWW-Authenticate response header with a Basic challenge as follows:
the browser can automatically ask the user for login credentials (login and password). The README of the BasicAuth plug gives us a hint on a helper:
Apart from the authentication helper that we pipe through with our connection we are also using valid credentials by default that we put to the text.exs file:
Of course it’s up to you to make sure that a user with such credentials exist during the test run. Finally, if you are authorizing users to manipulate data on the server, make sure to use CSRF protection, because as I stated in the beginning, the Authorization header is sent automatically by the browser.
Source: nts.strzibny.name