1616
1717use PHPUnit \Framework \TestCase ;
1818
19+ defined ('CURLOPT_PINNEDPUBLICKEY ' ) || define ('CURLOPT_PINNEDPUBLICKEY ' , 10230 );
20+
1921class ParseClientTest extends TestCase
2022{
2123 public static function setUpBeforeClass () : void
@@ -35,6 +37,9 @@ public function tearDown() : void
3537
3638 // unset CA file
3739 ParseClient::setCAFile (null );
40+
41+ // unset http options
42+ ParseClient::setHttpOptions (null );
3843 }
3944
4045 /**
@@ -667,4 +672,52 @@ public function testCheckBadServer()
667672 $ this ->assertTrue (isset ($ health ['error_message ' ]));
668673 }
669674 }
675+
676+ /**
677+ * @group test-http-options
678+ */
679+ public function testCurlHttpOptions ()
680+ {
681+ if (function_exists ('curl_init ' )) {
682+ ParseClient::setHttpClient (new ParseCurlHttpClient ());
683+ ParseClient::setServerURL ('https://localhost:1338 ' , 'parse ' );
684+ ParseClient::setHttpOptions ([
685+ CURLOPT_SSL_VERIFYPEER => false ,
686+ CURLOPT_PINNEDPUBLICKEY => 'sha256//Oz+R70/uIv0irdBWc7RNPyCGeZNbN+CBiPLjJxXWigg= ' ,
687+ CURLOPT_SSLCERT => dirname (__DIR__ ).'/keys/client.crt ' ,
688+ CURLOPT_SSLKEY => dirname (__DIR__ ).'/keys/client.key ' ,
689+ ]);
690+ $ health = ParseClient::getServerHealth ();
691+
692+ $ this ->assertNotNull ($ health );
693+ $ this ->assertEquals ($ health ['status ' ], 200 );
694+ $ this ->assertEquals ($ health ['response ' ]['status ' ], 'ok ' );
695+ Helper::setServerURL ();
696+ }
697+ }
698+
699+ /**
700+ * @group test-http-options
701+ */
702+ public function testStreamHttpOptions ()
703+ {
704+ ParseClient::setHttpClient (new ParseStreamHttpClient ());
705+ ParseClient::setServerURL ('https://localhost:1338 ' , 'parse ' );
706+ ParseClient::setHttpOptions ([
707+ 'ssl ' => [
708+ 'verify_peer ' => false ,
709+ 'verify_peer_name ' => false ,
710+ 'allow_self_signed ' => true ,
711+ 'local_cert ' => dirname (__DIR__ ).'/keys/client.crt ' ,
712+ 'local_pk ' => dirname (__DIR__ ).'/keys/client.key ' ,
713+ 'peer_fingerprint ' => '29F36676EFA0CA18B5B571C6144580044CB289C2 ' ,
714+ ]
715+ ]);
716+ $ health = ParseClient::getServerHealth ();
717+
718+ $ this ->assertNotNull ($ health );
719+ $ this ->assertEquals ($ health ['status ' ], 200 );
720+ $ this ->assertEquals ($ health ['response ' ]['status ' ], 'ok ' );
721+ Helper::setServerURL ();
722+ }
670723}
0 commit comments