use of io.kestra.core.models.storage.FileMetas in project kestra by kestra-io.
the class ExecutionControllerTest method downloadFile.
@Test
void downloadFile() throws TimeoutException {
Execution execution = runnerUtils.runOne(TESTS_FLOW_NS, "inputs", null, (flow, execution1) -> runnerUtils.typedInputs(flow, execution1, inputs));
assertThat(execution.getTaskRunList(), hasSize(5));
String path = (String) execution.getInputs().get("file");
String file = client.toBlocking().retrieve(HttpRequest.GET("/api/v1/executions/" + execution.getId() + "/file?path=" + path), String.class);
assertThat(file, containsString("micronaut:"));
FileMetas metas = client.retrieve(HttpRequest.GET("/api/v1/executions/" + execution.getId() + "/file/metas?path=" + path), FileMetas.class).blockingFirst();
assertThat(metas.getSize(), equalTo(288L));
String newExecutionId = IdUtils.create();
HttpClientResponseException e = assertThrows(HttpClientResponseException.class, () -> client.toBlocking().retrieve(HttpRequest.GET("/api/v1/executions/" + execution.getId() + "/file?path=" + path.replace(execution.getId(), newExecutionId)), String.class));
// we redirect to good execution (that doesn't exist, so 404)
assertThat(e.getStatus().getCode(), is(404));
assertThat(e.getMessage(), containsString("execution id '" + newExecutionId + "'"));
}
Aggregations