0
0
mirror of https://github.com/mongodb/mongo.git synced 2024-11-21 20:49:10 +01:00
mongodb/jstests/ocsp/ocsp_unable_to_staple_log.js
2023-08-06 20:48:04 +00:00

45 lines
1.1 KiB
JavaScript

// Check that log messages for OCSP stapling work
// @tags: [requires_http_client, requires_ocsp_stapling]
import {
OCSP_CA_PEM,
OCSP_SERVER_SIGNED_BY_INTERMEDIATE_CA_PEM,
supportsStapling,
waitForServer
} from "jstests/ocsp/lib/ocsp_helpers.js";
if (!supportsStapling()) {
quit();
}
const logPath = MongoRunner.dataPath + "mongod.log";
const ocsp_options = {
logpath: logPath,
sslMode: "requireSSL",
sslPEMKeyFile: OCSP_SERVER_SIGNED_BY_INTERMEDIATE_CA_PEM,
sslCAFile: OCSP_CA_PEM,
sslAllowInvalidHostnames: "",
waitForConnect: false,
};
// Because waitForConnect is off, we need to wait for the process to create the
// mongod logfile, hence the waitForServer.
const conn = MongoRunner.runMongod(ocsp_options);
waitForServer(conn);
const failedToStapleID = 5512202;
assert.soon(() => {
try {
cat(logPath);
return true;
} catch (e) {
return false;
}
});
assert.soon(() => {
return cat(logPath).trim().split("\n").some((line) => JSON.parse(line).id === failedToStapleID);
});
MongoRunner.stopMongod(conn);