@@ -90,25 +90,28 @@ describe('trust-on-first-use', function() {
90
90
fs . unlinkSync ( knownHostsPath ) ;
91
91
}
92
92
93
- fs . writeFileSync (
94
- knownHostsPath ,
95
- 'localhost:7687 abcd\n' +
96
- 'localhost:7687 abcd'
97
- ) ;
98
-
99
93
driver = neo4j . driver ( "bolt://localhost" , neo4j . auth . basic ( "neo4j" , "neo4j" ) , {
100
94
encrypted : true ,
101
95
trust : "TRUST_ON_FIRST_USE" ,
102
96
knownHosts : knownHostsPath
103
97
} ) ;
104
98
99
+ driver . session ( ) ; // write into the knownHost file
100
+
101
+ // duplicate the same serverId twice
102
+ setTimeout ( function ( ) {
103
+ var text = fs . readFileSync ( knownHostsPath , 'utf8' ) ;
104
+ fs . writeFileSync ( knownHostsPath , text + text ) ;
105
+ } , 1000 ) ;
106
+
105
107
// When
106
- driver . session ( ) . run ( "RETURN true AS a" ) . then ( function ( data ) {
107
- // Then we get to here.
108
- // And then the known_hosts file should have correct contents
109
- expect ( data . records [ 0 ] . get ( 'a' ) ) . toBe ( true ) ;
110
- done ( ) ;
111
- } ) ;
108
+ setTimeout ( function ( ) {
109
+ driver . session ( ) . run ( "RETURN true AS a" ) . then ( function ( data ) {
110
+ // Then we get to here.
111
+ expect ( data . records [ 0 ] . get ( 'a' ) ) . toBe ( true ) ;
112
+ done ( ) ;
113
+ } ) ;
114
+ } , 2000 ) ;
112
115
} ) ;
113
116
114
117
it ( 'should accept previously un-seen hosts' , function ( done ) {
@@ -164,7 +167,7 @@ describe('trust-on-first-use', function() {
164
167
driver . session ( ) ;
165
168
166
169
setTimeout ( function ( ) {
167
- expect ( fs . readFileSync ( knownHostsPath , 'utf8' ) . split ( '\n' ) . length ) . toBe ( 1 ) ;
170
+ expect ( fs . readFileSync ( knownHostsPath , 'utf8' ) . trim ( ) . split ( '\n' ) . length ) . toBe ( 1 ) ;
168
171
done ( ) ;
169
172
} , 1000 ) ;
170
173
} ) ;
0 commit comments