Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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 @@ -59,9 +59,6 @@ private static ListMultimap<Class<?>, String> createLegacyRestTestBasePluginUsag
map.put(LegacyRestTestBasePlugin.class, ":x-pack:plugin:deprecation:qa:early-deprecation-rest");
map.put(LegacyRestTestBasePlugin.class, ":x-pack:plugin:deprecation:qa:rest");
map.put(LegacyRestTestBasePlugin.class, ":x-pack:plugin:downsample:qa:with-security");
map.put(LegacyRestTestBasePlugin.class, ":x-pack:plugin:enrich:qa:rest");
map.put(LegacyRestTestBasePlugin.class, ":x-pack:plugin:enrich:qa:rest-with-advanced-security");
map.put(LegacyRestTestBasePlugin.class, ":x-pack:plugin:enrich:qa:rest-with-security");
map.put(LegacyRestTestBasePlugin.class, ":x-pack:plugin:ent-search:qa:rest");
map.put(LegacyRestTestBasePlugin.class, ":x-pack:plugin:eql:qa:ccs-rolling-upgrade");
map.put(LegacyRestTestBasePlugin.class, ":x-pack:plugin:eql:qa:correctness");
Expand Down
23 changes: 22 additions & 1 deletion x-pack/plugin/enrich/build.gradle
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
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'

