describe('Protocol > Requests > Heartbeat > v1', () => { test('request', async () => { const { buffer } = await RequestV0Protocol({ groupId: 'consumer-group-id-4c456000151f094b600d-26762-fd6a6ae7-3f66-408e-802e-d261d6983d0d', groupGenerationId: 1, memberId: 'test-14da1b41ac688a6dcb78-26762-4dac8e12-dc28-4db2-8456-95bc6c1589bb-7bad1e84-c2de-4cc6-8071-badb27c86166', }).encode() expect(buffer).toEqual(Buffer.from(require('../fixtures/v1_request.json'))) }) })
describe('Broker > SASL Authenticator > PLAIN', () => { it('throws KafkaJSSASLAuthenticationError for invalid username', async () => { const plain = new Plain({ sasl: {} }, newLogger()) await expect(plain.authenticate()).rejects.toThrow('Invalid username or password') }) it('throws KafkaJSSASLAuthenticationError for invalid password', async () => { const plain = new Plain({ sasl: { username: '<username>' } }, newLogger()) await expect(plain.authenticate()).rejects.toThrow('Invalid username or password') }) })
describe('Utils > websiteUrl', () => { it('generates links to the website', () => { expect(websiteUrl('docs/faq')).toEqual('https://kafka.js.org/docs/faq') }) it('allows specifying a hash', () => { expect( websiteUrl('docs/faq', 'why-am-i-receiving-messages-for-topics-i-m-not-subscribed-to') ).toEqual( 'https://kafka.js.org/docs/faq#why-am-i-receiving-messages-for-topics-i-m-not-subscribed-to' ) }) })
describe('Protocol > Requests > Heartbeat > v0', () => { test('response', async () => { const data = await decode(Buffer.from(require('../fixtures/v0_response.json'))) expect(data).toEqual({ errorCode: 0 }) await expect(parse(data)).resolves.toBeTruthy() }) test('throws KafkaJSProtocolError if the api is not supported', async () => { await expect(decode(unsupportedVersionResponse())).rejects.toThrow( /The version of API is not supported/ ) }) })
describe('Protocol > Requests > SASLHandshake > v0', () => { test('throws KafkaJSProtocolError if the api is not supported', async () => { await expect(decode(unsupportedVersionResponse())).rejects.toThrow( /The version of API is not supported/ ) }) })
describe('Protocol > Requests > SyncGroup > v1', () => { test('response', async () => { const data = await decode(Buffer.from(require('../fixtures/v1_response.json'))) expect(data).toEqual({ throttleTime: 0, errorCode: 0, memberAssignment: Buffer.from(require('../fixtures/v1_memberAssignment.json')), }) await expect(parse(data)).resolves.toBeTruthy() }) })
describe('#paused', () => { it('returns an empty array if consumer#run has not been called', () => { expect(consumer.paused()).toEqual([]) }) })
describe('response with an unconfigured compression codec (snappy)', () => { test('throws KafkaJSNotImplemented error', async () => { await expect( decode(Buffer.from(require('../fixtures/v4_response_snappy.json'))) ).rejects.toThrow(KafkaJSNotImplemented) }) })
describe('Protocol > Requests > Heartbeat > v1', () => { test('response', async () => { const data = await decode(Buffer.from(require('../fixtures/v1_response.json'))) expect(data).toEqual({ throttleTime: 0, errorCode: 0 }) await expect(parse(data)).resolves.toBeTruthy() }) })
describe('Protocol > Requests > DescribeGroups > v0', () => { test('request', async () => { const groupIds = ['consumer-group-id-608e7e42043d917ecb44'] const { buffer } = await RequestV0Protocol({ groupIds }).encode() expect(buffer).toEqual(Buffer.from(require('../fixtures/v0_request.json'))) }) })
describe('Protocol > Requests > LeaveGroup > v0', () => { test('response', async () => { const data = await decode(Buffer.from(require('../fixtures/v0_response.json'))) expect(data).toEqual({ errorCode: 0 }) await expect(parse(data)).resolves.toBeTruthy() }) test('throws KafkaJSProtocolError if the api is not supported', async () => { await expect(decode(unsupportedVersionResponse())).rejects.toThrow( /The version of API is not supported/ ) }) })
describe('Protocol > Requests > FindCoordinator > v0', () => { test('request', async () => { const groupId = 'test-topic' const { buffer } = await RequestV0Protocol({ groupId }).encode() expect(buffer).toEqual(Buffer.from(require('../fixtures/v0_request.json'))) }) })
describe('Protocol > Requests > LeaveGroup > v1', () => { test('response', async () => { const data = await decode(Buffer.from(require('../fixtures/v1_response.json'))) expect(data).toEqual({ throttleTime: 0, errorCode: 0 }) await expect(parse(data)).resolves.toBeTruthy() }) })
describe('Protocol > Requests > OffsetCommit > v0', () => { test('response', async () => { const data = await decode(Buffer.from(require('../fixtures/v0_response.json'))) expect(data).toEqual({ responses: [ { topic: 'test-topic-eb1a285cda2e9f9a1021', partitions: [{ partition: 0, errorCode: 0 }] }, ], }) await expect(parse(data)).resolves.toBeTruthy() }) })
describe('Protocol > Requests > AddPartitionsToTxn > v0', () => { test('request', async () => { const { buffer } = await RequestV0Protocol({ transactionalId: 'test-transactional-id', producerId: '1001', producerEpoch: 0, groupId: 'foobar', }).encode() expect(buffer).toEqual(Buffer.from(require('../fixtures/v0_request.json'))) }) })