verschoof /
bunq-api
This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
| 1 | <?php |
||
| 2 | |||
| 3 | namespace Bunq\Tests; |
||
| 4 | |||
| 5 | use Bunq\Certificate\CertificateType; |
||
| 6 | use Bunq\Certificate\DefaultCertificate; |
||
| 7 | use Bunq\Certificate\Storage\CertificateStorage; |
||
| 8 | use Bunq\HttpClientFactory; |
||
| 9 | use Bunq\Middleware\RefreshSessionMiddleware; |
||
| 10 | use Bunq\Middleware\RequestAuthenticationMiddleware; |
||
| 11 | use Bunq\Middleware\RequestIdMiddleware; |
||
| 12 | use Bunq\Middleware\RequestSignatureMiddleware; |
||
| 13 | use Bunq\Middleware\ResponseSignatureMiddleware; |
||
| 14 | use Bunq\Service\InstallationService; |
||
| 15 | use Bunq\Service\TokenService; |
||
| 16 | use Bunq\Token\DefaultToken; |
||
| 17 | use Bunq\Token\Storage\TokenStorage; |
||
| 18 | use GuzzleHttp\HandlerStack; |
||
| 19 | use GuzzleHttp\Middleware; |
||
| 20 | use PHPUnit\Framework\TestCase; |
||
| 21 | use Prophecy\Prophecy\ObjectProphecy; |
||
| 22 | |||
| 23 | final class HttpClientFactoryTest extends TestCase |
||
| 24 | { |
||
| 25 | /** |
||
| 26 | * @test |
||
| 27 | */ |
||
| 28 | public function itCreatesAInstallationClient() |
||
| 29 | { |
||
| 30 | $baseUrl = 'uri'; |
||
| 31 | $privateCertificate = DefaultCertificate::fromString('private-certificate'); |
||
| 32 | |||
| 33 | /** @var CertificateStorage|ObjectProphecy $certificateStorage */ |
||
| 34 | $certificateStorage = $this->prophesize(CertificateStorage::class); |
||
| 35 | $certificateStorage->load(CertificateType::PRIVATE_KEY())->willReturn($privateCertificate); |
||
|
0 ignored issues
–
show
|
|||
| 36 | |||
| 37 | $client = HttpClientFactory::createInstallationClient($baseUrl, $certificateStorage->reveal()); |
||
|
0 ignored issues
–
show
The method
reveal does only exist in Prophecy\Prophecy\ObjectProphecy, but not in Bunq\Certificate\Storage\CertificateStorage.
It seems like the method you are trying to call exists only in some of the possible types. Let’s take a look at an example: class A
{
public function foo() { }
}
class B extends A
{
public function bar() { }
}
/**
* @param A|B $x
*/
function someFunction($x)
{
$x->foo(); // This call is fine as the method exists in A and B.
$x->bar(); // This method only exists in B and might cause an error.
}
Available Fixes
Loading history...
|
|||
| 38 | |||
| 39 | $expectedHandlerStack = HandlerStack::create(); |
||
| 40 | $expectedHandlerStack->push( |
||
| 41 | Middleware::mapRequest(new RequestIdMiddleware()) |
||
| 42 | ); |
||
| 43 | $expectedHandlerStack->push( |
||
| 44 | Middleware::mapRequest(new RequestSignatureMiddleware($privateCertificate)) |
||
| 45 | ); |
||
| 46 | |||
| 47 | $expectedClient = new \GuzzleHttp\Client( |
||
| 48 | [ |
||
| 49 | 'base_uri' => $baseUrl, |
||
| 50 | 'handler' => $expectedHandlerStack, |
||
| 51 | 'headers' => [ |
||
| 52 | 'Content-Type' => 'application/json', |
||
| 53 | 'User-Agent' => 'bunq-api-client:user', |
||
| 54 | ], |
||
| 55 | ] |
||
| 56 | ); |
||
| 57 | |||
| 58 | $this->assertEquals($expectedClient, $client); |
||
| 59 | } |
||
| 60 | |||
| 61 | /** |
||
| 62 | * @test |
||
| 63 | */ |
||
| 64 | public function itCreatesADefaultClient() |
||
| 65 | { |
||
| 66 | $baseUrl = 'uri'; |
||
| 67 | |||
| 68 | $privateCertificate = DefaultCertificate::fromString('private-certificate'); |
||
| 69 | $bunqCertificate = DefaultCertificate::fromString('bunq-certificate'); |
||
| 70 | /** @var CertificateStorage|ObjectProphecy $certificateStorage */ |
||
| 71 | $certificateStorage = $this->prophesize(CertificateStorage::class); |
||
| 72 | $certificateStorage->load(CertificateType::PRIVATE_KEY())->willReturn($privateCertificate); |
||
|
0 ignored issues
–
show
The method
load does only exist in Bunq\Certificate\Storage\CertificateStorage, but not in Prophecy\Prophecy\ObjectProphecy.
It seems like the method you are trying to call exists only in some of the possible types. Let’s take a look at an example: class A
{
public function foo() { }
}
class B extends A
{
public function bar() { }
}
/**
* @param A|B $x
*/
function someFunction($x)
{
$x->foo(); // This call is fine as the method exists in A and B.
$x->bar(); // This method only exists in B and might cause an error.
}
Available Fixes
Loading history...
|
|||
| 73 | $certificateStorage->load(CertificateType::BUNQ_SERVER_KEY())->willReturn($bunqCertificate); |
||
| 74 | |||
| 75 | $sessionToken = DefaultToken::fromString('session-token'); |
||
| 76 | /** @var TokenService|ObjectProphecy $tokenService */ |
||
| 77 | $tokenService = $this->prophesize(TokenService::class); |
||
| 78 | $tokenService->sessionToken()->willReturn($sessionToken); |
||
|
0 ignored issues
–
show
The method
sessionToken does only exist in Bunq\Service\TokenService, but not in Prophecy\Prophecy\ObjectProphecy.
It seems like the method you are trying to call exists only in some of the possible types. Let’s take a look at an example: class A
{
public function foo() { }
}
class B extends A
{
public function bar() { }
}
/**
* @param A|B $x
*/
function someFunction($x)
{
$x->foo(); // This call is fine as the method exists in A and B.
$x->bar(); // This method only exists in B and might cause an error.
}
Available Fixes
Loading history...
|
|||
| 79 | |||
| 80 | /** @var InstallationService|ObjectProphecy $installationService */ |
||
| 81 | $installationService = $this->prophesize(InstallationService::class); |
||
| 82 | |||
| 83 | /** @var TokenStorage|ObjectProphecy $tokenStorage */ |
||
| 84 | $tokenStorage = $this->prophesize(TokenStorage::class); |
||
| 85 | |||
| 86 | $client = HttpClientFactory::create( |
||
| 87 | $baseUrl, |
||
| 88 | $tokenService->reveal(), |
||
|
0 ignored issues
–
show
The method
reveal does only exist in Prophecy\Prophecy\ObjectProphecy, but not in Bunq\Service\TokenService.
It seems like the method you are trying to call exists only in some of the possible types. Let’s take a look at an example: class A
{
public function foo() { }
}
class B extends A
{
public function bar() { }
}
/**
* @param A|B $x
*/
function someFunction($x)
{
$x->foo(); // This call is fine as the method exists in A and B.
$x->bar(); // This method only exists in B and might cause an error.
}
Available Fixes
Loading history...
|
|||
| 89 | $certificateStorage->reveal(), |
||
|
0 ignored issues
–
show
The method
reveal does only exist in Prophecy\Prophecy\ObjectProphecy, but not in Bunq\Certificate\Storage\CertificateStorage.
It seems like the method you are trying to call exists only in some of the possible types. Let’s take a look at an example: class A
{
public function foo() { }
}
class B extends A
{
public function bar() { }
}
/**
* @param A|B $x
*/
function someFunction($x)
{
$x->foo(); // This call is fine as the method exists in A and B.
$x->bar(); // This method only exists in B and might cause an error.
}
Available Fixes
Loading history...
|
|||
| 90 | $installationService->reveal(), |
||
|
0 ignored issues
–
show
The method
reveal does only exist in Prophecy\Prophecy\ObjectProphecy, but not in Bunq\Service\InstallationService.
It seems like the method you are trying to call exists only in some of the possible types. Let’s take a look at an example: class A
{
public function foo() { }
}
class B extends A
{
public function bar() { }
}
/**
* @param A|B $x
*/
function someFunction($x)
{
$x->foo(); // This call is fine as the method exists in A and B.
$x->bar(); // This method only exists in B and might cause an error.
}
Available Fixes
Loading history...
|
|||
| 91 | $tokenStorage->reveal() |
||
|
0 ignored issues
–
show
The method
reveal does only exist in Prophecy\Prophecy\ObjectProphecy, but not in Bunq\Token\Storage\TokenStorage.
It seems like the method you are trying to call exists only in some of the possible types. Let’s take a look at an example: class A
{
public function foo() { }
}
class B extends A
{
public function bar() { }
}
/**
* @param A|B $x
*/
function someFunction($x)
{
$x->foo(); // This call is fine as the method exists in A and B.
$x->bar(); // This method only exists in B and might cause an error.
}
Available Fixes
Loading history...
|
|||
| 92 | ); |
||
| 93 | |||
| 94 | $expectedHandlerStack = HandlerStack::create(); |
||
| 95 | $expectedHandlerStack->push( |
||
| 96 | Middleware::mapRequest(new RequestIdMiddleware()) |
||
| 97 | ); |
||
| 98 | $expectedHandlerStack->push( |
||
| 99 | Middleware::mapRequest(new RequestAuthenticationMiddleware($sessionToken)) |
||
| 100 | ); |
||
| 101 | $expectedHandlerStack->push( |
||
| 102 | Middleware::mapRequest(new RequestSignatureMiddleware($bunqCertificate)) |
||
| 103 | ); |
||
| 104 | $expectedHandlerStack->push( |
||
| 105 | Middleware::mapResponse(new ResponseSignatureMiddleware($bunqCertificate)) |
||
| 106 | ); |
||
| 107 | $expectedHandlerStack->push( |
||
| 108 | Middleware::mapResponse(new RefreshSessionMiddleware($installationService->reveal(), $tokenStorage->reveal())) |
||
| 109 | ); |
||
| 110 | |||
| 111 | $expectedClient = new \GuzzleHttp\Client( |
||
| 112 | [ |
||
| 113 | 'base_uri' => $baseUrl, |
||
| 114 | 'handler' => $expectedHandlerStack, |
||
| 115 | 'headers' => [ |
||
| 116 | 'Content-Type' => 'application/json', |
||
| 117 | 'User-Agent' => 'bunq-api-client:user', |
||
| 118 | ], |
||
| 119 | ] |
||
| 120 | ); |
||
| 121 | |||
| 122 | $this->assertEquals($expectedClient, $client); |
||
| 123 | } |
||
| 124 | } |
||
| 125 | |||
| 126 |
It seems like the method you are trying to call exists only in some of the possible types.
Let’s take a look at an example:
Available Fixes
Add an additional type-check:
Only allow a single type to be passed if the variable comes from a parameter: