Skip to content

Commit

Permalink
Set user agent string (#140)
Browse files Browse the repository at this point in the history
* Set user agent string

* this won't work

* fix mock

* Fixed test
  • Loading branch information
danepowell authored Jun 10, 2020
1 parent 77426ad commit 71cff36
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/Command/Api/ApiCommandBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ class ApiCommandBase extends CommandBase {
* @param \Symfony\Component\Console\Output\OutputInterface $output
*
* @throws \Acquia\Cli\Exception\AcquiaCliException
* @throws \Exception
*/
protected function initialize(InputInterface $input, OutputInterface $output) {
parent::initialize($input, $output);
Expand Down Expand Up @@ -87,6 +88,8 @@ protected function execute(InputInterface $input, OutputInterface $output) {
}

$path = $this->getRequestPath($input);
$user_agent = sprintf("acli/%s", $this->getApplication()->getVersion());
$acquia_cloud_client->addOption('headers', ['User-Agent' => $user_agent]);
$response = $acquia_cloud_client->request($this->method, $path);
// @todo Add syntax highlighting to json output.
$contents = json_encode($response, JSON_PRETTY_PRINT);
Expand Down
1 change: 1 addition & 0 deletions tests/phpunit/src/TestBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ protected function setUp($output = NULL): void {
$this->cloudDatastore = new JsonFileStore($this->cloudConfigFilepath, 1);
$this->amplitudeProphecy = $this->prophet->prophesize(Amplitude::class);
$this->clientProphecy = $this->prophet->prophesize(Client::class);
$this->clientProphecy->addOption('headers', ['User-Agent' => 'acli/UNKNOWN'])->willReturn();
$this->localMachineHelper = new LocalMachineHelper($this->input, $output, $logger);
$this->clientServiceProphecy = $this->prophet->prophesize(ClientService::class);
$this->clientServiceProphecy->getClient()->willReturn($this->clientProphecy->reveal());
Expand Down

0 comments on commit 71cff36

Please sign in to comment.