HttpTestTrait - Allow one to easily add Authx JWTs to each request
authorTim Otten <totten@civicrm.org>
Wed, 25 Aug 2021 00:08:19 +0000 (17:08 -0700)
committerTim Otten <totten@civicrm.org>
Thu, 26 Aug 2021 04:31:00 +0000 (21:31 -0700)
commitee4d3a2dbfa8fa1a7705d9a27e8bb735fb8439f1
tree40d3c1f3422f7f3584e3c368a517ed5374909d56
parentcefafd639cbe38471edda567f015895988925064
HttpTestTrait - Allow one to easily add Authx JWTs to each request

```php
// Add JWT credentials to every Guzzle request
$http = $this->createGuzzle([
  'authx_user' => 'admin',
]);
$response = $http->get('route://civicrm/dashboard');

// Add JWT credentials to a single request
$http = $this->createGuzzle();
$response = $http->get('route://civicrm/dashboard', [
  'authx_user' => 'demo',
]);

// Perform a stateful login via JWT
$http = $this->createGuzzle(['cookies' => new CookieJar()]);
$response = $http->get('route://civicrm/authx/login', [
  'authx_contact_id' => 100,
]);
```
CRM/Utils/GuzzleMiddleware.php
Civi/Test/HttpTestTrait.php
ext/authx/tests/phpunit/Civi/Authx/AllFlowsTest.php