File tree Expand file tree Collapse file tree
src/core/server/elasticsearch/client Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -216,28 +216,14 @@ describe('parseClientOptions', () => {
216216 ) ;
217217 } ) ;
218218
219- it ( 'adds auth to the nodes if both `username` and `password` are set ' , ( ) => {
220- let options = parseClientOptions (
219+ it ( 'does not add auth to the nodes' , ( ) => {
220+ const options = parseClientOptions (
221221 createConfig ( {
222222 username : 'user' ,
223- hosts : [ 'http://node-A:9200' ] ,
224- } ) ,
225- false
226- ) ;
227- expect ( options . nodes ) . toMatchInlineSnapshot ( `
228- Array [
229- Object {
230- "url": "http://node-a:9200/",
231- },
232- ]
233- ` ) ;
234-
235- options = parseClientOptions (
236- createConfig ( {
237223 password : 'pass' ,
238224 hosts : [ 'http://node-A:9200' ] ,
239225 } ) ,
240- false
226+ true
241227 ) ;
242228 expect ( options . nodes ) . toMatchInlineSnapshot ( `
243229 Array [
@@ -246,22 +232,6 @@ describe('parseClientOptions', () => {
246232 },
247233 ]
248234 ` ) ;
249-
250- options = parseClientOptions (
251- createConfig ( {
252- username : 'user' ,
253- password : 'pass' ,
254- hosts : [ 'http://node-A:9200' ] ,
255- } ) ,
256- false
257- ) ;
258- expect ( options . nodes ) . toMatchInlineSnapshot ( `
259- Array [
260- Object {
261- "url": "http://user:pass@node-a:9200/",
262- },
263- ]
264- ` ) ;
265235 } ) ;
266236 } ) ;
267237 describe ( 'when `scoped` is true' , ( ) => {
Original file line number Diff line number Diff line change @@ -93,7 +93,7 @@ export function parseClientOptions(
9393 } ;
9494 }
9595
96- clientOptions . nodes = config . hosts . map ( ( host ) => convertHost ( host , ! scoped , config ) ) ;
96+ clientOptions . nodes = config . hosts . map ( ( host ) => convertHost ( host ) ) ;
9797
9898 if ( config . ssl ) {
9999 clientOptions . ssl = generateSslConfig (
@@ -140,18 +140,10 @@ const generateSslConfig = (
140140 return ssl ;
141141} ;
142142
143- const convertHost = (
144- host : string ,
145- needAuth : boolean ,
146- { username, password } : ElasticsearchClientConfig
147- ) : NodeOptions => {
143+ const convertHost = ( host : string ) : NodeOptions => {
148144 const url = new URL ( host ) ;
149145 const isHTTPS = url . protocol === 'https:' ;
150146 url . port = url . port || ( isHTTPS ? '443' : '80' ) ;
151- if ( needAuth && username && password ) {
152- url . username = username ;
153- url . password = password ;
154- }
155147
156148 return {
157149 url,
You can’t perform that action at this time.
0 commit comments