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

Serve static assets from NP #60490

Merged
merged 24 commits into from
Mar 27, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
a3cc842
Merge branch 'master' into issue-50654-http-resources-service
mshustov Mar 18, 2020
9bb4937
add hapi.inert plugin to NP
mshustov Mar 18, 2020
aaafdc6
update tests
mshustov Mar 18, 2020
475a5c3
move serving static assets
mshustov Mar 18, 2020
6aa6e56
update tests
mshustov Mar 18, 2020
fabb201
add functional tests
mshustov Mar 18, 2020
a2394df
fix type errors. Hapi.Request doesn't support typings for payload
mshustov Mar 18, 2020
e03576a
update docs
mshustov Mar 18, 2020
05e026c
remove comment
mshustov Mar 18, 2020
0dec6ca
move assets to NP
mshustov Mar 18, 2020
048c385
update all assets references
mshustov Mar 18, 2020
70e9ffc
Merge branch 'master' into issue-50654-http-resources-service
mshustov Mar 19, 2020
dc10e99
address Spencer's comments
mshustov Mar 19, 2020
3d7dcb0
move ui settings migration to migration examples
mshustov Mar 19, 2020
862d230
document legacy plugin spec
mshustov Mar 19, 2020
d0678c9
Merge branch 'master' into issue-50654-http-resources-service
mshustov Mar 20, 2020
3021e43
move platform assets test to integration_tests
mshustov Mar 20, 2020
59759d7
address Spencer's comment p.2
mshustov Mar 20, 2020
753f2c4
try to fix type errors
mshustov Mar 20, 2020
38fb7be
Merge branch 'master' into issue-50654-http-resources-service
mshustov Mar 24, 2020
9912b9a
fix merge commit
mshustov Mar 24, 2020
30effed
Merge branch 'master' into issue-50654-http-resources-service
mshustov Mar 27, 2020
ce9fbb5
Merge branch 'master' into issue-50654-http-resources-service
mshustov Mar 27, 2020
4aad487
update tests
mshustov Mar 27, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export default function createActionTests({ getService }: FtrProviderContext) {
},
});

expect(response.statusCode).to.eql(200);
expect(response.status).to.eql(200);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That should be in a separate PR, but I don't want to spend more time on it.

objectRemover.add(Spaces.space1.id, response.body.id, 'action');
expect(response.body).to.eql({
id: response.body.id,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export default function({ getService }: FtrProviderContext) {
},
});

expect(response.statusCode).to.eql(200);
expect(response.status).to.eql(200);
expect(response.body).to.be.an('object');
const searchResult = await esTestIndexTool.search('action:test.index-record', reference);
expect(searchResult.hits.total.value).to.eql(1);
Expand Down Expand Up @@ -110,7 +110,7 @@ export default function({ getService }: FtrProviderContext) {
},
});

expect(response.statusCode).to.eql(200);
expect(response.status).to.eql(200);
expect(response.body).to.eql({
actionId: createdAction.id,
status: 'error',
Expand Down Expand Up @@ -180,7 +180,7 @@ export default function({ getService }: FtrProviderContext) {
},
});

expect(response.statusCode).to.eql(200);
expect(response.status).to.eql(200);
const searchResult = await esTestIndexTool.search('action:test.authorization', reference);
expect(searchResult.hits.total.value).to.eql(1);
const indexedRecord = searchResult.hits.hits[0];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export default function listActionTypesTests({ getService }: FtrProviderContext)
};
}

expect(response.statusCode).to.eql(200);
expect(response.status).to.eql(200);
// Check for values explicitly in order to avoid this test failing each time plugins register
// a new action type
expect(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export default function typeNotEnabledTests({ getService }: FtrProviderContext)
actionTypeId: DISABLED_ACTION_TYPE,
});

