diff --git a/package.json b/package.json index 2cdc9c69..694aa404 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,7 @@ "compile": "tsc --project tsconfig.json", "docs": "rm -rf ./docs && typedoc", "generate:grpc": "grpc_tools_node_protoc --plugin=protoc-gen-ts=./node_modules/.bin/protoc-gen-ts --js_out=import_style=commonjs,binary:./src/generated --grpc_out=./src/generated --ts_out=./src/generated -I ./src/proto ./src/proto/*.proto", - "test": "cross-env CAMUNDA_UNIT_TEST=true jest '.*unit.*' -u --detectOpenHandles --testPathIgnorePatterns integration --testPathIgnorePatterns local-integration --testPathIgnorePatterns disconnection --testPathIgnorePatterns multitenancy --testPathIgnorePatterns __tests__/config", + "test": "cross-env CAMUNDA_UNIT_TEST=true jest '.*unit.*' -u --detectOpenHandles --runInBand --testPathIgnorePatterns integration --testPathIgnorePatterns local-integration --testPathIgnorePatterns disconnection --testPathIgnorePatterns multitenancy --testPathIgnorePatterns __tests__/config", "test:integration": "jest --runInBand --testPathIgnorePatterns disconnection --testPathIgnorePatterns '.unit.*' --testPathIgnorePatterns __tests__/config --testPathIgnorePatterns multitenancy --detectOpenHandles --verbose true -u", "test:multitenancy": "jest --runInBand --testPathIgnorePatterns disconnection --testPathIgnorePatterns admin --testPathIgnorePatterns '.unit.*' --testPathIgnorePatterns __tests__/config - --detectOpenHandles --verbose true -u", "test:local": "jest --runInBand --verbose true --detectOpenHandles local-integration -u", diff --git a/src/__tests__/lib/GetCustomCertificateBuffer.unit.spec.ts b/src/__tests__/lib/GetCustomCertificateBuffer.unit.spec.ts index f4c3d202..84eaf0ee 100644 --- a/src/__tests__/lib/GetCustomCertificateBuffer.unit.spec.ts +++ b/src/__tests__/lib/GetCustomCertificateBuffer.unit.spec.ts @@ -53,8 +53,11 @@ test('Can use a custom root certificate to connect to a REST API', async () => { CAMUNDA_OPERATE_BASE_URL: 'https://localhost:3012', }, }) - + console.log('Trying to get process instance with certificate') const res = await c.getProcessInstance('1') + console.log( + `Got response from self-signed secured server: ${res.bpmnProcessId}` + ) expect(res.bpmnProcessId).toBe('test') const c1 = new OperateApiClient({ config: { @@ -65,6 +68,7 @@ test('Can use a custom root certificate to connect to a REST API', async () => { let threw = false try { + console.log('Trying to get process instance without certificate') await c1.getProcessInstance('1') } catch (e) { threw = true diff --git a/src/lib/GetCustomCertificateBuffer.ts b/src/lib/GetCustomCertificateBuffer.ts index 1655b271..5197a910 100644 --- a/src/lib/GetCustomCertificateBuffer.ts +++ b/src/lib/GetCustomCertificateBuffer.ts @@ -11,8 +11,7 @@ const trace = debug('camunda:certificate') export async function GetCustomCertificateBuffer( config: CamundaPlatform8Configuration -): Promise { - trace(config) +): Promise { const customRootCertPath = config.CAMUNDA_CUSTOM_ROOT_CERT_PATH const customRootCert = config.CAMUNDA_CUSTOM_ROOT_CERT_STRING @@ -42,8 +41,9 @@ export async function GetCustomCertificateBuffer( trace(`No custom root certificates found`) return undefined } - - return Buffer.from(rootCerts.join('\n')) + const output = rootCerts.join('\n') + trace(`Custom root certificates:\n${output}`) + return output } function readRootCertificate(certPath) { diff --git a/src/zeebe/zb/ZeebeGrpcClient.ts b/src/zeebe/zb/ZeebeGrpcClient.ts index 257551d8..72ae63ff 100644 --- a/src/zeebe/zb/ZeebeGrpcClient.ts +++ b/src/zeebe/zb/ZeebeGrpcClient.ts @@ -159,7 +159,7 @@ export class ZeebeGrpcClient extends TypedEmitter< const customSSL = { certChain: certChainPath ? readFileSync(certChainPath) : undefined, privateKey: privateKeyPath ? readFileSync(privateKeyPath) : undefined, - rootCerts, + rootCerts: rootCerts ? Buffer.from(rootCerts) : undefined, } this.customSSL = customSSL