Skip to content

Commit

Permalink
Merge pull request #640 from cakephp/3.x-testing-docs
Browse files Browse the repository at this point in the history
add docs on how to test basic/digest auth
  • Loading branch information
LordSimal committed Sep 19, 2023
2 parents 27c0d04 + e48ff9d commit a178bf5
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions docs/en/testing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,23 @@ With token based authentication you need to simulate the
$this->get('/api/bookmarks');
$this->assertResponseOk();
}


Basic/Digest based authentication
=================================

When testing Basic or Digest Authentication, you can add the environment
variables that `PHP creates <https://php.net/manual/en/features.http-auth.php>`_
automatically.::

public function testGet()
{
$this->configRequest([
'environment' => [
'PHP_AUTH_USER' => 'username',
'PHP_AUTH_PW' => 'password',
]
]);
$this->get('/api/bookmarks');
$this->assertResponseOk();
}

0 comments on commit a178bf5

Please sign in to comment.