File tree Expand file tree Collapse file tree 3 files changed +21
-5
lines changed
src/Elasticsearch/Connections
tests/Elasticsearch/Tests Expand file tree Collapse file tree 3 files changed +21
-5
lines changed Original file line number Diff line number Diff line change @@ -493,6 +493,17 @@ public function getHost()
493
493
return $ this ->host ;
494
494
}
495
495
496
+ /**
497
+ * @return null|string
498
+ */
499
+ public function getUserPass ()
500
+ {
501
+ if (isset ($ this ->connectionParams ['client ' ]['curl ' ][CURLOPT_USERPWD ]) === true ) {
502
+ return $ this ->connectionParams ['client ' ]['curl ' ][CURLOPT_USERPWD ];
503
+ }
504
+ return null ;
505
+ }
506
+
496
507
/**
497
508
* @param $request
498
509
* @param $response
Original file line number Diff line number Diff line change @@ -44,6 +44,13 @@ public function getTransportSchema();
44
44
*/
45
45
public function getHost ();
46
46
47
+ /**
48
+ * Get the username:password string for this connection, null if not set
49
+ *
50
+ * @return null|string
51
+ */
52
+ public function getUserPass ();
53
+
47
54
/**
48
55
* Check to see if this instance is marked as 'alive'
49
56
*
Original file line number Diff line number Diff line change @@ -300,15 +300,13 @@ public function testInlineHosts()
300
300
$ this ->assertEquals ("https " , $ host ->getTransportSchema ());
301
301
302
302
303
- // Note: we can't test user/pass themselves yet, need to introduce
304
- // breaking change to interface in master to do that
305
- // But we can confirm it doesn't break anything
306
303
$ client = Elasticsearch \ClientBuilder::create ()->setHosts ([
307
304
'https://user:pass@foo.com:9200 '
308
305
])->build ();
309
306
$ host = $ client ->transport ->getConnection ();
310
307
$ this ->assertEquals ("foo.com:9200 " , $ host ->getHost ());
311
308
$ this ->assertEquals ("https " , $ host ->getTransportSchema ());
309
+ $ this ->assertEquals ("user:pass " , $ host ->getUserPass ());
312
310
}
313
311
314
312
public function testExtendedHosts ()
@@ -410,12 +408,12 @@ public function testExtendedHosts()
410
408
[
411
409
'host ' => 'foo.com ' ,
412
410
'user ' => 'user ' ,
413
- 'pass ' => 'abc#$%!abc '
411
+ 'pass ' => 'abc#$@? %!abc '
414
412
]
415
413
])->build ();
416
414
$ host = $ client ->transport ->getConnection ();
417
415
$ this ->assertEquals ("foo.com:9200 " , $ host ->getHost ());
418
416
$ this ->assertEquals ("http " , $ host ->getTransportSchema ());
419
-
417
+ $ this -> assertEquals ( " user:abc#$@?%!abc " , $ host -> getUserPass ());
420
418
}
421
419
}
You can’t perform that action at this time.
0 commit comments