Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Alerting] Fixes Failing test: X-Pack Alerting API Integration Tests.x-pack/test/alerting_api_integration/security_and_spaces/tests/alerting - alerting api integration security and spaces enabled Alerts do stuff when AAD is broken #84707

Merged
merged 9 commits into from
Dec 7, 2020
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import { FtrProviderContext } from '../../../common/ftr_provider_context';
export default function createDeleteTests({ getService }: FtrProviderContext) {
const supertest = getService('supertest');
const es = getService('legacyEs');
const retry = getService('retry');
const supertestWithoutAuth = getService('supertestWithoutAuth');

describe('delete', () => {
Expand Down Expand Up @@ -301,17 +302,19 @@ export default function createDeleteTests({ getService }: FtrProviderContext) {
.send(getTestAlertData())
.expect(200);

await supertest
.put(
`${getUrlPrefix(space.id)}/api/alerts_fixture/saved_object/alert/${createdAlert.id}`
)
.set('kbn-xsrf', 'foo')
.send({
attributes: {
name: 'bar',
},
})
.expect(200);
await retry.try(async () => {
ymao1 marked this conversation as resolved.
Show resolved Hide resolved
await supertest
.put(
`${getUrlPrefix(space.id)}/api/alerts_fixture/saved_object/alert/${createdAlert.id}`
)
.set('kbn-xsrf', 'foo')
.send({
attributes: {
name: 'bar',
},
})
.expect(200);
});

const response = await supertestWithoutAuth
.delete(`${getUrlPrefix(space.id)}/api/alerts/alert/${createdAlert.id}`)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import {
// eslint-disable-next-line import/no-default-export
export default function createDisableAlertTests({ getService }: FtrProviderContext) {
const es = getService('legacyEs');
const retry = getService('retry');
const supertest = getService('supertest');
const supertestWithoutAuth = getService('supertestWithoutAuth');

Expand Down Expand Up @@ -287,17 +288,19 @@ export default function createDisableAlertTests({ getService }: FtrProviderConte
.expect(200);
objectRemover.add(space.id, createdAlert.id, 'alert', 'alerts');

await supertest
.put(
`${getUrlPrefix(space.id)}/api/alerts_fixture/saved_object/alert/${createdAlert.id}`
)
.set('kbn-xsrf', 'foo')
.send({
attributes: {
name: 'bar',
},
})
.expect(200);
await retry.try(async () => {
await supertest
.put(
`${getUrlPrefix(space.id)}/api/alerts_fixture/saved_object/alert/${createdAlert.id}`
)
.set('kbn-xsrf', 'foo')
.send({
attributes: {
name: 'bar',
},
})
.expect(200);
});

const response = await alertUtils.getDisableRequest(createdAlert.id);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import {
// eslint-disable-next-line import/no-default-export
export default function createEnableAlertTests({ getService }: FtrProviderContext) {
const es = getService('legacyEs');
const retry = getService('retry');
const supertest = getService('supertest');
const supertestWithoutAuth = getService('supertestWithoutAuth');

Expand Down Expand Up @@ -304,17 +305,19 @@ export default function createEnableAlertTests({ getService }: FtrProviderContex
.expect(200);
objectRemover.add(space.id, createdAlert.id, 'alert', 'alerts');

await supertest
.put(
`${getUrlPrefix(space.id)}/api/alerts_fixture/saved_object/alert/${createdAlert.id}`
)
.set('kbn-xsrf', 'foo')
.send({
attributes: {
name: 'bar',
},
})
.expect(200);
await retry.try(async () => {
await supertest
.put(
`${getUrlPrefix(space.id)}/api/alerts_fixture/saved_object/alert/${createdAlert.id}`
)
.set('kbn-xsrf', 'foo')
.send({
attributes: {
name: 'bar',
},
})
.expect(200);
});

const response = await alertUtils.getEnableRequest(createdAlert.id);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,18 @@ export default function eventLogTests({ getService }: FtrProviderContext) {
const alertId = response.body.id;
objectRemover.add(spaceId, alertId, 'alert', 'alerts');

// break AAD
await supertest
.put(`${getUrlPrefix(spaceId)}/api/alerts_fixture/saved_object/alert/${alertId}`)
.set('kbn-xsrf', 'foo')
.send({
attributes: {
name: 'bar',
},
})
.expect(200);
await retry.try(async () => {
// break AAD
await supertest
.put(`${getUrlPrefix(spaceId)}/api/alerts_fixture/saved_object/alert/${alertId}`)
.set('kbn-xsrf', 'foo')
.send({
attributes: {
name: 'bar',
},
})
.expect(200);
});

const events = await retry.try(async () => {
// there can be a successful execute before the error one
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { FtrProviderContext } from '../../../common/ftr_provider_context';

// eslint-disable-next-line import/no-default-export
export default function executionStatusAlertTests({ getService }: FtrProviderContext) {
const retry = getService('retry');
const supertest = getService('supertest');
const spaceId = Spaces[0].id;

Expand All @@ -37,16 +38,18 @@ export default function executionStatusAlertTests({ getService }: FtrProviderCon

let executionStatus = await waitForStatus(alertId, new Set(['ok']), 10000);

// break AAD
await supertest
.put(`${getUrlPrefix(spaceId)}/api/alerts_fixture/saved_object/alert/${alertId}`)
.set('kbn-xsrf', 'foo')
.send({
attributes: {
name: 'bar',
},
})
.expect(200);
await retry.try(async () => {
// break AAD
await supertest
.put(`${getUrlPrefix(spaceId)}/api/alerts_fixture/saved_object/alert/${alertId}`)
.set('kbn-xsrf', 'foo')
.send({
attributes: {
name: 'bar',
},
})
.expect(200);
});

executionStatus = await waitForStatus(alertId, new Set(['error']));
expect(executionStatus.error).to.be.ok();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@ export default function createUpdateTests({ getService }: FtrProviderContext) {
.then((response: SupertestResponse) => response.body);
}

// FLAKY: https://github.com/elastic/kibana/issues/82804
describe.skip('update', () => {
describe('update', () => {
const objectRemover = new ObjectRemover(supertest);

after(() => objectRemover.removeAll());
Expand Down Expand Up @@ -429,17 +428,19 @@ export default function createUpdateTests({ getService }: FtrProviderContext) {
.expect(200);
objectRemover.add(space.id, createdAlert.id, 'alert', 'alerts');

await supertest
.put(
`${getUrlPrefix(space.id)}/api/alerts_fixture/saved_object/alert/${createdAlert.id}`
)
.set('kbn-xsrf', 'foo')
.send({
attributes: {
name: 'bar',
},
})
.expect(200);
await retry.try(async () => {
await supertest
.put(
`${getUrlPrefix(space.id)}/api/alerts_fixture/saved_object/alert/${createdAlert.id}`
)
.set('kbn-xsrf', 'foo')
.send({
attributes: {
name: 'bar',
},
})
.expect(200);
});

const updatedData = {
name: 'bcd',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import {

// eslint-disable-next-line import/no-default-export
export default function createUpdateApiKeyTests({ getService }: FtrProviderContext) {
const retry = getService('retry');
const supertest = getService('supertest');
const supertestWithoutAuth = getService('supertestWithoutAuth');

Expand Down Expand Up @@ -301,17 +302,19 @@ export default function createUpdateApiKeyTests({ getService }: FtrProviderConte
.expect(200);
objectRemover.add(space.id, createdAlert.id, 'alert', 'alerts');

await supertest
.put(
`${getUrlPrefix(space.id)}/api/alerts_fixture/saved_object/alert/${createdAlert.id}`
)
.set('kbn-xsrf', 'foo')
.send({
attributes: {
name: 'bar',
},
})
.expect(200);
await retry.try(async () => {
await supertest
.put(
`${getUrlPrefix(space.id)}/api/alerts_fixture/saved_object/alert/${createdAlert.id}`
)
.set('kbn-xsrf', 'foo')
.send({
attributes: {
name: 'bar',
},
})
.expect(200);
});

const response = await alertUtils.getUpdateApiKeyRequest(createdAlert.id);

Expand Down