add two new tests to diagnose unavailability of uploaded blocks and blobs

This commit is contained in:
ansuz 2022-03-08 18:20:11 +05:30
parent e5891b2e05
commit c111364024
3 changed files with 57 additions and 0 deletions

View File

@ -4,6 +4,8 @@ const NetfluxSrv = require('chainpad-server');
const Decrees = require("./decrees");
const nThen = require("nthen");
const Fs = require("fs");
const Path = require("path");
module.exports.create = function (Env) {
var log = Env.Log;
@ -19,6 +21,9 @@ nThen(function (w) {
console.error(err);
}
}));
}).nThen(function (w) {
var fullPath = Path.join(Env.paths.block, 'placeholder.txt');
Fs.writeFile(fullPath, 'PLACEHOLDER\n', w());
}).nThen(function () {
// asynchronously create a historyKeeper and RPC together
require('./historyKeeper.js').create(Env, function (err, historyKeeper) {

View File

@ -495,6 +495,10 @@ BlobStore.create = function (config, _cb) {
Fse.mkdirp(Path.join(Env.archivePath, Env.blobPath), w(function (e) {
if (e) { CB(e); }
}));
}).nThen(function (w) {
// XXX make a placeholder file in the root of the blob path
var fullPath = Path.join(Env.blobPath, 'placeholder.txt');
Fse.writeFile(fullPath, 'PLACEHOLDER\n', w());
}).nThen(function () {
var methods = {
isFileId: isValidId,

View File

@ -1113,6 +1113,54 @@ define([
});
});
assert(function (cb, msg) {
var path = '/blob/placeholder.txt';
var fullPath;
try {
fullPath = new URL(path, ApiConfig.fileHost || ApiConfig.httpUnsafeOrigin).href;
} catch (err) {
fullPath = path;
}
msg.appendChild(h('span', [
"A placeholder file was expected to be available at ",
code(fullPath),
", but it was not found.",
" This commonly indicates a mismatch between the API server's ",
code('blobPath'),
" value and the path that the webserver or reverse proxy is attempting to serve.",
" This misconfiguration will cause errors with uploaded files and CryptPad's office editors (sheet, presentation, document).",
]));
Tools.common_xhr(fullPath, xhr => {
cb(xhr.status === 200 || xhr.status);
});
});
assert(function (cb, msg) {
var path = '/block/placeholder.txt';
var fullPath;
try {
fullPath = new URL(path, ApiConfig.fileHost || ApiConfig.httpUnsafeOrigin).href;
} catch (err) {
fullPath = path;
}
msg.appendChild(h('span', [
"A placeholder file was expected to be available at ",
code(fullPath),
", but it was not found.",
" This commonly indicates a mismatch between the API server's ",
code('blockPath'),
" value and the path that the webserver or reverse proxy is attempting to serve.",
" This misconfiguration will cause errors with login, registration, and password change.",
]));
Tools.common_xhr(fullPath, xhr => {
cb(xhr.status === 200 || xhr.status);
});
});
var serverToken;
Tools.common_xhr('/', function (xhr) {
serverToken = xhr.getResponseHeader('server');