@@ -26,7 +26,13 @@ class SSLTest extends PredisTestCase
2626 */
2727 public function testExecuteCommandOverSSLConnection ()
2828 {
29- $ redis = $ this ->createClient ();
29+ $ redis = $ this ->createClient ([
30+ 'ssl ' => [
31+ 'cafile ' => getenv ('STANDALONE_CA_CERT_PATH ' ),
32+ 'verify_peer ' => true ,
33+ 'verify_peer_name ' => false ,
34+ ],
35+ ]);
3036 $ this ->assertEquals ('PONG ' , $ redis ->ping ());
3137 }
3238
@@ -76,7 +82,16 @@ public function testExecuteCommandOverSSLConnectionWithoutSSLConfig()
7682 */
7783 public function testClusterExecuteCommandOverSSLConnection ()
7884 {
79- $ redis = $ this ->createClient ();
85+ $ redis = $ this ->createClient (null , [
86+ 'cluster ' => 'redis ' ,
87+ 'parameters ' => [
88+ 'ssl ' => [
89+ 'cafile ' => getenv ('CLUSTER_CA_CERT_PATH ' ),
90+ 'verify_peer ' => true ,
91+ 'verify_peer_name ' => false ,
92+ ],
93+ ],
94+ ]);
8095 $ redis ->set ('foo ' , 'bar ' );
8196 $ this ->assertEquals ('bar ' , $ redis ->get ('foo ' ));
8297 }
@@ -123,4 +138,74 @@ public function testClusterExecuteCommandOverSSLConnectionWithoutSSLConfig()
123138
124139 $ redis ->set ('foo ' , 'bar ' );
125140 }
141+
142+ /**
143+ * @group connected
144+ * @group ssl
145+ * @group relay-incompatible
146+ * @requiresRedisVersion >= 8.5.0
147+ * @return void
148+ */
149+ public function testAuthWithSSLCertificateWithCNSpecified ()
150+ {
151+ $ redis = $ this ->createClient ();
152+
153+ $ this ->assertEquals (
154+ 'OK ' ,
155+ $ redis ->acl ->setUser ('test_user ' , 'on ' , '>clientpass ' , 'allcommands ' , 'allkeys ' )
156+ );
157+
158+ $ redis ->disconnect ();
159+
160+ // Remove AUTH
161+ $ redis = $ this ->createClient (['password ' => null ]);
162+
163+ $ this ->assertEquals (getenv ('CN_USER_NAME ' ), $ redis ->acl ->whoami ());
164+ $ this ->assertEquals (1 , $ redis ->acl ->delUser (getenv ('CN_USER_NAME ' )));
165+ }
166+
167+ /**
168+ * @group connected
169+ * @group ssl
170+ * @group cluster
171+ * @group relay-incompatible
172+ * @requiresRedisVersion >= 8.5.0
173+ * @return void
174+ */
175+ public function testClusterAuthWithSSLCertificateWithCNSpecified ()
176+ {
177+ $ redis = $ this ->createClient ();
178+
179+ $ this ->assertEquals (
180+ 'OK ' ,
181+ $ redis ->acl ->setUser ('test_user ' , 'on ' , '>clientpass ' , 'allcommands ' , 'allkeys ' )
182+ );
183+
184+ $ redis ->disconnect ();
185+
186+ // Remove AUTH
187+ $ defaultParameters = $ this ->getDefaultParametersArray ();
188+ $ trimmedParameters = array_map (function (string $ parameter ) {
189+ return explode ('? ' , $ parameter )[0 ];
190+ }, $ defaultParameters );
191+
192+ $ redis = new Client (
193+ $ trimmedParameters ,
194+ [
195+ 'cluster ' => 'redis ' ,
196+ 'parameters ' => [
197+ 'ssl ' => [
198+ 'cafile ' => getenv ('CLUSTER_CA_CERT_PATH ' ),
199+ 'local_cert ' => getenv ('CLUSTER_LOCAL_CERT_PATH ' ),
200+ 'local_pk ' => getenv ('CLUSTER_LOCAL_PK_PATH ' ),
201+ 'verify_peer ' => true ,
202+ 'verify_peer_name ' => false ,
203+ ],
204+ ],
205+ ]
206+ );
207+
208+ $ this ->assertEquals (getenv ('CN_USER_NAME ' ), $ redis ->acl ->whoami ());
209+ $ this ->assertEquals (1 , $ redis ->acl ->delUser (getenv ('CN_USER_NAME ' )));
210+ }
126211}
0 commit comments