forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[alerting] removes usage of any throughout Alerting Services code (el…
…astic#64161) This removes unneeded use of `any` throughout: 1. alerting 2. alerting_builtin 3. actions 4. task manager 5. event log It also adds a linting rule that will prevent us from adding more `any` in the future unless an explicit exemption is made.
- Loading branch information
Showing
131 changed files
with
845 additions
and
544 deletions.
There are no files selected for viewing
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
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
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
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
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
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
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
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
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
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
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 |
---|---|---|
|
@@ -30,7 +30,7 @@ const NO_OP_FN = () => {}; | |
|
||
const services = { | ||
log: NO_OP_FN, | ||
callCluster: async (path: string, opts: any) => {}, | ||
callCluster: async (path: string, opts: unknown) => {}, | ||
savedObjectsClient: savedObjectsClientMock.create(), | ||
}; | ||
|
||
|
@@ -52,7 +52,7 @@ describe('actionTypeRegistry.get() works', () => { | |
|
||
describe('config validation', () => { | ||
test('config validation succeeds when config is valid', () => { | ||
const config: Record<string, any> = { | ||
const config: Record<string, unknown> = { | ||
service: 'gmail', | ||
from: '[email protected]', | ||
}; | ||
|
@@ -74,7 +74,7 @@ describe('config validation', () => { | |
}); | ||
|
||
test('config validation fails when config is not valid', () => { | ||
const baseConfig: Record<string, any> = { | ||
const baseConfig: Record<string, unknown> = { | ||
from: '[email protected]', | ||
}; | ||
|
||
|
@@ -177,15 +177,15 @@ describe('config validation', () => { | |
|
||
describe('secrets validation', () => { | ||
test('secrets validation succeeds when secrets is valid', () => { | ||
const secrets: Record<string, any> = { | ||
const secrets: Record<string, unknown> = { | ||
user: 'bob', | ||
password: 'supersecret', | ||
}; | ||
expect(validateSecrets(actionType, secrets)).toEqual(secrets); | ||
}); | ||
|
||
test('secrets validation succeeds when secrets props are null/undefined', () => { | ||
const secrets: Record<string, any> = { | ||
const secrets: Record<string, unknown> = { | ||
user: null, | ||
password: null, | ||
}; | ||
|
@@ -197,7 +197,7 @@ describe('secrets validation', () => { | |
|
||
describe('params validation', () => { | ||
test('params validation succeeds when params is valid', () => { | ||
const params: Record<string, any> = { | ||
const params: Record<string, unknown> = { | ||
to: ['[email protected]'], | ||
subject: 'this is a test', | ||
message: 'this is the message', | ||
|
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
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
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
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
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 |
---|---|---|
|
@@ -63,12 +63,15 @@ describe('send_email module', () => { | |
}); | ||
|
||
test('handles unauthenticated email using not secure host/port', async () => { | ||
const sendEmailOptions = getSendEmailOptions(); | ||
const sendEmailOptions = getSendEmailOptions({ | ||
transport: { | ||
host: 'example.com', | ||
port: 1025, | ||
}, | ||
}); | ||
delete sendEmailOptions.transport.service; | ||
delete sendEmailOptions.transport.user; | ||
delete sendEmailOptions.transport.password; | ||
sendEmailOptions.transport.host = 'example.com'; | ||
sendEmailOptions.transport.port = 1025; | ||
const result = await sendEmail(mockLogger, sendEmailOptions); | ||
expect(result).toBe(sendMailMockResult); | ||
expect(createTransportMock.mock.calls[0]).toMatchInlineSnapshot(` | ||
|
@@ -105,13 +108,17 @@ describe('send_email module', () => { | |
}); | ||
|
||
test('handles unauthenticated email using secure host/port', async () => { | ||
const sendEmailOptions = getSendEmailOptions(); | ||
const sendEmailOptions = getSendEmailOptions({ | ||
transport: { | ||
host: 'example.com', | ||
port: 1025, | ||
secure: true, | ||
}, | ||
}); | ||
delete sendEmailOptions.transport.service; | ||
delete sendEmailOptions.transport.user; | ||
delete sendEmailOptions.transport.password; | ||
sendEmailOptions.transport.host = 'example.com'; | ||
sendEmailOptions.transport.port = 1025; | ||
sendEmailOptions.transport.secure = true; | ||
|
||
const result = await sendEmail(mockLogger, sendEmailOptions); | ||
expect(result).toBe(sendMailMockResult); | ||
expect(createTransportMock.mock.calls[0]).toMatchInlineSnapshot(` | ||
|
@@ -154,19 +161,22 @@ describe('send_email module', () => { | |
}); | ||
}); | ||
|
||
function getSendEmailOptions(): any { | ||
function getSendEmailOptions({ content = {}, routing = {}, transport = {} } = {}) { | ||
return { | ||
content: { | ||
...content, | ||
message: 'a message', | ||
subject: 'a subject', | ||
}, | ||
routing: { | ||
...routing, | ||
from: '[email protected]', | ||
to: ['[email protected]'], | ||
cc: ['[email protected]', '[email protected]'], | ||
bcc: [], | ||
}, | ||
transport: { | ||
...transport, | ||
service: 'whatever', | ||
user: 'elastic', | ||
password: 'changeme', | ||
|
Oops, something went wrong.