Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: set explicitly useTLS=false for http endpoints #3242

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 5 additions & 7 deletions app/lib/zeebe-api/zeebe-api.js
Original file line number Diff line number Diff line change
Expand Up @@ -283,8 +283,7 @@ class ZeebeAPI {
clientId: endpoint.clientId,
clientSecret: endpoint.clientSecret,
cacheOnDisk: false
},
useTLS: true
}
};
} else if (type === endpointTypes.CAMUNDA_CLOUD) {
options = {
Expand All @@ -308,11 +307,10 @@ class ZeebeAPI {
async _withTLSConfig(url, options) {
const rootCerts = [];

// (0) force TLS only for https endpoints; don't parse the URL to avoid errors at this step
const tlsOptions = {};
if (/^https:\/\//.test(url)) {
tlsOptions.useTLS = true;
}
// (0) set `useTLS` according to the protocol
const tlsOptions = {
useTLS: options.useTLS || /^https:\/\//.test(url)
};

// (1) use certificate from flag
const customCertificatePath = this._flags.get('zeebe-ssl-certificate');
Expand Down
64 changes: 62 additions & 2 deletions app/test/spec/zeebe-api-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1469,7 +1469,7 @@ describe('ZeebeAPI', function() {
});


it('should NOT set `useTLS` for http endpoint', async () => {
it('should set `useTLS=false` for http endpoint (no auth)', async () => {

// given
let usedConfig;
Expand All @@ -1495,7 +1495,67 @@ describe('ZeebeAPI', function() {
await zeebeAPI.deploy(parameters);

// then
expect(usedConfig[1]).not.to.have.property('useTLS');
expect(usedConfig[1]).to.have.property('useTLS', false);
});


it('should set `useTLS=false` for http endpoint (oauth)', async () => {

// given
let usedConfig;

const zeebeAPI = mockZeebeNode({
ZBClient: function(...args) {
usedConfig = args;

return {
deployProcess: noop
};
}
});

const parameters = {
endpoint: {
type: 'oauth',
url: 'http://camunda.com'
}
};

// when
await zeebeAPI.deploy(parameters);

// then
expect(usedConfig[1]).to.have.property('useTLS', false);
});


it('should set `useTLS=true` for no protocol endpoint (cloud)', async () => {

// given
let usedConfig;

const zeebeAPI = mockZeebeNode({
ZBClient: function(...args) {
usedConfig = args;

return {
deployProcess: noop
};
}
});

const parameters = {
endpoint: {
type: 'camundaCloud',
url: 'camunda.com'
}
};

// when
await zeebeAPI.deploy(parameters);

// then
expect(usedConfig[1]).to.have.property('useTLS', true);
});
});

Expand Down