Search in sources :

Example 1 with RxHttpClient

use of io.micronaut.rxjava2.http.client.RxHttpClient in project kestra by kestra-io.

the class PluginControllerTest method docs.

@SuppressWarnings("unchecked")
@Test
void docs() throws URISyntaxException {
    Helpers.runApplicationContext((applicationContext, embeddedServer) -> {
        RxHttpClient client = RxHttpClient.create(embeddedServer.getURL());
        io.kestra.webserver.controllers.PluginController.Doc doc = client.toBlocking().retrieve(HttpRequest.GET("/api/v1/plugins/io.kestra.plugin.templates.ExampleTask"), io.kestra.webserver.controllers.PluginController.Doc.class);
        assertThat(doc.getMarkdown(), containsString("io.kestra.plugin.templates.ExampleTask"));
        assertThat(((Map<String, Object>) doc.getSchema().getProperties().get("properties")).size(), is(2));
        assertThat(((Map<String, Object>) doc.getSchema().getOutputs().get("properties")).size(), is(1));
    });
}
Also used : RxHttpClient(io.micronaut.rxjava2.http.client.RxHttpClient) Test(org.junit.jupiter.api.Test)

Example 2 with RxHttpClient

use of io.micronaut.rxjava2.http.client.RxHttpClient in project kestra by kestra-io.

the class PluginControllerTest method plugins.

@Test
void plugins() throws URISyntaxException {
    Helpers.runApplicationContext((applicationContext, embeddedServer) -> {
        RxHttpClient client = RxHttpClient.create(embeddedServer.getURL());
        List<io.kestra.webserver.controllers.PluginController.Plugin> list = client.toBlocking().retrieve(HttpRequest.GET("/api/v1/plugins"), Argument.listOf(io.kestra.webserver.controllers.PluginController.Plugin.class));
        assertThat(list.size(), is(2));
        io.kestra.webserver.controllers.PluginController.Plugin template = list.stream().filter(plugin -> plugin.getManifest().get("X-Kestra-Title").equals("plugin-template-test")).findFirst().orElseThrow();
        assertThat(template.getTasks().size(), is(1));
        assertThat(template.getTasks().get(0), is("io.kestra.plugin.templates.ExampleTask"));
        // classLoader can lead to duplicate plugins for the core, just verify that the response is still the same
        list = client.toBlocking().retrieve(HttpRequest.GET("/api/v1/plugins"), Argument.listOf(io.kestra.webserver.controllers.PluginController.Plugin.class));
        assertThat(list.size(), is(2));
    });
}
Also used : RxHttpClient(io.micronaut.rxjava2.http.client.RxHttpClient) Test(org.junit.jupiter.api.Test)

Example 3 with RxHttpClient

use of io.micronaut.rxjava2.http.client.RxHttpClient in project kestra by kestra-io.

the class BasicAuthEndpointsFilterTest method test.

void test(boolean password, BiConsumer<RxHttpClient, MutableHttpRequest<String>> consumer) {
    MapPropertySource mapPropertySource = new MapPropertySource("unittest", password ? Map.of("endpoints.all.enabled", true, "endpoints.all.sensitive", false, "endpoints.all.basic-auth.username", "foo", "endpoints.all.basic-auth.password", "bar") : Map.of("endpoints.all.enabled", true, "endpoints.all.sensitive", false));
    try (ApplicationContext ctx = ApplicationContext.run(mapPropertySource, Environment.CLI, Environment.TEST)) {
        EmbeddedServer embeddedServer = ctx.getBean(EmbeddedServer.class);
        embeddedServer.start();
        RxHttpClient client = ctx.getBean(RxHttpClient.class);
        consumer.accept(client, HttpRequest.GET("http://localhost:" + embeddedServer.getPort() + "/health"));
    }
}
Also used : ApplicationContext(io.micronaut.context.ApplicationContext) MapPropertySource(io.micronaut.context.env.MapPropertySource) RxHttpClient(io.micronaut.rxjava2.http.client.RxHttpClient) EmbeddedServer(io.micronaut.runtime.server.EmbeddedServer)