expect(response.statusCode).to.eql(400);
expect(response.status).to.eql(400);
expect(response.body).to.eql({
statusCode: 400,
error: 'Bad Request',
Expand All @@ -46,7 +46,7 @@ export default function typeNotEnabledTests({ getService }: FtrProviderContext)
params: {},
});

expect(response.statusCode).to.eql(200);
expect(response.status).to.eql(200);
expect(response.body).to.eql({
status: 'error',
retry: false,
Expand All @@ -59,7 +59,7 @@ export default function typeNotEnabledTests({ getService }: FtrProviderContext)
it('should handle get action request with disabled actionType appropriately', async () => {
const response = await supertest.get(`/api/action/${PREWRITTEN_ACTION_ID}`);

expect(response.statusCode).to.eql(200);
expect(response.status).to.eql(200);
expect(response.body).to.eql({
actionTypeId: 'test.not-enabled',
config: {},
Expand All @@ -76,7 +76,7 @@ export default function typeNotEnabledTests({ getService }: FtrProviderContext)
name: 'an action created before test.not-enabled was disabled (updated)',
});

expect(responseUpdate.statusCode).to.eql(200);
expect(responseUpdate.status).to.eql(200);
expect(responseUpdate.body).to.eql({
actionTypeId: 'test.not-enabled',
config: {},
Expand All @@ -85,7 +85,7 @@ export default function typeNotEnabledTests({ getService }: FtrProviderContext)
});

const response = await supertest.get(`/api/action/${PREWRITTEN_ACTION_ID}`);
expect(response.statusCode).to.eql(200);
expect(response.status).to.eql(200);
expect(response.body).to.eql({
actionTypeId: 'test.not-enabled',
config: {},
Expand All @@ -100,10 +100,10 @@ export default function typeNotEnabledTests({ getService }: FtrProviderContext)
response = await supertest
.delete(`/api/action/${PREWRITTEN_ACTION_ID}`)
.set('kbn-xsrf', 'foo');
expect(response.statusCode).to.eql(204);
expect(response.status).to.eql(204);

response = await supertest.get(`/api/action/${PREWRITTEN_ACTION_ID}`);
expect(response.statusCode).to.eql(404);
expect(response.status).to.eql(404);
});
});
}
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ export default function alertTests({ getService }: FtrProviderContext) {
},
};

