-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add schedule to CI, fix and improve tests after library refresh
- Loading branch information
1 parent
8f3d64a
commit 9a991c5
Showing
8 changed files
with
88 additions
and
31 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 |
---|---|---|
|
@@ -62,6 +62,12 @@ protected function createApplicant(): Onfido\Model\Applicant | |
]), | ||
'email' => '[email protected]', | ||
'phone_number' => '351911111111', | ||
'consents' => [ | ||
new Onfido\Model\ApplicantConsentBuilder([ | ||
'name' => Onfido\Model\ApplicantConsentName::PRIVACY_NOTICES_READ, | ||
'granted' => true | ||
]) | ||
] | ||
] | ||
), | ||
); | ||
|
@@ -106,7 +112,7 @@ protected static function cleanUpWebhooks(): void | |
protected function uploadDocument(string $applicantId): Onfido\Model\Document | ||
{ | ||
return self::$onfido->uploadDocument( | ||
'passport', | ||
Onfido\Model\DocumentTypes::PASSPORT, | ||
$applicantId, | ||
new \SplFileObject('test/media/sample_driving_licence.png') | ||
); | ||
|
@@ -220,6 +226,7 @@ protected function repeatRequestUntilHttpCodeChanges( | |
$sleepTime = 1 | ||
) | ||
{ | ||
$instance = null; | ||
$iteration = 0; | ||
while($iteration <= $maxRetries) { | ||
try { | ||
|
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
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,57 @@ | ||
<?php | ||
|
||
namespace Onfido\Test; | ||
|
||
use PHPUnit\Framework\TestCase; | ||
|
||
use Onfido as Onfido; | ||
|
||
class StudioWebhookEventVerifierTest extends TestCase | ||
{ | ||
private static $rawEvent = "{\"payload\":{\"resource_type\":\"workflow_task\",\"action\":\"workflow_task.started\",\"object\":{\"id\":\"profile_1eb92\",\"task_spec_id\":\"profile_1eb92\",\"task_def_id\":\"profile_data\",\"workflow_run_id\":\"bc77c6e5-753a-4580-96a6-aaed3e5a8d19\",\"status\":\"started\",\"started_at_iso8601\":\"2024-07-10T12:49:09Z\",\"href\":\"https://api.eu.onfido.com/v3.6/workflow_runs/bc77c6e5-753a-4580-96a6-aaed3e5a8d19/tasks/profile_1eb92\"},\"resource\":{\"created_at\":\"2024-07-10T12:49:09Z\",\"id\":\"profile_1eb92\",\"workflow_run_id\":\"bc77c6e5-753a-4580-96a6-aaed3e5a8d19\",\"updated_at\":\"2024-07-10T12:49:09Z\",\"input\":{},\"task_def_version\":null,\"task_def_id\":\"profile_data\",\"output\":null}}}"; | ||
private static $webhookToken = "YKOC6mkBxi6yK2zlUIrLMvsJMFEZObP5"; | ||
|
||
private static $webhookEventVerifier; | ||
|
||
/** | ||
* Setup before running any test case | ||
*/ | ||
public static function setUpBeforeClass(): void | ||
{ | ||
self::$webhookEventVerifier = new Onfido\WebhookEventVerifier(self::$webhookToken); | ||
} | ||
|
||
public function testValidSignature(): void | ||
{ | ||
$signature = "c95a5b785484f6fa1bc25f381b5595d66bf85cb442eefb06aa007802ee6a4dfa"; | ||
|
||
$event = self::$webhookEventVerifier->readPayload(self::$rawEvent, $signature); | ||
$payload = $event->getPayload(); | ||
$object = $payload->getObject(); | ||
|
||
$this->assertSame(Onfido\Model\WebhookEventType::WORKFLOW_TASK_STARTED, $payload->getAction()); | ||
$this->assertSame(Onfido\Model\WebhookEventResourceType::WORKFLOW_TASK, $payload->getResourceType()); | ||
$this->assertSame('profile_1eb92', $object->getId()); | ||
$this->assertSame('https://api.eu.onfido.com/v3.6/workflow_runs/bc77c6e5-753a-4580-96a6-aaed3e5a8d19/tasks/profile_1eb92', $object->getHref()); | ||
$this->assertSame(Onfido\Model\WebhookEventObjectStatus::STARTED, $object->getStatus()); | ||
$this->assertSame('2024-07-10T12:49:09+00:00', $object->getStartedAtIso8601()->format('c')); | ||
|
||
$resource = $payload->getResource(); | ||
$this->assertSame('2024-07-10T12:49:09+00:00', $resource->getCreatedAt()->format('c')); | ||
$this->assertSame('profile_1eb92', $resource->getId()); | ||
$this->assertSame([], $resource->getInput()); | ||
$this->assertSame(null, $resource->getOutput()); | ||
$this->assertSame('profile_data', $resource->getTaskDefId()); | ||
$this->assertSame(null, $resource->getTaskDefVersion()); | ||
$this->assertSame('2024-07-10T12:49:09+00:00', $resource->getUpdatedAt()->format('c')); | ||
$this->assertSame('bc77c6e5-753a-4580-96a6-aaed3e5a8d19', $resource->getWorkflowRunId()); | ||
} | ||
|
||
public function testInvalidSignature() | ||
{ | ||
$signature = "c95a5b785484f6fa1bc25f381b5595d66bf85cb442eefb06aa007802ee6a4dfb"; | ||
|
||
$this->expectException(Onfido\OnfidoInvalidSignatureError::class); | ||
$event = self::$webhookEventVerifier->readPayload(self::$rawEvent, $signature); | ||
} | ||
} |