massakam commented on a change in pull request #138: URL: https://github.com/apache/pulsar-client-node/pull/138#discussion_r559980339
########## File path: tests/end_to_end.test.js ########## @@ -665,5 +669,87 @@ const Pulsar = require('../index.js'); await consumer.close(); await client.close(); }); + test('Basic produce and consume encryption', async () => { + const client = new Pulsar.Client({ + serviceUrl: 'pulsar://localhost:6650', + operationTimeoutSeconds: 30, + }); + + const topic = 'persistent://public/default/encryption-produce-consume'; + const producer = await client.createProducer({ + topic, + sendTimeoutMs: 30000, + batchingEnabled: true, + publicKeyPath: './certificate/public-rsa.pem', + privateKeyPath: './certificate/private-rsa.pem', + encryptionKey: 'encryption-key', + }); + + const consumer = await client.subscribe({ + topic, + subscription: 'sub1', + subscriptionType: 'Shared', + ackTimeoutMs: 10000, + publicKeyPath: './public-rsa.pem', + privateKeyPath: './private-rsa.pem', + }); + + const messages = []; + for (let i = 0; i < 10; i += 1) { + const msg = `my-message-${i}`; + producer.send({ + data: Buffer.from(msg), + }); + messages.push(msg); + } + await producer.flush(); + + const results = []; + for (let i = 0; i < 10; i += 1) { + const msg = await consumer.receive(); + consumer.acknowledge(msg); + results.push(msg.getData().toString()); + } + expect(lodash.difference(messages, results)).toEqual([]); + await producer.close(); + await consumer.close(); + await client.close(); + }); + + test('Failed produce and consume encryption', async () => { Review comment: Is this test case necessary? It doesn't seem to be a test related to encryption. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org