-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Confirm preAuth handler only added when max > 0
- Loading branch information
John Schulz
committed
Jul 14, 2020
1 parent
aba7a45
commit b8288ae
Showing
1 changed file
with
35 additions
and
0 deletions.
There are no files selected for viewing
35 changes: 35 additions & 0 deletions
35
x-pack/plugins/ingest_manager/server/routes/limited_concurrency.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
}); | ||
}); |