Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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 @@ -92,8 +92,6 @@ private static ListMultimap<Class<?>, String> createLegacyRestTestBasePluginUsag
map.put(LegacyRestTestBasePlugin.class, ":x-pack:plugin:transform:qa:multi-cluster-tests-with-security");
map.put(LegacyRestTestBasePlugin.class, ":x-pack:plugin:transform:qa:multi-node-tests");
map.put(LegacyRestTestBasePlugin.class, ":x-pack:plugin:transform:qa:single-node-tests");
map.put(LegacyRestTestBasePlugin.class, ":x-pack:plugin:watcher:qa:rest");
map.put(LegacyRestTestBasePlugin.class, ":x-pack:plugin:watcher:qa:with-security");
return map;
}

Expand Down
56 changes: 53 additions & 3 deletions x-pack/plugin/watcher/build.gradle
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
apply plugin: 'elasticsearch.internal-es-plugin'
apply plugin: 'elasticsearch.internal-cluster-test'
apply plugin: 'elasticsearch.internal-java-rest-test'
apply plugin: 'elasticsearch.internal-yaml-rest-test'
apply plugin: 'elasticsearch.internal-test-artifact'
apply plugin: 'elasticsearch.yaml-rest-compat-test'

esplugin {
name = 'x-pack-watcher'
description = 'Elasticsearch Expanded Pack Plugin - Watcher'
classname ='org.elasticsearch.xpack.watcher.Watcher'
hasNativeController =false
requiresKeystore =false
classname = 'org.elasticsearch.xpack.watcher.Watcher'
hasNativeController = false
requiresKeystore = false
extendedPlugins = ['x-pack-core', 'lang-painless']
}

