Skip to content
Advertisement

Test basic auth

I want to test my basic auth protected pages. The test for unauthorization works fine. But I struggle on the authorized login, as I do not know how to set the headers on in the test.

I could not find a hint, how to set headers on $this->call(). The only information I could find was:

JavaScript

and there are the headers missing.

How do I easily test basic auth on laravel. Concrete: How do I set the basic auth header for the test request?

What I currently have:

JavaScript

I tried $this->$request->setHeader(); but with this I only get an error:

JavaScript

Advertisement

Answer

Found the solution with HTTP authentication with PHP. This can be used in the $server parameter of $this->call().

Here’s my working function:

JavaScript
User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement