Skip to content

Commit

Permalink
Confirm preAuth handler only added when max > 0
Browse files Browse the repository at this point in the history
  • Loading branch information
John Schulz committed Jul 14, 2020
1 parent aba7a45 commit b8288ae
Showing 1 changed file with 35 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

import { coreMock } from 'src/core/server/mocks';
import { registerLimitedConcurrencyRoutes } from './limited_concurrency';
import { IngestManagerConfigType } from '../index';

describe('registerLimitedConcurrencyRoutes', () => {
test(`doesn't call registerOnPreAuth if maxConcurrentConnections is 0`, async () => {
const mockSetup = coreMock.createSetup();
const mockConfig = { fleet: { maxConcurrentConnections: 0 } } as IngestManagerConfigType;
registerLimitedConcurrencyRoutes(mockSetup, mockConfig);

expect(mockSetup.http.registerOnPreAuth).not.toHaveBeenCalled();
});

test(`calls registerOnPreAuth once if maxConcurrentConnections is 1`, async () => {
const mockSetup = coreMock.createSetup();
const mockConfig = { fleet: { maxConcurrentConnections: 1 } } as IngestManagerConfigType;
registerLimitedConcurrencyRoutes(mockSetup, mockConfig);

expect(mockSetup.http.registerOnPreAuth).toHaveBeenCalledTimes(1);
});

test(`calls registerOnPreAuth once if maxConcurrentConnections is 1000`, async () => {
const mockSetup = coreMock.createSetup();
const mockConfig = { fleet: { maxConcurrentConnections: 1000 } } as IngestManagerConfigType;
registerLimitedConcurrencyRoutes(mockSetup, mockConfig);

expect(mockSetup.http.registerOnPreAuth).toHaveBeenCalledTimes(1);
});
});

0 comments on commit b8288ae

Please sign in to comment.