Skip to content

Commit 0f3759e

Browse files
author
Zhen
committed
Merge branch '1.0' into 1.1
2 parents c41db88 + c64c727 commit 0f3759e

File tree

2 files changed

+2
-73
lines changed

2 files changed

+2
-73
lines changed

src/v1/internal/ch-node.js

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -57,30 +57,12 @@ function loadFingerprint( serverId, knownHostsPath, cb ) {
5757
});
5858
}
5959

60-
const _lockFingerprintFromAppending = {};
61-
function storeFingerprint( serverId, knownHostsPath, fingerprint ) {
62-
// we check if the serverId has been appended
63-
if(!!_lockFingerprintFromAppending[serverId]){
64-
// if it has, we ignore it
65-
return;
66-
}
67-
68-
// we make the line as appended
69-
// ( 1 is more efficient to store than true because true is an oddball )
70-
_lockFingerprintFromAppending[serverId] = 1;
71-
72-
// we append to file
60+
function storeFingerprint(serverId, knownHostsPath, fingerprint) {
7361
fs.appendFile(knownHostsPath, serverId + " " + fingerprint + EOL, "utf8", (err) => {
7462
if (err) {
7563
console.log(err);
7664
}
7765
});
78-
79-
// since the error occurs in the span of one tick
80-
// after one tick we clean up to not interfere with anything else
81-
setImmediate(() => {
82-
delete _lockFingerprintFromAppending[serverId];
83-
});
8466
}
8567

8668
const TrustStrategy = {

test/internal/tls.test.js

Lines changed: 1 addition & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -142,60 +142,7 @@ describe('trust-on-first-use', function() {
142142
done();
143143
});
144144
});
145-
146-
it('should not duplicate fingerprint entries', function(done) {
147-
// Assuming we only run this test on NodeJS with TOFU support
148-
if( !hasFeature("trust_on_first_use") ) {
149-
done();
150-
return;
151-
}
152-
153-
// Given
154-
var knownHostsPath = "build/known_hosts";
155-
if( fs.existsSync(knownHostsPath) ) {
156-
fs.unlinkSync(knownHostsPath);
157-
}
158-
fs.writeFileSync(knownHostsPath, '');
159-
160-
driver = neo4j.driver("bolt://localhost", neo4j.auth.basic("neo4j", "neo4j"), {
161-
encrypted: true,
162-
trust: "TRUST_ON_FIRST_USE",
163-
knownHosts: knownHostsPath
164-
});
165-
166-
// When
167-
driver.session();
168-
driver.session();
169-
170-
setTimeout(function() {
171-
var lines = {};
172-
fs.readFileSync(knownHostsPath, 'utf8')
173-
.split('\n')
174-
.filter(function(line) {
175-
return !! (line.trim());
176-
})
177-
.forEach(function(line) {
178-
if (!lines[line]) {
179-
lines[line] = 0;
180-
}
181-
lines[line]++;
182-
});
183-
184-
var duplicatedLines = Object
185-
.keys(lines)
186-
.map(function(line) {
187-
return lines[line];
188-
})
189-
.filter(function(count) {
190-
return count > 1;
191-
})
192-
.length;
193-
194-
expect( duplicatedLines ).toBe( 0 );
195-
done();
196-
}, 1000);
197-
});
198-
145+
199146
it('should should give helpful error if database cert does not match stored certificate', function(done) {
200147
// Assuming we only run this test on NodeJS with TOFU support
201148
if( !hasFeature("trust_on_first_use") ) {

0 commit comments

Comments
 (0)