esplugin {
name = 'x-pack-enrich'
description = 'Elasticsearch Expanded Pack Plugin - Enrich'
classname ='org.elasticsearch.xpack.enrich.EnrichPlugin'
classname = 'org.elasticsearch.xpack.enrich.EnrichPlugin'
extendedPlugins = ['x-pack-core']
}
base {
Expand All @@ -20,6 +23,24 @@ dependencies {
testImplementation project(xpackModule('spatial'))
testImplementation(testArtifact(project(xpackModule('monitoring'))))
internalClusterTestImplementation project(':modules:rest-root')

clusterModules project(':modules:analysis-common')
clusterModules project(':modules:ingest-common')
clusterModules project(':modules:mapper-extras')

clusterModules project(xpackModule('monitoring'))
clusterModules project(xpackModule('ilm'))
clusterModules project(xpackModule('wildcard'))
}

addQaCheckDependencies(project)
Copy link
Contributor

Choose a reason for hiding this comment

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

We can remove this since we've gotten rid of the QA projects.


restResources {
restApi {
include '_common', 'bulk', 'indices', 'index', 'ingest.delete_pipeline', 'ingest.put_pipeline', 'enrich', 'get', 'capabilities'
}
restTests {
includeXpack 'enrich'
}
}

Empty file.
5 changes: 0 additions & 5 deletions x-pack/plugin/enrich/qa/common/build.gradle

This file was deleted.

23 changes: 0 additions & 23 deletions x-pack/plugin/enrich/qa/rest-with-advanced-security/build.gradle

This file was deleted.

28 changes: 0 additions & 28 deletions x-pack/plugin/enrich/qa/rest-with-security/build.gradle

This file was deleted.

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

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,14 @@
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.common.xcontent.XContentHelper;
import org.elasticsearch.common.xcontent.support.XContentMapValues;
import org.elasticsearch.index.query.QueryBuilders;
import org.elasticsearch.test.cluster.ElasticsearchCluster;
import org.elasticsearch.test.cluster.local.LocalClusterSpecBuilder;
import org.elasticsearch.test.rest.ESRestTestCase;
import org.elasticsearch.xcontent.XContentBuilder;
import org.elasticsearch.xcontent.json.JsonXContent;
Expand All @@ -34,6 +38,27 @@

public abstract class CommonEnrichRestTestCase extends ESRestTestCase {

static LocalClusterSpecBuilder<ElasticsearchCluster> enrichCluster(String license, boolean isSecurityEnabled) {
return ElasticsearchCluster.local()
.module("analysis-common")
.module("ingest-common")
.module("mapper-extras")
.module("x-pack-enrich")
.module("x-pack-monitoring")
.module("x-pack-ilm")
.module("wildcard")
.setting("xpack.security.enabled", Boolean.toString(isSecurityEnabled))
.setting("xpack.license.self_generated.type", license)
// silence stats collector errors (we don't want to add all xpack modules here)
.setting("logger.org.elasticsearch.xpack.monitoring.collector", "fatal")
.setting("xpack.monitoring.collection.enabled", "true");
}

static Settings authRequestHeaderSetting(String user, String password) {
String token = basicAuthHeaderValue(user, new SecureString(password.toCharArray()));
return Settings.builder().put(ThreadContext.PREFIX + ".Authorization", token).build();
}

private List<String> cleanupPipelines = new ArrayList<>();

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/
package org.elasticsearch.xpack.enrich;
package org.elasticsearch.test.enrich;

import org.elasticsearch.client.Request;
import org.elasticsearch.common.settings.SecureString;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.util.concurrent.ThreadContext;
import org.elasticsearch.test.enrich.CommonEnrichRestTestCase;
import org.elasticsearch.test.cluster.ElasticsearchCluster;
import org.elasticsearch.test.cluster.util.resource.Resource;
import org.junit.ClassRule;

import java.io.IOException;
import java.util.Map;
Expand All @@ -20,16 +20,29 @@

public class EnrichAdvancedSecurityIT extends CommonEnrichRestTestCase {

public static final String ADMIN_USER = "test_admin";
public static final String ENRICH_USER = "test_enrich";
public static final String TEST_PASSWORD = "x-pack-test-password";

@ClassRule
public static ElasticsearchCluster cluster = enrichCluster("trial", true).rolesFile(Resource.fromClasspath("advanced_roles.yml"))
.user(ADMIN_USER, TEST_PASSWORD, "superuser", true)
.user(ENRICH_USER, TEST_PASSWORD, "integ_test_role", false)
.build();

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

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

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

public void testEnrichEnforcesDLS() throws IOException {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/
package org.elasticsearch.test.enrich;

import org.elasticsearch.test.cluster.ElasticsearchCluster;
import org.junit.ClassRule;

public class EnrichIT extends CommonEnrichRestTestCase {
@ClassRule
public static ElasticsearchCluster cluster = enrichCluster("basic", false).build();

@Override
protected String getTestRestCluster() {
return cluster.getHttpAddresses();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,30 +4,42 @@
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/
package org.elasticsearch.xpack.enrich;
package org.elasticsearch.test.enrich;

import org.elasticsearch.client.Request;
import org.elasticsearch.client.ResponseException;
import org.elasticsearch.common.settings.SecureString;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.util.concurrent.ThreadContext;
import org.elasticsearch.test.enrich.CommonEnrichRestTestCase;
import org.elasticsearch.test.cluster.ElasticsearchCluster;
import org.elasticsearch.test.cluster.util.resource.Resource;
import org.elasticsearch.test.rest.ESRestTestCase;

import static org.elasticsearch.xpack.core.security.authc.support.UsernamePasswordToken.basicAuthHeaderValue;
import org.junit.ClassRule;

public class EnrichSecurityFailureIT extends ESRestTestCase {

public static final String ADMIN_USER = "test_admin";
public static final String ENRICH_USER = "test_enrich_no_privs";
public static final String TEST_PASSWORD = "x-pack-test-password";

@ClassRule
public static ElasticsearchCluster cluster = CommonEnrichRestTestCase.enrichCluster("basic", true)
.rolesFile(Resource.fromClasspath("roles.yml"))
.user(ADMIN_USER, TEST_PASSWORD, "superuser", true)
.user(ENRICH_USER, TEST_PASSWORD, "enrich_no_privs", false)
.build();

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

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

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

public void testFailure() throws Exception {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,30 +4,43 @@
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/
package org.elasticsearch.xpack.enrich;
package org.elasticsearch.test.enrich;

import org.elasticsearch.client.Request;
import org.elasticsearch.client.ResponseException;
import org.elasticsearch.common.settings.SecureString;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.util.concurrent.ThreadContext;
import org.elasticsearch.core.Strings;
import org.elasticsearch.test.enrich.CommonEnrichRestTestCase;
import org.elasticsearch.test.cluster.ElasticsearchCluster;
import org.elasticsearch.test.cluster.util.resource.Resource;
import org.junit.ClassRule;

import static org.hamcrest.CoreMatchers.containsString;

public class EnrichSecurityIT extends CommonEnrichRestTestCase {

public static final String ADMIN_USER = "test_admin";
public static final String ENRICH_USER = "test_enrich";
public static final String TEST_PASSWORD = "x-pack-test-password";

@ClassRule
public static ElasticsearchCluster cluster = enrichCluster("basic", true).rolesFile(Resource.fromClasspath("roles.yml"))
.user(ADMIN_USER, TEST_PASSWORD, "superuser", true)
.user(ENRICH_USER, TEST_PASSWORD, "enrich_user,integ_test_role", false)
.build();

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

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

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

public void testInsufficientPermissionsOnNonExistentIndex() throws Exception {
Expand Down
Loading