|
@@ 36-60 (lines=25) @@
|
| 33 |
|
/** |
| 34 |
|
* @test |
| 35 |
|
*/ |
| 36 |
|
public function itValidatesSignature() |
| 37 |
|
{ |
| 38 |
|
$headers = [ |
| 39 |
|
'Date' => 'Sat, 20 May 2017 10:40:41 GMT', |
| 40 |
|
'Server' => 'Apache', |
| 41 |
|
'Access-Control-Allow-Origin' => '*', |
| 42 |
|
'Cache-Control' => 'max-age=31536000', |
| 43 |
|
'X-Bunq-Client-Response-Id' => 'd93e60ce-8de7-4c8c-b911-9614e63ef1db', |
| 44 |
|
'X-Bunq-Client-Request-Id' => '7c54ccde-89ab-4546-ad91-c6af28ed535a', |
| 45 |
|
'X-Bunq-Server-Signature' => 'YfMLJ/Rh1n46epfA/qY9dG5dwWk2sIY2W+ceSOR0yH17ifX9Ppx7KtSSgng3NNXdQksBN0LMa2N2BU/uN6fONP+p3K7YpAOV6nGJfF4DqIi4jcL6OpngLLSNG1EX5PJx3FsFHhr7fwp0Bn0pJcgiJqFW6sea9ChoZsMpCUaeCC4jU2MM4LooQM8yBOUYg70+LLlzHhj3C1GhiEzDnw1aEaLDpRGdMK2JeCi0XuAAwB+JvT7TaOwjSvdgT4dHJY8Vo55A3cTpi8niIqQlaUy37DxPmHbSFW9gbki9tUn0+zmT6xJhZutzCGa/W/bqnGSMtsOnybbBFsabiGHOOlBb8g==', |
| 46 |
|
'X-Frame-Options' => 'SAMEORIGIN', |
| 47 |
|
'ETag' => '94930c03a34cd0b94ac1361bcc9f8a7163df238c599eb2ba9163afde1ef229f7', |
| 48 |
|
'Transfer-Encoding' => 'chunked', |
| 49 |
|
'Content-Type' => 'application/json', |
| 50 |
|
'Strict-Transport-Security' => 'max-age=31536000;', |
| 51 |
|
]; |
| 52 |
|
|
| 53 |
|
$body = '{"Response":[{"Payment":{"id":17495,"created":"2017-04-17 11:01:15.347501","updated":"2017-04-17 11:01:15.347501","monetary_account_id":2030,"amount":{"currency":"EUR","value":"-11.05"},"description":"invoice 1629","type":"BUNQ","merchant_reference":null,"alias":{"iban":"NL37BUNQ9900020189","is_light":false,"display_name":"Linville Co\u00f6peratie","avatar":{"uuid":"465f0bb5-b103-4c0d-ba97-a91b37b7f405","image":[{"attachment_public_uuid":"26031605-c8e9-462a-8117-6edeb61f5d7c","height":1024,"width":1024,"content_type":"image\/png"}],"anchor_uuid":null},"label_user":{"uuid":"79963d66-1561-48a8-8233-a89e4a46a9d3","display_name":"Linville Co\u00f6peratie","country":"NL","avatar":{"uuid":"646d3802-881e-415c-96f9-35397ce7cc9a","image":[{"attachment_public_uuid":"0d10b1c4-b249-4c49-a442-5379bae0a030","height":640,"width":640,"content_type":"image\/png"}],"anchor_uuid":"79963d66-1561-48a8-8233-a89e4a46a9d3"},"public_nick_name":"Linville Co\u00f6peratie"},"country":"NL"},"counterparty_alias":{"iban":"NL37BUNQ9900000013","is_light":false,"display_name":"Catrice (nickname)","avatar":{"uuid":"0f56a33b-a451-48b4-8d4a-3d8a34c15fa1","image":[{"attachment_public_uuid":"5c598364-ab1b-42d7-9a79-91f872f333c1","height":1024,"width":1024,"content_type":"image\/png"}],"anchor_uuid":null},"label_user":{"uuid":"8de50b32-8b97-481f-85a7-aa4e751803f2","display_name":"Catrice (nickname)","country":"NL","avatar":{"uuid":"3552dc00-b8b8-4edc-9163-515647c75d4a","image":[{"attachment_public_uuid":"eca34771-55cc-42c3-b7b4-8f1a978b6624","height":480,"width":480,"content_type":"image\/jpeg"}],"anchor_uuid":"8de50b32-8b97-481f-85a7-aa4e751803f2"},"public_nick_name":"Catrice (nickname)"},"country":"NL"},"attachment":[],"geolocation":null,"batch_id":null,"allow_chat":true,"scheduled_id":null,"address_billing":null,"address_shipping":null}}]}'; |
| 54 |
|
|
| 55 |
|
$response = new Response(200, $headers, $body); |
| 56 |
|
|
| 57 |
|
$result = $this->middleware->__invoke($response); |
| 58 |
|
|
| 59 |
|
$this->assertEquals($response, $result); |
| 60 |
|
} |
| 61 |
|
|
| 62 |
|
/** |
| 63 |
|
* @test |
|
@@ 67-91 (lines=25) @@
|
| 64 |
|
* @expectedException \Exception |
| 65 |
|
* @expectedExceptionMessage Server signature does not match response |
| 66 |
|
*/ |
| 67 |
|
public function itThrowsAnExpectionWhenSignatureDoesNotMatch() |
| 68 |
|
{ |
| 69 |
|
$headers = [ |
| 70 |
|
'Date' => 'Sat, 20 May 2017 10:40:41 GMT', |
| 71 |
|
'Server' => 'Apache', |
| 72 |
|
'Access-Control-Allow-Origin' => '*', |
| 73 |
|
'Cache-Control' => 'max-age=31536000', |
| 74 |
|
'X-Bunq-Client-Response-Id' => 'd93e60ce-8de7-4c8c-b911-9614e63ef1db', |
| 75 |
|
'X-Bunq-Client-Request-Id' => '7c54ccde-89ab-4546-ad91-c6af28ed535a', |
| 76 |
|
'X-Bunq-Server-Signature' => 'YfMLJ/Rh1n46epfA/qY9dG5dwWk2sIY2W+ceSOR0yH17ifX9Ppx7KtSSgng3NNXdQksBN0LMa2N2BU/uN6fONP+p3K7YpAOV6nGJfF4DqIi4jcL6OpngLLSNG1EX5PJx3FsFHhr7fwp0Bn0pJcgiJqFW6sea9ChoZsMpCUaeCC4jU2MM4LooQM8yBOUYg70+LLlzHhj3C1GhiEzDnw1aEaLDpRGdMK2JeCi0XuAAwB+JvT7TaOwjSvdgT4dHJY8Vo55A3cTpi8niIqQlaUy37DxPmHbSFW9gbki9tUn0+zmT6xJhZutzCGa/W/bqnGSMtsOnybbBFsabiGHOOlBb8g==', |
| 77 |
|
'X-Frame-Options' => 'SAMEORIGIN', |
| 78 |
|
'ETag' => '94930c03a34cd0b94ac1361bcc9f8a7163df238c599eb2ba9163afde1ef229f7', |
| 79 |
|
'Transfer-Encoding' => 'chunked', |
| 80 |
|
'Content-Type' => 'application/json', |
| 81 |
|
'Strict-Transport-Security' => 'max-age=31536000;', |
| 82 |
|
]; |
| 83 |
|
|
| 84 |
|
$body = '{"Response":[{"Payment":{"id":17495,"created":"2017-04-17 11:01:15.347501","updated":"2017-04-17 11:01:15.347501","monetary_account_id":2030,"amount":{"currency":"EUR","value":"-11.05"},"description":"invoice 1629","type":"BUNQ","merchant_reference":null,"alias":{"iban":"NL37BUNQ9900020189","is_light":false,"display_name":"Man in the middle attack!","avatar":{"uuid":"465f0bb5-b103-4c0d-ba97-a91b37b7f405","image":[{"attachment_public_uuid":"26031605-c8e9-462a-8117-6edeb61f5d7c","height":1024,"width":1024,"content_type":"image\/png"}],"anchor_uuid":null},"label_user":{"uuid":"79963d66-1561-48a8-8233-a89e4a46a9d3","display_name":"Linville Co\u00f6peratie","country":"NL","avatar":{"uuid":"646d3802-881e-415c-96f9-35397ce7cc9a","image":[{"attachment_public_uuid":"0d10b1c4-b249-4c49-a442-5379bae0a030","height":640,"width":640,"content_type":"image\/png"}],"anchor_uuid":"79963d66-1561-48a8-8233-a89e4a46a9d3"},"public_nick_name":"Linville Co\u00f6peratie"},"country":"NL"},"counterparty_alias":{"iban":"NL37BUNQ9900000013","is_light":false,"display_name":"Catrice (nickname)","avatar":{"uuid":"0f56a33b-a451-48b4-8d4a-3d8a34c15fa1","image":[{"attachment_public_uuid":"5c598364-ab1b-42d7-9a79-91f872f333c1","height":1024,"width":1024,"content_type":"image\/png"}],"anchor_uuid":null},"label_user":{"uuid":"8de50b32-8b97-481f-85a7-aa4e751803f2","display_name":"Catrice (nickname)","country":"NL","avatar":{"uuid":"3552dc00-b8b8-4edc-9163-515647c75d4a","image":[{"attachment_public_uuid":"eca34771-55cc-42c3-b7b4-8f1a978b6624","height":480,"width":480,"content_type":"image\/jpeg"}],"anchor_uuid":"8de50b32-8b97-481f-85a7-aa4e751803f2"},"public_nick_name":"Catrice (nickname)"},"country":"NL"},"attachment":[],"geolocation":null,"batch_id":null,"allow_chat":true,"scheduled_id":null,"address_billing":null,"address_shipping":null}}]}'; |
| 85 |
|
|
| 86 |
|
$response = new Response(200, $headers, $body); |
| 87 |
|
|
| 88 |
|
$result = $this->middleware->__invoke($response); |
| 89 |
|
|
| 90 |
|
$this->assertEquals($response, $result); |
| 91 |
|
} |
| 92 |
|
} |
| 93 |
|
|
| 94 |
|
|