forked from apoloz/alfa-bank-sdk
65 lines
2.1 KiB
PHP
65 lines
2.1 KiB
PHP
<?php
|
|
|
|
use Apoloz\AlfaBank\Core\AlfaBankConnector;
|
|
use Apoloz\AlfaBank\Requests\CloudSignature\GetDnRequest;
|
|
use Apoloz\AlfaBank\Requests\CloudSignature\IssueRsaCertificateRequest;
|
|
use Apoloz\AlfaBank\Requests\CloudSignature\SubmitSigningRequest;
|
|
use Apoloz\AlfaBank\Requests\CloudSignature\ConfirmSigningWithSmsRequest;
|
|
use Saloon\Http\Faking\MockResponse;
|
|
|
|
test('can get user dn', function () {
|
|
$mockClient = new \Saloon\Http\Faking\MockClient([
|
|
GetDnRequest::class => MockResponse::make(['dn' => 'CN=Test'], 200),
|
|
]);
|
|
|
|
$config = createTestConfig();
|
|
$connector = new AlfaBankConnector($config);
|
|
$connector->withMockClient($mockClient);
|
|
|
|
$response = $connector->send(new GetDnRequest());
|
|
|
|
expect($response->status())->toBe(200);
|
|
});
|
|
|
|
test('can request rsa certificate issue', function () {
|
|
$mockClient = new \Saloon\Http\Faking\MockClient([
|
|
IssueRsaCertificateRequest::class => MockResponse::make(['id' => 'ISSUE-1'], 200),
|
|
]);
|
|
|
|
$config = createTestConfig();
|
|
$connector = new AlfaBankConnector($config);
|
|
$connector->withMockClient($mockClient);
|
|
|
|
$response = $connector->send(new IssueRsaCertificateRequest(tokenSerialNumber: '123'));
|
|
|
|
expect($response->status())->toBe(200);
|
|
});
|
|
|
|
test('can submit signing request', function () {
|
|
$mockClient = new \Saloon\Http\Faking\MockClient([
|
|
SubmitSigningRequest::class => MockResponse::make(['operationId' => 'OP-1'], 200),
|
|
]);
|
|
|
|
$config = createTestConfig();
|
|
$connector = new AlfaBankConnector($config);
|
|
$connector->withMockClient($mockClient);
|
|
|
|
$response = $connector->send(new SubmitSigningRequest('REQ-1'));
|
|
|
|
expect($response->status())->toBe(200);
|
|
});
|
|
|
|
test('can confirm signing with sms', function () {
|
|
$mockClient = new \Saloon\Http\Faking\MockClient([
|
|
ConfirmSigningWithSmsRequest::class => MockResponse::make([], 200),
|
|
]);
|
|
|
|
$config = createTestConfig();
|
|
$connector = new AlfaBankConnector($config);
|
|
$connector->withMockClient($mockClient);
|
|
|
|
$response = $connector->send(new ConfirmSigningWithSmsRequest('OP-1', '123456'));
|
|
|
|
expect($response->status())->toBe(200);
|
|
});
|