Skip to content

Commit

Permalink
chore(zeebe-api): pass flag from external source
Browse files Browse the repository at this point in the history
  • Loading branch information
nikku committed Aug 16, 2024
1 parent 87f39e6 commit e4ea090
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 15 deletions.
3 changes: 2 additions & 1 deletion app/lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -690,7 +690,8 @@ function bootstrap() {
errorTracking.setTag(Sentry, 'plugins', generatePluginsTag(plugins));

// (9) zeebe API
const zeebeAPI = new ZeebeAPI({ readFile }, ZeebeNode, flags);
const zeebeCustomCertificatePath = flags.get('zeebe-ssl-certificate');
const zeebeAPI = new ZeebeAPI({ readFile }, ZeebeNode, zeebeCustomCertificatePath);

// (10) connector templates
if (flags.get('enable-connector-templates', false)) {
Expand Down
8 changes: 4 additions & 4 deletions app/lib/zeebe-api/zeebe-api.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,11 +110,11 @@ const CLIENT_OPTIONS_SECRETS = [
*/

class ZeebeAPI {
constructor(fs, ZeebeNode, flags, log = createLog('app:zeebe-api')) {
constructor(fs, ZeebeNode, customCertificatePath, log = createLog('app:zeebe-api')) {
this._fs = fs;

this._ZeebeNode = ZeebeNode;
this._flags = flags;
this._customCertificatePath = customCertificatePath;
this._log = log;

this._zeebeClient = null;
Expand Down Expand Up @@ -400,8 +400,8 @@ class ZeebeAPI {
useTLS: options.useTLS || /^https:\/\//.test(url)
};

// (1) use certificate from flag
const customCertificatePath = this._flags.get('zeebe-ssl-certificate');
// (1) use certificate from custom path
const customCertificatePath = this._customCertificatePath;

if (customCertificatePath) {
const cert = this._readRootCertificate(customCertificatePath);
Expand Down
14 changes: 4 additions & 10 deletions app/test/spec/zeebe-api/zeebe-api-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2148,11 +2148,7 @@ describe('ZeebeAPI', function() {
deployResource: noop
};
},
flags: {
get() {
return '/path/to/cert.pem';
}
},
customCertificatePath: '/path/to/cert.pem',
fs: {
readFile() {
return { contents: certificate };
Expand All @@ -2173,7 +2169,7 @@ describe('ZeebeAPI', function() {
}


it('should pass root certificate from flag', async () => {
it('should pass root certificate', async () => {

// given
const cert = readFile('./root-self-signed.pem');
Expand Down Expand Up @@ -2531,9 +2527,7 @@ function mockZeebeNode(options = {}) {
const fs = options.fs || {
readFile: () => ({})
};
const flags = options.flags || {
get: () => {}
};
const customCertificatePath = options.customCertificatePath;
const log = {
error() {},
debug() {},
Expand All @@ -2553,7 +2547,7 @@ function mockZeebeNode(options = {}) {
}
};

return new ZeebeAPI(fs, ZeebeNode, flags, log);
return new ZeebeAPI(fs, ZeebeNode, customCertificatePath, log);
}

function noop() {}
Expand Down

0 comments on commit e4ea090

Please sign in to comment.