Expand All @@ -15,6 +20,16 @@ base {

ext.compactProfile = 'full'

restResources {
restApi {
include '_common', 'cluster', 'index', 'indices', 'get', 'nodes', 'search', 'watcher', 'security', 'xpack',
'put_script', 'ingest', 'count', 'xpack'
}
restTests {
includeXpack 'watcher'
}
}

tasks.named("dependencyLicenses").configure {
mapping from: /owasp-java-html-sanitizer.*/, to: 'owasp-java-html-sanitizer'
}
Expand Down Expand Up @@ -44,6 +59,41 @@ dependencies {
testImplementation 'com.google.code.findbugs:jsr305:3.0.2'

internalClusterTestImplementation project(":modules:analysis-common")

javaRestTestImplementation project(':x-pack:qa')
yamlRestTestImplementation project(':x-pack:qa')

clusterModules project(':modules:analysis-common')
clusterModules project(':modules:ingest-common')
clusterModules project(':modules:lang-mustache')
clusterModules project(':modules:lang-painless')
clusterModules project(xpackModule('ilm'))
}

artifacts {
restXpackTests(new File(projectDir, "src/yamlRestTest/resources/rest-api-spec/test"))
}

tasks.named("yamlRestTestV7CompatTransform").configure{ task ->
task.skipTest("mustache/30_search_input/Test search input mustache integration (using request body and rest_total_hits_as_int)", "remove JodaCompatibleDateTime -- ZonedDateTime doesn't output millis/nanos if they're 0 (#78417)")
task.skipTest("mustache/30_search_input/Test search input mustache integration (using request body)", "remove JodaCompatibleDateTime -- ZonedDateTime doesn't output millis/nanos if they're 0 (#78417)")
task.skipTest("mustache/40_search_transform/Test search transform mustache integration (using request body)", "remove JodaCompatibleDateTime -- ZonedDateTime doesn't output millis/nanos if they're 0 (#78417)")
task.skipTest("painless/40_exception/Test painless exceptions are returned when logging a broken response", "Exceptions are no longer thrown from Mustache, but from the transform action itself")
task.replaceKeyInDo("watcher.ack_watch", "xpack-watcher.ack_watch")
task.replaceKeyInDo("watcher.activate_watch", "xpack-watcher.activate_watch")
task.replaceKeyInDo("watcher.deactivate_watch", "xpack-watcher.deactivate_watch")
task.replaceKeyInDo("watcher.delete_watch", "xpack-watcher.delete_watch")
task.replaceKeyInDo("watcher.execute_watch", "xpack-watcher.execute_watch")
task.replaceKeyInDo("watcher.get_watch", "xpack-watcher.get_watch")
task.replaceKeyInDo("watcher.put_watch", "xpack-watcher.put_watch")
task.replaceKeyInDo("watcher.start", "xpack-watcher.start")
task.replaceKeyInDo("watcher.stats", "xpack-watcher.stats")
task.replaceKeyInDo("watcher.stop", "xpack-watcher.stop")

task.addAllowedWarningRegex(".*_xpack/watcher/.* is deprecated.*")
task.addAllowedWarningRegex("\\[types removal\\].*")
task.replaceValueTextByKeyValue("path", "/my_index/my_type/{{ctx.watch_id}}", "/my_index/_doc/{{ctx.watch_id}}",
"Test webhook action with mustache integration")
}

// classes are missing, e.g. com.ibm.icu.lang.UCharacter
Expand Down
Empty file.
6 changes: 0 additions & 6 deletions x-pack/plugin/watcher/qa/common/build.gradle

This file was deleted.

59 changes: 0 additions & 59 deletions x-pack/plugin/watcher/qa/rest/build.gradle

This file was deleted.

39 changes: 0 additions & 39 deletions x-pack/plugin/watcher/qa/with-security/build.gradle

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,11 @@
import org.elasticsearch.client.Response;
import org.elasticsearch.client.ResponseException;
import org.elasticsearch.common.Strings;
import org.elasticsearch.common.settings.SecureString;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.util.concurrent.ThreadContext;
import org.elasticsearch.test.cluster.ElasticsearchCluster;
import org.elasticsearch.test.rest.ObjectPath;
import org.elasticsearch.xcontent.XContentBuilder;
import org.elasticsearch.xcontent.XContentType;
import org.elasticsearch.xpack.watcher.WatcherRestTestCase;
import org.junit.ClassRule;

import java.io.IOException;
import java.util.Map;
Expand All @@ -31,19 +29,12 @@

public class SmokeTestWatcherTestSuiteIT extends WatcherRestTestCase {

private static final String TEST_ADMIN_USERNAME = "test_admin";
private static final String TEST_ADMIN_PASSWORD = "x-pack-test-password";
@ClassRule
public static ElasticsearchCluster cluster = watcherClusterSpec().build();

@Override
protected Settings restClientSettings() {
String token = basicAuthHeaderValue("watcher_manager", new SecureString("x-pack-test-password".toCharArray()));
return Settings.builder().put(ThreadContext.PREFIX + ".Authorization", token).build();
}

@Override
protected Settings restAdminSettings() {
String token = basicAuthHeaderValue(TEST_ADMIN_USERNAME, new SecureString(TEST_ADMIN_PASSWORD.toCharArray()));
return Settings.builder().put(ThreadContext.PREFIX + ".Authorization", token).build();
protected String getTestRestCluster() {
return cluster.getHttpAddresses();
}

@AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/issues/52453")
Expand Down Expand Up @@ -79,8 +70,8 @@ public void testMonitorClusterHealth() throws Exception {
.field("scheme", "http")
.startObject("auth")
.startObject("basic")
.field("username", TEST_ADMIN_USERNAME)
.field("password", TEST_ADMIN_PASSWORD)
.field("username", ADMIN_USER)
.field("password", TEST_PASSWORD)
.endObject()
.endObject()
.endObject()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,12 @@
import org.elasticsearch.client.Response;
import org.elasticsearch.client.ResponseException;
import org.elasticsearch.common.Strings;
import org.elasticsearch.common.settings.SecureString;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.util.concurrent.ThreadContext;
import org.elasticsearch.test.cluster.ElasticsearchCluster;
import org.elasticsearch.test.cluster.util.resource.Resource;
import org.elasticsearch.test.rest.ObjectPath;
import org.elasticsearch.xcontent.XContentBuilder;
import org.elasticsearch.xpack.watcher.WatcherRestTestCase;
import org.junit.Before;
import org.junit.ClassRule;

import java.io.IOException;
import java.util.Map;
Expand All @@ -31,11 +30,19 @@

public class SmokeTestWatcherWithSecurityIT extends WatcherRestTestCase {

private static final String TEST_ADMIN_USERNAME = "test_admin";
private static final String TEST_ADMIN_PASSWORD = "x-pack-test-password";

private String watchId = randomAlphaOfLength(20);

@ClassRule
public static ElasticsearchCluster cluster = watcherClusterSpec().setting("xpack.security.enabled", "true")
.rolesFile(Resource.fromClasspath("roles.yml"))
.user(WATCHER_USER, TEST_PASSWORD, "watcher_manager", false)
.build();

@Override
protected String getTestRestCluster() {
return cluster.getHttpAddresses();
}

@Before
public void beforeTest() throws Exception {
Request deleteRequest = new Request("DELETE", "/my_test_index");
Expand All @@ -53,18 +60,6 @@ public void beforeTest() throws Exception {
adminClient().performRequest(createNotAllowedDoc);
}

@Override
protected Settings restClientSettings() {
String token = basicAuthHeaderValue("watcher_manager", new SecureString("x-pack-test-password".toCharArray()));
return Settings.builder().put(ThreadContext.PREFIX + ".Authorization", token).build();
}

@Override
protected Settings restAdminSettings() {
String token = basicAuthHeaderValue(TEST_ADMIN_USERNAME, new SecureString(TEST_ADMIN_PASSWORD.toCharArray()));
return Settings.builder().put(ThreadContext.PREFIX + ".Authorization", token).build();
}

public void testSearchInputHasPermissions() throws Exception {
try (XContentBuilder builder = jsonBuilder()) {
builder.startObject();
Expand Down
Loading