[8.13] [Synthetics] Change test now trigger route from GET to POST (#177093) (#177369)

# Backport

This will backport the following commits from `main` to `8.13`:
- [[Synthetics] Change test now trigger route from GET to POST
(#177093)](https://github.com/elastic/kibana/pull/177093)

<!--- Backport version: 9.4.3 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Justin
Kambic","email":"jk@elastic.co"},"sourceCommit":{"committedDate":"2024-02-20T19:50:31Z","message":"[Synthetics]
Change test now trigger route from GET to POST (#177093)\n\n##
Summary\r\n\r\nThis route should not be a `GET`. The processing
initiated from this\r\nroute causes persisted data and resource usage,
not mere data retrieval.\r\n\r\n## Testing\r\n\r\n```bash\r\n# on
`main`, this is the route\r\ncurl -X GET
http://localhost:5601/internal/synthetics/service/monitors/trigger/{monitorId}
-u {user}:{pass} \r\n\r\n# on this branch, the route above returns a 404
and you must request like:\r\ncurl -X POST
http://localhost:5601/internal/synthetics/service/monitors/trigger/{monitorId}
-u {user}:{pass} -H \"kbn-xsrf:
true\"\r\n```","sha":"d37909ca07cd2a8e17deaaceda825993ba8884c6","branchLabelMapping":{"^v8.14.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["bug","release_note:fix","Team:obs-ux-infra_services","v8.13.0","v8.14.0"],"title":"[Synthetics]
Change test now trigger route from GET to
POST","number":177093,"url":"https://github.com/elastic/kibana/pull/177093","mergeCommit":{"message":"[Synthetics]
Change test now trigger route from GET to POST (#177093)\n\n##
Summary\r\n\r\nThis route should not be a `GET`. The processing
initiated from this\r\nroute causes persisted data and resource usage,
not mere data retrieval.\r\n\r\n## Testing\r\n\r\n```bash\r\n# on
`main`, this is the route\r\ncurl -X GET
http://localhost:5601/internal/synthetics/service/monitors/trigger/{monitorId}
-u {user}:{pass} \r\n\r\n# on this branch, the route above returns a 404
and you must request like:\r\ncurl -X POST
http://localhost:5601/internal/synthetics/service/monitors/trigger/{monitorId}
-u {user}:{pass} -H \"kbn-xsrf:
true\"\r\n```","sha":"d37909ca07cd2a8e17deaaceda825993ba8884c6"}},"sourceBranch":"main","suggestedTargetBranches":["8.13"],"targetPullRequestStates":[{"branch":"8.13","label":"v8.13.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v8.14.0","branchLabelMappingKey":"^v8.14.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/177093","number":177093,"mergeCommit":{"message":"[Synthetics]
Change test now trigger route from GET to POST (#177093)\n\n##
Summary\r\n\r\nThis route should not be a `GET`. The processing
initiated from this\r\nroute causes persisted data and resource usage,
not mere data retrieval.\r\n\r\n## Testing\r\n\r\n```bash\r\n# on
`main`, this is the route\r\ncurl -X GET
http://localhost:5601/internal/synthetics/service/monitors/trigger/{monitorId}
-u {user}:{pass} \r\n\r\n# on this branch, the route above returns a 404
and you must request like:\r\ncurl -X POST
http://localhost:5601/internal/synthetics/service/monitors/trigger/{monitorId}
-u {user}:{pass} -H \"kbn-xsrf:
true\"\r\n```","sha":"d37909ca07cd2a8e17deaaceda825993ba8884c6"}}]}]
BACKPORT-->

Co-authored-by: Justin Kambic <jk@elastic.co>
This commit is contained in:
Kibana Machine 2024-02-20 16:11:51 -05:00 committed by GitHub
parent cb47f76b74
commit 876a3bfe74
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 4 additions and 4 deletions

View file

@ -16,7 +16,7 @@ export const triggerTestNowMonitor = async ({
configId: string;
name: string;
}): Promise<TestNowResponse | undefined> => {
return await apiService.get(SYNTHETICS_API_URLS.TRIGGER_MONITOR + `/${configId}`);
return await apiService.post(SYNTHETICS_API_URLS.TRIGGER_MONITOR + `/${configId}`);
};
export const runOnceMonitor = async ({

View file

@ -16,7 +16,7 @@ import { SYNTHETICS_API_URLS } from '../../../common/constants';
import { normalizeSecrets } from '../../synthetics_service/utils/secrets';
export const testNowMonitorRoute: SyntheticsRestApiRouteFactory<TestNowResponse> = () => ({
method: 'GET',
method: 'POST',
path: SYNTHETICS_API_URLS.TRIGGER_MONITOR + '/{monitorId}',
validate: {
params: schema.object({

View file

@ -38,7 +38,7 @@ export default function ({ getService }: FtrProviderContext) {
const resp = await monitorTestService.addMonitor(newMonitor);
const res = await supertest
.get(SYNTHETICS_API_URLS.TRIGGER_MONITOR + `/${resp.id}`)
.post(SYNTHETICS_API_URLS.TRIGGER_MONITOR + `/${resp.id}`)
.set('kbn-xsrf', 'true')
.expect(200);
@ -79,7 +79,7 @@ export default function ({ getService }: FtrProviderContext) {
.expect(200);
const res = await supertest
.get(`/s/${SPACE_ID}${SYNTHETICS_API_URLS.TRIGGER_MONITOR}/${resp.body.id}`)
.post(`/s/${SPACE_ID}${SYNTHETICS_API_URLS.TRIGGER_MONITOR}/${resp.body.id}`)
.set('kbn-xsrf', 'true')
.expect(200);