mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-12 06:12:18 +00:00
Merge pull request #1547 from quanticsoul4772/upstream/nominatim-cache-mode-windows
test(nominatim): check cache file modes only where POSIX modes exist
This commit is contained in:
2 files changed
+25
-13
No files matched your search
@@ -0,0 +1,3 @@
|
|||||||
|
- The Nominatim disk-cache test checks the cache directory and file modes
|
||||||
|
only where POSIX modes exist, so it no longer always fails on Windows
|
||||||
|
(quanticsoul4772, #1547).
|
||||||
@@ -684,25 +684,34 @@ test('the disk cache survives a restart and stays within its bounds', async () =
|
|||||||
await createNominatimCache({ dir, now: time.now }).get('k0'),
|
await createNominatimCache({ dir, now: time.now }).get('k0'),
|
||||||
null,
|
null,
|
||||||
);
|
);
|
||||||
assert.equal(
|
// The cache is private only through POSIX mode bits. Windows has none
|
||||||
fs.statSync(dir).mode & 0o777,
|
// (directories stat as 0o666) and the cache keeps the checkout's ACLs,
|
||||||
0o700,
|
// so these checks run, and privacy holds, only on POSIX systems.
|
||||||
'the query cache directory is private',
|
const posixModes = process.platform !== 'win32';
|
||||||
);
|
if (posixModes) {
|
||||||
|
assert.equal(
|
||||||
|
fs.statSync(dir).mode & 0o777,
|
||||||
|
0o700,
|
||||||
|
'the query cache directory is private (POSIX modes)',
|
||||||
|
);
|
||||||
|
}
|
||||||
const text = fs
|
const text = fs
|
||||||
.readdirSync(dir)
|
.readdirSync(dir)
|
||||||
.filter((name) => name.endsWith('.json'))
|
.filter((name) => name.endsWith('.json'))
|
||||||
.map((name) => fs.readFileSync(path.join(dir, name), 'utf8'))
|
.map((name) => fs.readFileSync(path.join(dir, name), 'utf8'))
|
||||||
.join('\n');
|
.join('\n');
|
||||||
assert.equal(text.includes('k4'), false, 'disk entries never store raw keys');
|
assert.equal(text.includes('k4'), false, 'disk entries never store raw keys');
|
||||||
for (const name of fs
|
if (posixModes) {
|
||||||
.readdirSync(dir)
|
for (const name of fs
|
||||||
.filter((entry) => entry.endsWith('.json')))
|
.readdirSync(dir)
|
||||||
assert.equal(
|
.filter((entry) => entry.endsWith('.json'))) {
|
||||||
fs.statSync(path.join(dir, name)).mode & 0o777,
|
assert.equal(
|
||||||
0o600,
|
fs.statSync(path.join(dir, name)).mode & 0o777,
|
||||||
`${name} is private`,
|
0o600,
|
||||||
);
|
`${name} is private (POSIX modes)`,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
fs.rmSync(dir, { recursive: true, force: true });
|
fs.rmSync(dir, { recursive: true, force: true });
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user