Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: include guzzle configuration when additionalConfigKeys is defined in provider #227

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/Helpers/ConfigRetriever.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ public function fromServices($providerName, array $additionalConfigKeys = [])
$this->providerName = $providerName;
$this->getConfigFromServicesArray($providerName);

$this->additionalConfigKeys = $additionalConfigKeys = array_unique($additionalConfigKeys + ['guzzle']);
$this->additionalConfigKeys = $additionalConfigKeys = array_unique(
array_merge($additionalConfigKeys, ['guzzle']),
);

return new Config(
$this->getFromServices('client_id'),
Expand Down
33 changes: 33 additions & 0 deletions tests/ConfigRetrieverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,39 @@ public function it_retrieves_a_config_from_the_services(): void
$this->assertSame($uri, $result['redirect']);
$this->assertSame($additionalConfigItem, $result['additional']);
}

/**
* @test
*/
public function it_retrieves_a_config_from_the_services_with_guzzle(): void
{
$providerName = 'test';
$key = 'key';
$secret = 'secret';
$uri = 'uri';
$additionalConfigItem = 'test';
$config = [
'client_id' => $key,
'client_secret' => $secret,
'redirect' => $uri,
'additional' => $additionalConfigItem,
'guzzle' => ['verify' => false],
];
self::$functions
->shouldReceive('config')
->with("services.{$providerName}")
->once()
->andReturn($config);
$configRetriever = new ConfigRetriever();

$result = $configRetriever->fromServices($providerName, ['additional'])->get();

$this->assertSame($key, $result['client_id']);
$this->assertSame($secret, $result['client_secret']);
$this->assertSame($uri, $result['redirect']);
$this->assertSame($additionalConfigItem, $result['additional']);
$this->assertSame(['verify' => false], $result['guzzle']);
}
}

namespace SocialiteProviders\Manager\Helpers;
Expand Down
Loading