-
Notifications
You must be signed in to change notification settings - Fork 181
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
106 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace VonageTest\Verify2\Request; | ||
|
||
use PHPUnit\Framework\TestCase; | ||
use Vonage\Client; | ||
use Vonage\Verify2\Request\BaseVerifyRequest; | ||
use Vonage\Verify2\Request\SilentAuthRequest; | ||
use Vonage\Verify2\Request\SMSRequest; | ||
use Vonage\Verify2\VerifyObjects\VerificationLocale; | ||
use Vonage\Verify2\VerifyObjects\VerificationWorkflow; | ||
|
||
class SilentAuthRequestTest extends TestCase | ||
{ | ||
public function testIsValidSilentAuthRequest(): void | ||
{ | ||
$silentAuthRequest = new SilentAuthRequest( | ||
'077377775555', | ||
'VONAGE', | ||
'https://silent-auth.example' | ||
); | ||
|
||
$extraWorkflow = new VerificationWorkflow( | ||
VerificationWorkflow::WORKFLOW_SMS, | ||
'077377775555' | ||
); | ||
|
||
$silentAuthRequest->addWorkflow($extraWorkflow); | ||
|
||
$client = new Client(new Client\Credentials\Basic('test', 'test2')); | ||
$this->assertTrue($client->verify2()::isSilentAuthRequest($silentAuthRequest)); | ||
$this->assertTrue(SilentAuthRequest::isValidWorkflow($silentAuthRequest->getWorkflows())); | ||
} | ||
|
||
public function testIsInvalidSilentAuthRequest(): void | ||
{ | ||
$request = new SMSRequest( | ||
'077377775555', | ||
'VONAGE', | ||
); | ||
|
||
$extraWorkflow = new VerificationWorkflow( | ||
VerificationWorkflow::WORKFLOW_SILENT_AUTH, | ||
'077377775555' | ||
); | ||
|
||
$request->addWorkflow($extraWorkflow); | ||
$client = new Client(new Client\Credentials\Basic('test', 'test2')); | ||
|
||
$this->assertTrue($client->verify2()::isSilentAuthRequest($request)); | ||
$this->assertFalse(SilentAuthRequest::isValidWorkflow($request->getWorkflows())); | ||
} | ||
|
||
public function testIsNotSilentAuthRequest(): void | ||
{ | ||
$request = new SMSRequest( | ||
'077377775555', | ||
'VONAGE', | ||
); | ||
|
||
$extraWorkflow = new VerificationWorkflow( | ||
VerificationWorkflow::WORKFLOW_EMAIL, | ||
'[email protected]' | ||
); | ||
|
||
$request->addWorkflow($extraWorkflow); | ||
$client = new Client(new Client\Credentials\Basic('test', 'test2')); | ||
|
||
$this->assertFalse($client->verify2()::isSilentAuthRequest($request)); | ||
// No second test to see if the workflow is valid, why are you checking a workflow on a non SA request? | ||
} | ||
} |