Skip to content

Commit

Permalink
Fixed migration issue for case specific actions, by extending email a…
Browse files Browse the repository at this point in the history
…ction migrator checks (#81673) (#81699)

* Fixed migration issue for case specific actions, by extending email action migrator checks

* Fixed e2e test

* fixed due to comments
  • Loading branch information
YulNaumenko authored Oct 27, 2020
1 parent 6f1d902 commit 6b2a9b3
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 20 deletions.
12 changes: 10 additions & 2 deletions x-pack/plugins/actions/server/saved_objects/migrations.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,11 @@ describe('7.10.0', () => {
test('add hasAuth config property for .email actions', () => {
const migration710 = getMigrations(encryptedSavedObjectsSetup)['7.10.0'];
const action = getMockDataForEmail({});
expect(migration710(action, context)).toMatchObject({
const migratedAction = migration710(action, context);
expect(migratedAction.attributes.config).toEqual({
hasAuth: true,
});
expect(migratedAction).toEqual({
...action,
attributes: {
...action.attributes,
Expand All @@ -38,7 +42,11 @@ describe('7.10.0', () => {
test('rename cases configuration object', () => {
const migration710 = getMigrations(encryptedSavedObjectsSetup)['7.10.0'];
const action = getMockData({});
expect(migration710(action, context)).toMatchObject({
const migratedAction = migration710(action, context);
expect(migratedAction.attributes.config).toEqual({
incidentConfiguration: { mapping: [] },
});
expect(migratedAction).toEqual({
...action,
attributes: {
...action.attributes,
Expand Down
3 changes: 3 additions & 0 deletions x-pack/plugins/actions/server/saved_objects/migrations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ function renameCasesConfigurationObject(
const addHasAuthConfigurationObject = (
doc: SavedObjectUnsanitizedDoc<RawAction>
): SavedObjectUnsanitizedDoc<RawAction> => {
if (doc.attributes.actionTypeId !== '.email') {
return doc;
}
const hasAuth = !!doc.attributes.secrets.user || !!doc.attributes.secrets.password;
return {
...doc,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,24 +30,29 @@ export default function createGetTests({ getService }: FtrProviderContext) {
expect(response.status).to.eql(200);
expect(response.body.config).key('incidentConfiguration');
expect(response.body.config).not.key('casesConfiguration');
expect(response.body.config.incidentConfiguration).to.eql({
mapping: [
{
actionType: 'overwrite',
source: 'title',
target: 'summary',
},
{
actionType: 'overwrite',
source: 'description',
target: 'description',
},
{
actionType: 'append',
source: 'comments',
target: 'comments',
},
],
expect(response.body.config).to.eql({
apiUrl:
'http://elastic:changeme@localhost:5620/api/_actions-FTS-external-service-simulators/jira',
incidentConfiguration: {
mapping: [
{
actionType: 'overwrite',
source: 'title',
target: 'summary',
},
{
actionType: 'overwrite',
source: 'description',
target: 'description',
},
{
actionType: 'append',
source: 'comments',
target: 'comments',
},
],
},
projectKey: 'CK',
});
});
});
Expand Down

0 comments on commit 6b2a9b3

Please sign in to comment.