Skip to content

Commit

Permalink
minor #30564 [HttpClient] Fix HttpOptions::setAuthBearer() (dunglas)
Browse files Browse the repository at this point in the history
This PR was merged into the 4.3-dev branch.

Discussion
----------

[HttpClient] Fix HttpOptions::setAuthBearer()

| Q             | A
| ------------- | ---
| Branch?       | master <!-- see below -->
| Bug fix?      | yes
| New feature?  | no <!-- don't forget to update src/**/CHANGELOG.md files -->
| BC breaks?    | no     <!-- see https://symfony.com/bc -->
| Deprecations? | no <!-- don't forget to update UPGRADE-*.md and src/**/CHANGELOG.md files -->
| Tests pass?   | yes    <!-- please add some, will be required by reviewers -->
| Fixed tickets | n/a   <!-- #-prefixed issue number(s), if any -->
| License       | MIT
| Doc PR        | n/a

I messed up the option name while rebasing...

Commits
-------

7308e5a [HttpClient] Fix HttpOptions::setAuthBearer()
  • Loading branch information
nicolas-grekas committed Mar 14, 2019
2 parents 8af6395 + 7308e5a commit 59e6380
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/Symfony/Component/HttpClient/HttpOptions.php
Expand Up @@ -49,7 +49,7 @@ public function setAuthBasic(string $user, string $password = '')
*/
public function setAuthBearer(string $token)
{
$this->options['bearer'] = $token;
$this->options['auth_bearer'] = $token;

return $this;
}
Expand Down
11 changes: 8 additions & 3 deletions src/Symfony/Component/HttpClient/Tests/HttpOptionsTest.php
Expand Up @@ -19,7 +19,7 @@
*/
class HttpOptionsTest extends TestCase
{
public function provideSetAuth()
public function provideSetAuthBasic()
{
yield ['user:password', 'user', 'password'];
yield ['user:password', 'user:password'];
Expand All @@ -28,10 +28,15 @@ public function provideSetAuth()
}

/**
* @dataProvider provideSetAuth
* @dataProvider provideSetAuthBasic
*/
public function testSetAuth(string $expected, string $user, string $password = '')
public function testSetAuthBasic(string $expected, string $user, string $password = '')
{
$this->assertSame($expected, (new HttpOptions())->setAuthBasic($user, $password)->toArray()['auth_basic']);
}

public function testSetAuthBearer()
{
$this->assertSame('foobar', (new HttpOptions())->setAuthBearer('foobar')->toArray()['auth_bearer']);
}
}

0 comments on commit 59e6380

Please sign in to comment.