16
16
17
17
use PHPUnit \Framework \TestCase ;
18
18
19
+ defined ('CURLOPT_PINNEDPUBLICKEY ' ) || define ('CURLOPT_PINNEDPUBLICKEY ' , 10230 );
20
+
19
21
class ParseClientTest extends TestCase
20
22
{
21
23
public static function setUpBeforeClass () : void
@@ -35,6 +37,9 @@ public function tearDown() : void
35
37
36
38
// unset CA file
37
39
ParseClient::setCAFile (null );
40
+
41
+ // unset http options
42
+ ParseClient::setHttpOptions (null );
38
43
}
39
44
40
45
/**
@@ -667,4 +672,52 @@ public function testCheckBadServer()
667
672
$ this ->assertTrue (isset ($ health ['error_message ' ]));
668
673
}
669
674
}
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
+ }
670
723
}
0 commit comments