Skip to content

Commit b8288ae

Browse files
author
John Schulz
committed
Confirm preAuth handler only added when max > 0
1 parent aba7a45 commit b8288ae

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the Elastic License;
4+
* you may not use this file except in compliance with the Elastic License.
5+
*/
6+
7+
import { coreMock } from 'src/core/server/mocks';
8+
import { registerLimitedConcurrencyRoutes } from './limited_concurrency';
9+
import { IngestManagerConfigType } from '../index';
10+
11+
describe('registerLimitedConcurrencyRoutes', () => {
12+
test(`doesn't call registerOnPreAuth if maxConcurrentConnections is 0`, async () => {
13+
const mockSetup = coreMock.createSetup();
14+
const mockConfig = { fleet: { maxConcurrentConnections: 0 } } as IngestManagerConfigType;
15+
registerLimitedConcurrencyRoutes(mockSetup, mockConfig);
16+
17+
expect(mockSetup.http.registerOnPreAuth).not.toHaveBeenCalled();
18+
});
19+
20+
test(`calls registerOnPreAuth once if maxConcurrentConnections is 1`, async () => {
21+
const mockSetup = coreMock.createSetup();
22+
const mockConfig = { fleet: { maxConcurrentConnections: 1 } } as IngestManagerConfigType;
23+
registerLimitedConcurrencyRoutes(mockSetup, mockConfig);
24+
25+
expect(mockSetup.http.registerOnPreAuth).toHaveBeenCalledTimes(1);
26+
});
27+
28+
test(`calls registerOnPreAuth once if maxConcurrentConnections is 1000`, async () => {
29+
const mockSetup = coreMock.createSetup();
30+
const mockConfig = { fleet: { maxConcurrentConnections: 1000 } } as IngestManagerConfigType;
31+
registerLimitedConcurrencyRoutes(mockSetup, mockConfig);
32+
33+
expect(mockSetup.http.registerOnPreAuth).toHaveBeenCalledTimes(1);
34+
});
35+
});

0 commit comments

Comments
 (0)