Skip to content

Commit fab7978

Browse files
committed
fix stream tests
1 parent b43a5eb commit fab7978

File tree

3 files changed

+17
-13
lines changed

3 files changed

+17
-13
lines changed

src/Parse/HttpClients/ParseStreamHttpClient.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ class ParseStreamHttpClient implements ParseHttpable
8383
*
8484
* @var array
8585
*/
86-
private static $httpOptions;
86+
private $httpOptions;
8787

8888
/**
8989
* Optional timeout for this request
@@ -203,7 +203,7 @@ public function send($url, $method = 'GET', $data = array())
203203
}
204204

205205
if (isset($this->httpOptions)) {
206-
foreach ($data as $key => $value) {
206+
foreach ($this->httpOptions as $key => $value) {
207207
$this->options[$key] = $value;
208208
}
209209
}
@@ -277,6 +277,7 @@ public function send($url, $method = 'GET', $data = array())
277277

278278
// clear options
279279
$this->options = array();
280+
$this->httpOptions = array();
280281

281282
// flush our existing headers
282283
$this->headers = array();
@@ -369,7 +370,7 @@ public function setCAFile($caFile)
369370
*/
370371
public function setHttpOptions($httpOptions)
371372
{
372-
$this->$httpOptions = $httpOptions;
373+
$this->httpOptions = $httpOptions;
373374
}
374375

375376
/**

tests/Parse/ParseClientTest.php

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -700,15 +700,18 @@ public function testStreamHttpOptions()
700700
{
701701
ParseClient::setHttpClient(new ParseStreamHttpClient());
702702
ParseClient::setServerURL('https://localhost:1338', 'parse');
703-
// ParseClient::setHttpOptions([
704-
// CURLOPT_SSL_VERIFYPEER => false,
705-
// CURLOPT_PINNEDPUBLICKEY => 'sha256//Oz+R70/uIv0irdBWc7RNPyCGeZNbN+CBiPLjJxXWigg=',
706-
// CURLOPT_SSLCERT => dirname(__DIR__).'/keys/client.crt',
707-
// CURLOPT_SSLKEY => dirname(__DIR__).'/keys/client.key',
708-
// ]);
703+
ParseClient::setHttpOptions([
704+
'ssl' => [
705+
'verify_peer' => false,
706+
'verify_peer_name' => false,
707+
'allow_self_signed' => true,
708+
'local_cert' => dirname(__DIR__).'/keys/client.crt',
709+
'local_pk' => dirname(__DIR__).'/keys/client.key',
710+
'peer_fingerprint' => '29F36676EFA0CA18B5B571C6144580044CB289C2',
711+
]
712+
]);
709713
$health = ParseClient::getServerHealth();
710714

711-
Helper::printArray($health);
712715
$this->assertNotNull($health);
713716
$this->assertEquals($health['status'], 200);
714717
$this->assertEquals($health['response']['status'], 'ok');

tests/server.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,16 +121,16 @@ var requestOptions = {
121121
// Create agent (required for custom trust list)
122122
requestOptions.agent = new https.Agent(requestOptions);
123123

124-
var req = https.request(requestOptions, (res) => {
124+
const req = https.request(requestOptions, (res) => {
125125
console.log('statusCode:', res.statusCode);
126126
});
127127
req.end();
128128

129129
// Pin server certs
130130
req.on('socket', socket => {
131131
socket.on('secureConnect', () => {
132-
var fingerprint = socket.getPeerCertificate().fingerprint;
133-
132+
const fingerprint = socket.getPeerCertificate().fingerprint;
133+
134134
// Check if certificate is valid
135135
if(socket.authorized === false){
136136
req.emit('error', new Error(socket.authorizationError));

0 commit comments

Comments
 (0)