-
Notifications
You must be signed in to change notification settings - Fork 8.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Extended Email action configuration with hasAuth property to identify…
… if the connector require user credentials. Improved UX for Email connector (#78235) * Extended Email action configuration with hasAuth property to identify if the connector require user credentials. Improved UX for Email connector * Fixed failing tests and comments * Fixed type check and reverted logic of Add user and password switch button * Fixed due to the latest design requirenments * Fixed due to review comments
- Loading branch information
1 parent
8406e04
commit 63ff060
Showing
13 changed files
with
345 additions
and
99 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -55,6 +55,7 @@ describe('config validation', () => { | |
const config: Record<string, unknown> = { | ||
service: 'gmail', | ||
from: '[email protected]', | ||
hasAuth: true, | ||
}; | ||
expect(validateConfig(actionType, config)).toEqual({ | ||
...config, | ||
|
@@ -66,6 +67,7 @@ describe('config validation', () => { | |
delete config.service; | ||
config.host = 'elastic.co'; | ||
config.port = 8080; | ||
config.hasAuth = true; | ||
expect(validateConfig(actionType, config)).toEqual({ | ||
...config, | ||
service: null, | ||
|
@@ -233,6 +235,7 @@ describe('execute()', () => { | |
port: 42, | ||
secure: true, | ||
from: '[email protected]', | ||
hasAuth: true, | ||
}; | ||
const secrets: ActionTypeSecretsType = { | ||
user: 'bob', | ||
|
@@ -269,6 +272,7 @@ describe('execute()', () => { | |
"message": "a message to you", | ||
"subject": "the subject", | ||
}, | ||
"hasAuth": true, | ||
"proxySettings": undefined, | ||
"routing": Object { | ||
"bcc": Array [ | ||
|
@@ -298,6 +302,7 @@ describe('execute()', () => { | |
port: 42, | ||
secure: true, | ||
from: '[email protected]', | ||
hasAuth: false, | ||
}; | ||
const secrets: ActionTypeSecretsType = { | ||
user: null, | ||
|
@@ -327,6 +332,7 @@ describe('execute()', () => { | |
"message": "a message to you", | ||
"subject": "the subject", | ||
}, | ||
"hasAuth": false, | ||
"proxySettings": undefined, | ||
"routing": Object { | ||
"bcc": Array [ | ||
|
@@ -356,6 +362,7 @@ describe('execute()', () => { | |
port: 42, | ||
secure: true, | ||
from: '[email protected]', | ||
hasAuth: false, | ||
}; | ||
const secrets: ActionTypeSecretsType = { | ||
user: null, | ||
|
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 |
---|---|---|
|
@@ -64,7 +64,7 @@ describe('send_email module', () => { | |
}); | ||
|
||
test('handles unauthenticated email using not secure host/port', async () => { | ||
const sendEmailOptions = getSendEmailOptions( | ||
const sendEmailOptions = getSendEmailOptionsNoAuth( | ||
{ | ||
transport: { | ||
host: 'example.com', | ||
|
@@ -76,12 +76,7 @@ describe('send_email module', () => { | |
proxyRejectUnauthorizedCertificates: false, | ||
} | ||
); | ||
// @ts-expect-error | ||
delete sendEmailOptions.transport.service; | ||
// @ts-expect-error | ||
delete sendEmailOptions.transport.user; | ||
// @ts-expect-error | ||
delete sendEmailOptions.transport.password; | ||
|
||
const result = await sendEmail(mockLogger, sendEmailOptions); | ||
expect(result).toBe(sendMailMockResult); | ||
expect(createTransportMock.mock.calls[0]).toMatchInlineSnapshot(` | ||
|
@@ -248,5 +243,31 @@ function getSendEmailOptions( | |
password: 'changeme', | ||
}, | ||
proxySettings, | ||
hasAuth: true, | ||
}; | ||
} | ||
|
||
function getSendEmailOptionsNoAuth( | ||
{ content = {}, routing = {}, transport = {} } = {}, | ||
proxySettings?: ProxySettings | ||
) { | ||
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, | ||
}, | ||
proxySettings, | ||
hasAuth: false, | ||
}; | ||
} |
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 |
---|---|---|
|
@@ -43,6 +43,7 @@ describe('connector validation', () => { | |
port: 2323, | ||
host: 'localhost', | ||
test: 'test', | ||
hasAuth: true, | ||
}, | ||
} as EmailActionConnector; | ||
|
||
|
@@ -72,6 +73,7 @@ describe('connector validation', () => { | |
port: 2323, | ||
host: 'localhost', | ||
test: 'test', | ||
hasAuth: false, | ||
}, | ||
} as EmailActionConnector; | ||
|
||
|
@@ -96,6 +98,7 @@ describe('connector validation', () => { | |
name: 'email', | ||
config: { | ||
from: '[email protected]', | ||
hasAuth: true, | ||
}, | ||
} as EmailActionConnector; | ||
|
||
|
@@ -124,6 +127,7 @@ describe('connector validation', () => { | |
port: 2323, | ||
host: 'localhost', | ||
test: 'test', | ||
hasAuth: true, | ||
}, | ||
} as EmailActionConnector; | ||
|
||
|
@@ -152,6 +156,7 @@ describe('connector validation', () => { | |
port: 2323, | ||
host: 'localhost', | ||
test: 'test', | ||
hasAuth: true, | ||
}, | ||
} as EmailActionConnector; | ||
|
||
|
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
Oops, something went wrong.