Example 4 with RxHttpClient

use of io.micronaut.rxjava2.http.client.RxHttpClient in project kestra by kestra-io.

the class PluginControllerTest method bash.

@SuppressWarnings("unchecked")
@Test
void bash() throws URISyntaxException {
    Helpers.runApplicationContext((applicationContext, embeddedServer) -> {
        RxHttpClient client = RxHttpClient.create(embeddedServer.getURL());
        io.kestra.webserver.controllers.PluginController.Doc doc = client.toBlocking().retrieve(HttpRequest.GET("/api/v1/plugins/io.kestra.core.tasks.scripts.Bash"), io.kestra.webserver.controllers.PluginController.Doc.class);
        assertThat(doc.getMarkdown(), containsString("io.kestra.core.tasks.scripts.Bash"));
        assertThat(doc.getMarkdown(), containsString("Exit if any non true return value"));
        assertThat(doc.getMarkdown(), containsString("The standard output line count"));
        assertThat(((Map<String, Object>) doc.getSchema().getProperties().get("properties")).size(), is(12));
        assertThat(((Map<String, Object>) doc.getSchema().getOutputs().get("properties")).size(), is(6));
    });
}
Also used : RxHttpClient(io.micronaut.rxjava2.http.client.RxHttpClient) Test(org.junit.jupiter.api.Test)

Example 5 with RxHttpClient

use of io.micronaut.rxjava2.http.client.RxHttpClient in project kestra by kestra-io.

the class PluginControllerTest method icons.

@Test
void icons() throws URISyntaxException {
    Helpers.runApplicationContext((applicationContext, embeddedServer) -> {
        RxHttpClient client = RxHttpClient.create(embeddedServer.getURL());
        Map<String, io.kestra.webserver.controllers.PluginController.PluginIcon> list = client.toBlocking().retrieve(HttpRequest.GET("/api/v1/plugins/icons"), Argument.mapOf(String.class, io.kestra.webserver.controllers.PluginController.PluginIcon.class));
        assertThat(list.entrySet().stream().filter(e -> e.getKey().equals(Bash.class.getName())).findFirst().orElseThrow().getValue().getIcon(), is(notNullValue()));
    });
}
Also used : Test(org.junit.jupiter.api.Test) List(java.util.List) Bash(io.kestra.core.tasks.scripts.Bash) URISyntaxException(java.net.URISyntaxException) Map(java.util.Map) Matchers(org.hamcrest.Matchers) Argument(io.micronaut.core.type.Argument) HttpRequest(io.micronaut.http.HttpRequest) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) RxHttpClient(io.micronaut.rxjava2.http.client.RxHttpClient) Helpers(io.kestra.core.Helpers) RxHttpClient(io.micronaut.rxjava2.http.client.RxHttpClient) Bash(io.kestra.core.tasks.scripts.Bash) Test(org.junit.jupiter.api.Test)

Aggregations

RxHttpClient (io.micronaut.rxjava2.http.client.RxHttpClient)5 Test (org.junit.jupiter.api.Test)4 Helpers (io.kestra.core.Helpers)1 Bash (io.kestra.core.tasks.scripts.Bash)1 ApplicationContext (io.micronaut.context.ApplicationContext)1 MapPropertySource (io.micronaut.context.env.MapPropertySource)1 Argument (io.micronaut.core.type.Argument)1 HttpRequest (io.micronaut.http.HttpRequest)1 EmbeddedServer (io.micronaut.runtime.server.EmbeddedServer)1 URISyntaxException (java.net.URISyntaxException)1 List (java.util.List)1 Map (java.util.Map)1 MatcherAssert.assertThat (org.hamcrest.MatcherAssert.assertThat)1 Matchers (org.hamcrest.Matchers)1