test(search-elasticsearch): add test for elastic provider with authProvider
Signed-off-by: nojaf <florian.verdonck@outlook.com>
This commit is contained in:
+30
@@ -1048,6 +1048,36 @@ describe('ElasticSearchSearchEngine', () => {
|
||||
expect(engine).toBeDefined();
|
||||
});
|
||||
|
||||
it('should accept an authProvider with elastic provider', async () => {
|
||||
// cloudId format: <name>:<base64-encoded-data>
|
||||
// The base64 part decodes to: <es-hostname>$<kibana-hostname>
|
||||
const cloudId =
|
||||
'test:dXMtY2VudHJhbDEuZ2NwLmNsb3VkLmVzLmlvJGFiY2QkZWZnaA==';
|
||||
const config = new ConfigReader({
|
||||
search: {
|
||||
elasticsearch: {
|
||||
provider: 'elastic',
|
||||
cloudId,
|
||||
// No auth config - using authProvider instead
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
const authProvider = {
|
||||
getAuthHeaders: jest
|
||||
.fn()
|
||||
.mockResolvedValue({ Authorization: 'Bearer test-token' }),
|
||||
};
|
||||
|
||||
const engine = await ElasticSearchSearchEngine.fromConfig({
|
||||
logger: mockServices.logger.mock(),
|
||||
config,
|
||||
authProvider,
|
||||
});
|
||||
|
||||
expect(engine).toBeDefined();
|
||||
});
|
||||
|
||||
it('should throw error when using authProvider with aws provider', async () => {
|
||||
const config = new ConfigReader({
|
||||
search: {
|
||||
|
||||
Reference in New Issue
Block a user