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
33 changes: 30 additions & 3 deletions x-pack/plugin/watcher/build.gradle
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
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'

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 +19,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 +58,19 @@ 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"))
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@mark-vieira I'm not sure about this change. This folder contains now both specs with and without security, previously it was just the ones without. Is there a way to filter these?

Copy link
Contributor

Choose a reason for hiding this comment

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

No, we expect a 1 project - 1 artifact type mapping here. You can filter them on the consumer side though when setting up your rest test.

}

// 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.

42 changes: 0 additions & 42 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();
}

public void testMonitorClusterHealth() throws Exception {
Expand Down Expand Up @@ -78,8 +69,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
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,16 @@
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/
package org.elasticsearch.xpack.watcher;
package org.elasticsearch.smoketest;

import org.elasticsearch.client.Request;
import org.elasticsearch.client.Response;
import org.elasticsearch.common.settings.SecureString;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.util.concurrent.ThreadContext;
import org.elasticsearch.test.ESTestCase;
import org.elasticsearch.test.cluster.ElasticsearchCluster;
import org.elasticsearch.test.cluster.local.LocalClusterSpecBuilder;
import org.elasticsearch.test.rest.ESRestTestCase;
import org.elasticsearch.test.rest.ObjectPath;
import org.junit.After;
Expand All @@ -26,6 +31,36 @@
*/
public abstract class WatcherRestTestCase extends ESRestTestCase {

static final String ADMIN_USER = "test_admin";
static final String WATCHER_USER = "watcher_manager";
static final String TEST_PASSWORD = "x-pack-test-password";

static LocalClusterSpecBuilder<ElasticsearchCluster> watcherClusterSpec() {
return ElasticsearchCluster.local()
.module("x-pack-watcher")
.module("x-pack-ilm")
.module("ingest-common")
.module("analysis-common")
.module("lang-mustache")
.setting("xpack.ml.enabled", "false")
.setting("xpack.license.self_generated.type", "trial")
.setting("logger.org.elasticsearch.xpack.watcher", "debug")
.setting("logger.org.elasticsearch.xpack.core.watcher", "debug")
.user(ADMIN_USER, TEST_PASSWORD, "superuser", true);
}

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

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

@Before
public final void startWatcher() throws Exception {
ESTestCase.assertBusy(() -> {
Expand Down
Loading