@@ -723,11 +723,11 @@ test('setRole', t => {
723723 t . end ( )
724724} )
725725
726- test ( 'Util.inspect Connection class should hide agent and ssl ' , t => {
726+ test ( 'Util.inspect Connection class should hide agent, ssl and auth ' , t => {
727727 t . plan ( 1 )
728728
729729 const connection = new Connection ( {
730- url : new URL ( 'http://localhost:9200' ) ,
730+ url : new URL ( 'http://user:password@ localhost:9200' ) ,
731731 id : 'node-id' ,
732732 headers : { foo : 'bar' }
733733 } )
@@ -741,20 +741,7 @@ test('Util.inspect Connection class should hide agent and ssl', t => {
741741 . replace ( / ( \r \n | \n | \r ) / gm, '' )
742742 }
743743
744- t . strictEqual ( cleanStr ( inspect ( connection ) ) , cleanStr ( `{ url:
745- URL {
746- href: 'http://localhost:9200/',
747- origin: 'http://localhost:9200',
748- protocol: 'http:',
749- username: '',
750- password: '',
751- host: 'localhost:9200',
752- hostname: 'localhost',
753- port: '9200',
754- pathname: '/',
755- search: '',
756- searchParams: URLSearchParams {},
757- hash: '' },
744+ t . strictEqual ( cleanStr ( inspect ( connection ) ) , cleanStr ( `{ url: 'http://localhost:9200/',
758745 id: 'node-id',
759746 headers: { foo: 'bar' },
760747 deadCount: 0,
@@ -765,6 +752,34 @@ test('Util.inspect Connection class should hide agent and ssl', t => {
765752 )
766753} )
767754
755+ test ( 'connection.toJSON should hide agent, ssl and auth' , t => {
756+ t . plan ( 1 )
757+
758+ const connection = new Connection ( {
759+ url : new URL ( 'http://user:password@localhost:9200' ) ,
760+ id : 'node-id' ,
761+ headers : { foo : 'bar' }
762+ } )
763+
764+ t . deepEqual ( connection . toJSON ( ) , {
765+ url : 'http://localhost:9200/' ,
766+ id : 'node-id' ,
767+ headers : {
768+ foo : 'bar'
769+ } ,
770+ deadCount : 0 ,
771+ resurrectTimeout : 0 ,
772+ _openRequests : 0 ,
773+ status : 'alive' ,
774+ roles : {
775+ master : true ,
776+ data : true ,
777+ ingest : true ,
778+ ml : false
779+ }
780+ } )
781+ } )
782+
768783// https://github.com/elastic/elasticsearch-js/issues/843
769784test ( 'Port handling' , t => {
770785 t . test ( 'http 80' , t => {
0 commit comments