const { statusCode, body: createdAlert } = await supertest
const { status, body: createdAlert } = await supertest
.post(`${getUrlPrefix(Spaces.space1.id)}/api/alert`)
.set('kbn-xsrf', 'foo')
.send({
Expand Down Expand Up @@ -363,7 +363,7 @@ export default function alertTests({ getService }: FtrProviderContext) {
// will print the error body, if an error occurred
// if (statusCode !== 200) console.log(createdAlert);

expect(statusCode).to.be(200);
expect(status).to.be(200);

const alertId = createdAlert.id;
objectRemover.add(Spaces.space1.id, alertId, 'alert');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export default function createAlertTests({ getService }: FtrProviderContext) {
})
);

expect(response.statusCode).to.eql(200);
expect(response.status).to.eql(200);
objectRemover.add(Spaces.space1.id, response.body.id, 'alert');
expect(response.body).to.eql({
id: response.body.id,
Expand Down Expand Up @@ -108,7 +108,7 @@ export default function createAlertTests({ getService }: FtrProviderContext) {
.set('kbn-xsrf', 'foo')
.send(getTestAlertData({ enabled: false }));

expect(response.statusCode).to.eql(200);
expect(response.status).to.eql(200);
objectRemover.add(Spaces.space1.id, response.body.id, 'alert');
expect(response.body.scheduledTaskId).to.eql(undefined);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export default function createFindTests({ getService }: FtrProviderContext) {
)}/api/alert/_find?search=test.noop&search_fields=alertTypeId`
);

expect(response.statusCode).to.eql(200);
expect(response.status).to.eql(200);
expect(response.body.page).to.equal(1);
expect(response.body.perPage).to.be.greaterThan(0);
expect(response.body.total).to.be.greaterThan(0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export default function createGetTests({ getService }: FtrProviderContext) {
`${getUrlPrefix(Spaces.space1.id)}/api/alert/${createdAlert.id}`
);

expect(response.statusCode).to.eql(200);
expect(response.status).to.eql(200);
expect(response.body).to.eql({
id: createdAlert.id,
name: 'abc',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export default function createGetAlertStateTests({ getService }: FtrProviderCont
`${getUrlPrefix(Spaces.space1.id)}/api/alert/${createdAlert.id}/state`
);

expect(response.statusCode).to.eql(200);
expect(response.status).to.eql(200);
expect(response.body).to.key('alertInstances', 'previousStartedAt');
});

Expand Down Expand Up @@ -59,7 +59,7 @@ export default function createGetAlertStateTests({ getService }: FtrProviderCont
`${getUrlPrefix(Spaces.space1.id)}/api/alert/${createdAlert.id}/state`
);

expect(response.statusCode).to.eql(200);
expect(response.status).to.eql(200);
expect(response.body).to.key('alertInstances', 'alertTypeState', 'previousStartedAt');
expect(response.body.alertTypeState.runCount).to.greaterThan(1);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export default function listAlertTypes({ getService }: FtrProviderContext) {
describe('list_alert_types', () => {
it('should return 200 with list of alert types', async () => {
const response = await supertest.get(`${getUrlPrefix(Spaces.space1.id)}/api/alert/types`);
expect(response.statusCode).to.eql(200);
expect(response.status).to.eql(200);
const fixtureAlertType = response.body.find((alertType: any) => alertType.id === 'test.noop');
expect(fixtureAlertType).to.eql({
actionGroups: [{ id: 'default', name: 'Default' }],
Expand All @@ -32,7 +32,7 @@ export default function listAlertTypes({ getService }: FtrProviderContext) {

it('should return actionVariables with both context and state', async () => {
const response = await supertest.get(`${getUrlPrefix(Spaces.space1.id)}/api/alert/types`);
expect(response.statusCode).to.eql(200);
expect(response.status).to.eql(200);

const fixtureAlertType = response.body.find(
(alertType: any) => alertType.id === 'test.always-firing'
Expand All @@ -46,7 +46,7 @@ export default function listAlertTypes({ getService }: FtrProviderContext) {

it('should return actionVariables with just context', async () => {
const response = await supertest.get(`${getUrlPrefix(Spaces.space1.id)}/api/alert/types`);
expect(response.statusCode).to.eql(200);
expect(response.status).to.eql(200);

const fixtureAlertType = response.body.find(
(alertType: any) => alertType.id === 'test.onlyContextVariables'
Expand All @@ -60,7 +60,7 @@ export default function listAlertTypes({ getService }: FtrProviderContext) {

it('should return actionVariables with just state', async () => {
const response = await supertest.get(`${getUrlPrefix(Spaces.space1.id)}/api/alert/types`);
expect(response.statusCode).to.eql(200);
expect(response.status).to.eql(200);

const fixtureAlertType = response.body.find(
(alertType: any) => alertType.id === 'test.onlyStateVariables'
Expand Down
16 changes: 8 additions & 8 deletions x-pack/test/api_integration/apis/apm/agent_configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,25 +83,25 @@ export default function agentConfigurationTests({ getService }: FtrProviderConte
});

it('can find the created config', async () => {
const { statusCode, body } = await searchConfigurations(searchParams);
expect(statusCode).to.equal(200);
const { status, body } = await searchConfigurations(searchParams);
expect(status).to.equal(200);
expect(body._source.service).to.eql({});
expect(body._source.settings).to.eql({ transaction_sample_rate: 0.55 });
});

it('can update the created config', async () => {
await updateConfiguration({ service: {}, settings: { transaction_sample_rate: 0.85 } });

const { statusCode, body } = await searchConfigurations(searchParams);
expect(statusCode).to.equal(200);
const { status, body } = await searchConfigurations(searchParams);
expect(status).to.equal(200);
expect(body._source.service).to.eql({});
expect(body._source.settings).to.eql({ transaction_sample_rate: 0.85 });
});

it('can delete the created config', async () => {
await deleteConfiguration(newConfig);
const { statusCode } = await searchConfigurations(searchParams);
expect(statusCode).to.equal(404);
const { status } = await searchConfigurations(searchParams);
expect(status).to.equal(404);
});
});

Expand Down Expand Up @@ -166,12 +166,12 @@ export default function agentConfigurationTests({ getService }: FtrProviderConte

for (const agentRequest of agentsRequests) {
it(`${agentRequest.service.name} / ${agentRequest.service.environment}`, async () => {
const { statusCode, body } = await searchConfigurations({
const { status, body } = await searchConfigurations({
service: agentRequest.service,
etag: 'abc',
});

expect(statusCode).to.equal(200);
expect(status).to.equal(200);
expect(body._source.settings).to.eql(agentRequest.expectedSettings);
});
}
Expand Down
12 changes: 6 additions & 6 deletions x-pack/test/api_integration/apis/apm/feature_controls.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,8 @@ export default function featureControlsTests({ getService }: FtrProviderContext)

async function executeAsAdmin({ method = 'get', url, body }: Endpoint['req'], spaceId?: string) {
const basePath = spaceId ? `/s/${spaceId}` : '';

let request = supertest[method](`${basePath}${url}`);
const fullPath = `${basePath}${url}`;
let request = supertest[method](fullPath);

// json body
if (body) {
Expand All @@ -192,10 +192,10 @@ export default function featureControlsTests({ getService }: FtrProviderContext)

const response = await request.set('kbn-xsrf', 'foo');

const { statusCode, req } = response;
if (statusCode !== 200) {
throw new Error(`Endpoint: ${req.method} ${req.path}
Status code: ${statusCode}
const { status } = response;
if (status !== 200) {
throw new Error(`Endpoint: ${method} ${fullPath}
Status code: ${status}
Response: ${response.body.message}`);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ export default ({ getService }: FtrProviderContext): void => {
const { body } = await supertest
.delete(`${DETECTION_ENGINE_RULES_URL}?rule_id=rule-1`)
.set('kbn-xsrf', 'true')
.query()
.expect(200);

const bodyToCompare = removeServerGeneratedProperties(body);
Expand All @@ -67,7 +66,6 @@ export default ({ getService }: FtrProviderContext): void => {
const { body } = await supertest
.delete(`${DETECTION_ENGINE_RULES_URL}?rule_id=${bodyWithCreatedRule.rule_id}`)
.set('kbn-xsrf', 'true')
.query()
.expect(200);

const bodyToCompare = removeServerGeneratedPropertiesIncludingRuleId(body);
Expand All @@ -86,7 +84,6 @@ export default ({ getService }: FtrProviderContext): void => {
const { body } = await supertest
.delete(`${DETECTION_ENGINE_RULES_URL}?id=${bodyWithCreatedRule.id}`)
.set('kbn-xsrf', 'true')
.query()
.expect(200);

const bodyToCompare = removeServerGeneratedPropertiesIncludingRuleId(body);
Expand All @@ -97,7 +94,6 @@ export default ({ getService }: FtrProviderContext): void => {
const { body } = await supertest
.delete(`${DETECTION_ENGINE_RULES_URL}?id=fake_id`)
.set('kbn-xsrf', 'true')
.query()
.expect(404);

expect(body).to.eql({
Expand All @@ -110,7 +106,6 @@ export default ({ getService }: FtrProviderContext): void => {
const { body } = await supertest
.delete(`${DETECTION_ENGINE_RULES_URL}?rule_id=fake_id`)
.set('kbn-xsrf', 'true')
.query()
.expect(404);

expect(body).to.eql({
Expand Down
Loading