@@ -723,11 +723,11 @@ test('setRole', t => {
723
723
t . end ( )
724
724
} )
725
725
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 => {
727
727
t . plan ( 1 )
728
728
729
729
const connection = new Connection ( {
730
- url : new URL ( 'http://localhost:9200' ) ,
730
+ url : new URL ( 'http://user:password@ localhost:9200' ) ,
731
731
id : 'node-id' ,
732
732
headers : { foo : 'bar' }
733
733
} )
@@ -741,20 +741,7 @@ test('Util.inspect Connection class should hide agent and ssl', t => {
741
741
. replace ( / ( \r \n | \n | \r ) / gm, '' )
742
742
}
743
743
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/',
758
745
id: 'node-id',
759
746
headers: { foo: 'bar' },
760
747
deadCount: 0,
@@ -765,6 +752,34 @@ test('Util.inspect Connection class should hide agent and ssl', t => {
765
752
)
766
753
} )
767
754
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
+
768
783
// https://github.com/elastic/elasticsearch-js/issues/843
769
784
test ( 'Port handling' , t => {
770
785
t . test ( 'http 80' , t => {
0 commit comments