fix tests so they pass on a self-signed single 21.10 node

This commit is contained in:
Nicolas Dextraze 2022-10-22 09:05:18 -04:00
parent 05e716e563
commit aa07b04dd3
5 changed files with 14 additions and 7 deletions

View File

@ -15,9 +15,10 @@ function safeParseJson(json) {
}
}
function ProjectionsClient(log, operationTimeout) {
function ProjectionsClient(log, operationTimeout, rejectUnauthorized) {
this._log = log;
this._operationTimeout = operationTimeout;
this._rejectUnauthorized = typeof rejectUnauthorized === 'undefined' ? true : !!rejectUnauthorized;
}
ProjectionsClient.prototype.enable = function(httpEndPoint, name, userCredentials) {
@ -118,6 +119,9 @@ ProjectionsClient.prototype.request = function(method, _url, data, userCredentia
if (userCredentials) {
options.auth = [userCredentials.username, userCredentials.password].join(':');
}
if (!this._rejectUnauthorized) {
options.rejectUnauthorized = false;
}
var self = this;
return new Promise(function (resolve, reject) {
const timeout = setTimeout(function () {

View File

@ -6,12 +6,13 @@ const ProjectionsClient = require('./projectionsClient');
* @param {Logger} log Instance of Logger to use for logging.
* @param {string} httpEndPoint HTTP endpoint of an Event Store server.
* @param {number} operationTimeout Operation timeout in milliseconds.
* @param {boolean} [rejectUnauthorized] Reject authorized SSL certs (if using SSL) - set to false is using self-signed certs
* @constructor
*/
function ProjectionsManager(log, httpEndPoint, operationTimeout) {
function ProjectionsManager(log, httpEndPoint, operationTimeout, rejectUnauthorized) {
ensure.notNull(log, "log");
ensure.notNull(httpEndPoint, "httpEndPoint");
this._client = new ProjectionsClient(log, operationTimeout);
this._client = new ProjectionsClient(log, operationTimeout, rejectUnauthorized);
this._httpEndPoint = httpEndPoint;
}

View File

@ -12,6 +12,8 @@ protobufJS.configure();
var settings = {
log: new NoopLogger(),
useSslConnection: true,
validateServer: false
};
if (process.env.TESTS_VERBOSE_LOGGING === '1') {
settings.verboseLogging = true;

View File

@ -41,7 +41,7 @@ module.exports = {
done();
}
var self = this;
this.conn.connectToPersistentSubscription(testStreamName, 'consumer-1', eventAppeared, subscriptionDropped)
this.conn.connectToPersistentSubscription(testStreamName, 'consumer-1', eventAppeared, subscriptionDropped, adminCredentials)
.then(function(subscription) {
test.ok(subscription, "Subscription is null.");
return self.conn.appendToStream(testStreamName, client.expectedVersion.any, [createRandomEvent(), createRandomEvent()]);

View File

@ -2,7 +2,7 @@ const client = require('../lib/dist');
const userCredentials = new client.UserCredentials('admin', 'changeit');
const log = new client.NoopLogger();
const httpEndpoint = `http://${process.env.EVENTSTORE_HOST || "localhost"}:2113`;
const httpEndpoint = `https://${process.env.EVENTSTORE_HOST || "localhost"}:2113`;
const operationTimeout = 5000;
const simpleProjection = "\
@ -21,7 +21,7 @@ fromStream('$stats-127.0.0.1:2113')\
module.exports = {
setUp: function(cb) {
this.projectionsManager = new client.ProjectionsManager(log, httpEndpoint, operationTimeout);
this.projectionsManager = new client.ProjectionsManager(log, httpEndpoint, operationTimeout, false);
cb();
},
'Create One Time Projection Happy Path': function(test) {