Skip to content

Commit

Permalink
DDBTEAM-538: Added test for multiple allowed client id's
Browse files Browse the repository at this point in the history
  • Loading branch information
turegjorup committed Jun 26, 2020
1 parent 7100676 commit df50eab
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/Security/TokenAuthenticator.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ public function __construct(string $openplatformId, string $openplatformSecret,
$this->clientId = $openplatformId;
$this->clientSecret = $openplatformSecret;
$this->endPoint = $openplatformIntrospectionUrl;
$this->allowedClients = empty($openplatformAllowedClients) ? [] : explode(',', $openplatformAllowedClients);

$this->allowedClients = empty($openplatformAllowedClients) ? [] : array_map('trim', explode(',', $openplatformAllowedClients));

$this->client = $httpClient;
$this->cache = $tokenCache;
Expand Down
4 changes: 2 additions & 2 deletions tests/TokenAuthenticatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -287,14 +287,14 @@ public function testActiveUSerAllowed(): void
*/
public function testCachedTokensClientIsAllowed(): void
{
$this->tokenAuthenticator = $this->getTokenAuthenticator('allowed-client-id');
$this->tokenAuthenticator = $this->getTokenAuthenticator('allowed-client-id-1, allowed-client-id-2, allowed-client-id-3');

$this->cache->method('getItem')->willReturn($this->item);
$this->cache->expects($this->once())->method('getItem')->with('12345678');

$this->item->method('isHit')->willReturn(true);
$user = new User();
$user->setClientId('allowed-client-id');
$user->setClientId('allowed-client-id-2');
$expires = new \DateTime('now + 2 days', new \DateTimeZone('UTC'));
$user->setExpires($expires);
$this->item->method('get')->willReturn($user);
Expand Down

0 comments on commit df50eab

Please sign in to comment.