n8n-nodes-kafka-batch-consumer 1.0.9 → 1.0.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "n8n-nodes-kafka-batch-consumer",
3
- "version": "1.0.9",
3
+ "version": "1.0.11",
4
4
  "description": "N8N node for consuming Kafka messages in batches",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -292,23 +292,25 @@ describe('KafkaBatchConsumer', () => {
292
292
  });
293
293
  });
294
294
 
295
- it('should handle SSL with rejectUnauthorized false', async () => {
295
+ /**
296
+ * Test plaintext connection (no SSL)
297
+ * When ssl is false or undefined, no SSL configuration should be added
298
+ */
299
+ it('should handle plaintext connection without SSL', async () => {
296
300
  mockExecuteFunctions.getCredentials.mockResolvedValue({
297
301
  brokers: 'localhost:9092',
298
302
  clientId: 'test-client',
299
- ssl: false,
303
+ ssl: false, // Explicitly disable SSL
300
304
  });
301
305
 
302
- mockConsumer.run.mockImplementation(async () => Promise.resolve());
306
+ mockConsumer.run.mockImplementation(async () => new Promise(() => {}));
303
307
 
304
308
  await kafkaBatchConsumer.execute.call(mockExecuteFunctions);
305
309
 
310
+ // Should NOT include ssl config when ssl: false
306
311
  expect(Kafka).toHaveBeenCalledWith({
307
312
  clientId: 'test-client',
308
313
  brokers: ['localhost:9092'],
309
- ssl: {
310
- rejectUnauthorized: false,
311
- },
312
314
  });
313
315
  });
314
316
 
@@ -151,6 +151,15 @@ export class KafkaBatchConsumer implements INodeType {
151
151
  ['localhost:9092'],
152
152
  };
153
153
 
154
+ // Debug: log credentials to understand SSL configuration
155
+ console.log('🔍 Kafka Credentials Debug:', {
156
+ ssl: credentials.ssl,
157
+ hasCa: !!credentials.ca,
158
+ hasCert: !!credentials.cert,
159
+ hasKey: !!credentials.key,
160
+ sslType: typeof credentials.ssl,
161
+ });
162
+
154
163
  // Map N8N credential fields to KafkaJS authentication format
155
164
  // Add SASL authentication if provided
156
165
  if (credentials.authentication) {
@@ -162,9 +171,10 @@ export class KafkaBatchConsumer implements INodeType {
162
171
  }
163
172
 
164
173
  // Add SSL/TLS configuration for encrypted connections
165
- if (credentials.ssl !== undefined) {
174
+ // Only enable SSL if explicitly set to true or if SSL certificates are provided
175
+ if (credentials.ssl === true || credentials.ca || credentials.cert || credentials.key) {
166
176
  kafkaConfig.ssl = {
167
- rejectUnauthorized: credentials.ssl, // Validate server certificates
177
+ rejectUnauthorized: credentials.ssl !== false, // Default to true if SSL is enabled
168
178
  };
169
179
 
170
180
  // Add optional SSL certificates for mutual TLS authentication