Skip to content

Commit

Permalink
Move NI and Verify to Basic (#529)
Browse files Browse the repository at this point in the history
  • Loading branch information
SecondeJK authored Jan 9, 2025
1 parent 97c41bd commit 911bed0
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 7 deletions.
3 changes: 2 additions & 1 deletion src/Insights/ClientFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

use Psr\Container\ContainerInterface;
use Vonage\Client\APIResource;
use Vonage\Client\Credentials\Handler\BasicHandler;
use Vonage\Client\Credentials\Handler\BasicQueryHandler;

class ClientFactory
Expand All @@ -15,7 +16,7 @@ public function __invoke(ContainerInterface $container): Client
/** @var APIResource $api */
$api = $container->make(APIResource::class);
$api->setIsHAL(false);
$api->setAuthHandlers(new BasicQueryHandler());
$api->setAuthHandlers(new BasicHandler());

return new Client($api);
}
Expand Down
3 changes: 2 additions & 1 deletion src/Verify/ClientFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

use Psr\Container\ContainerInterface;
use Vonage\Client\APIResource;
use Vonage\Client\Credentials\Handler\BasicHandler;
use Vonage\Client\Credentials\Handler\TokenBodyHandler;

class ClientFactory
Expand All @@ -18,7 +19,7 @@ public function __invoke(ContainerInterface $container): Client
->setIsHAL(false)
->setBaseUri('/verify')
->setErrorsOn200(true)
->setAuthHandlers(new TokenBodyHandler())
->setAuthHandlers(new BasicHandler())
->setExceptionErrorHandler(new ExceptionErrorHandler());

return new Client($api);
Expand Down
1 change: 1 addition & 0 deletions test/Insights/ClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ public function setUp(): void
$this->api = new APIResource();
$this->api->setIsHAL(false);
$this->api->setClient($this->vonageClient->reveal());
$this->api->setAuthHandlers(new Client\Credentials\Handler\BasicHandler());

$this->insightsClient = new InsightsClient($this->api);
}
Expand Down
11 changes: 6 additions & 5 deletions test/Verify/ClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,22 +51,23 @@ public function setUp(): void
->setIsHAL(false)
->setBaseUri('/verify')
->setErrorsOn200(true)
->setAuthHandlers(new Client\Credentials\Handler\TokenBodyHandler())
->setAuthHandlers(new Client\Credentials\Handler\BasicHandler())
->setClient($this->vonageClient->reveal())
->setExceptionErrorHandler(new ExceptionErrorHandler());

$this->client = new VerifyClient($api);
}

public function testUsesCorrectAuthInBody(): void
public function testUsesCorrectAuth(): void
{
$this->vonageClient->send(
Argument::that(
function (RequestInterface $request) {
$this->assertRequestJsonBodyContains('api_key', 'abc', $request);
$this->assertRequestJsonBodyContains('api_secret', 'def', $request);
$this->assertRequestMatchesUrl('https://api.nexmo.com/verify/psd2/json', $request);

$this->assertEquals(
'Basic ',
mb_substr($request->getHeaders()['Authorization'][0], 0, 6)
);
return true;
}
)
Expand Down

0 comments on commit 911bed0

Please sign in to comment.