Merge branch 'master' into gh-2200
Original commit: elastic/x-pack-elasticsearch@38629917e1
This commit is contained in:
commit
ab39cab599
|
@ -25,6 +25,7 @@ import org.elasticsearch.script.mustache.MustachePlugin;
|
|||
import org.elasticsearch.search.builder.SearchSourceBuilder;
|
||||
import org.elasticsearch.test.ESIntegTestCase;
|
||||
import org.elasticsearch.test.ESIntegTestCase.ClusterScope;
|
||||
import org.elasticsearch.xpack.common.text.TextTemplate;
|
||||
import org.elasticsearch.xpack.watcher.actions.ActionWrapper;
|
||||
import org.elasticsearch.xpack.watcher.actions.ExecutableActions;
|
||||
import org.elasticsearch.xpack.watcher.condition.always.ExecutableAlwaysCondition;
|
||||
|
@ -36,7 +37,6 @@ import org.elasticsearch.xpack.watcher.input.search.SearchInputFactory;
|
|||
import org.elasticsearch.xpack.watcher.input.simple.ExecutableSimpleInput;
|
||||
import org.elasticsearch.xpack.watcher.input.simple.SimpleInput;
|
||||
import org.elasticsearch.xpack.watcher.support.init.proxy.WatcherClientProxy;
|
||||
import org.elasticsearch.xpack.common.text.TextTemplate;
|
||||
import org.elasticsearch.xpack.watcher.trigger.schedule.IntervalSchedule;
|
||||
import org.elasticsearch.xpack.watcher.trigger.schedule.ScheduleTrigger;
|
||||
import org.elasticsearch.xpack.watcher.trigger.schedule.ScheduleTriggerEvent;
|
||||
|
@ -72,7 +72,8 @@ import static org.joda.time.DateTimeZone.UTC;
|
|||
|
||||
/**
|
||||
*/
|
||||
@ClusterScope(scope = SUITE, numClientNodes = 0, transportClientRatio = 0, randomDynamicTemplates = false, numDataNodes = 1)
|
||||
@ClusterScope(scope = SUITE, numClientNodes = 0, transportClientRatio = 0, randomDynamicTemplates = false, supportsDedicatedMasters = false,
|
||||
numDataNodes = 1)
|
||||
public class SearchInputIT extends ESIntegTestCase {
|
||||
|
||||
@Override
|
||||
|
|
|
@ -30,6 +30,7 @@ import org.elasticsearch.script.mustache.MustachePlugin;
|
|||
import org.elasticsearch.search.builder.SearchSourceBuilder;
|
||||
import org.elasticsearch.test.ESIntegTestCase;
|
||||
import org.elasticsearch.test.ESIntegTestCase.ClusterScope;
|
||||
import org.elasticsearch.xpack.common.text.TextTemplate;
|
||||
import org.elasticsearch.xpack.watcher.actions.ExecutableActions;
|
||||
import org.elasticsearch.xpack.watcher.condition.always.ExecutableAlwaysCondition;
|
||||
import org.elasticsearch.xpack.watcher.execution.TriggeredExecutionContext;
|
||||
|
@ -37,7 +38,6 @@ import org.elasticsearch.xpack.watcher.execution.WatchExecutionContext;
|
|||
import org.elasticsearch.xpack.watcher.input.simple.ExecutableSimpleInput;
|
||||
import org.elasticsearch.xpack.watcher.input.simple.SimpleInput;
|
||||
import org.elasticsearch.xpack.watcher.support.init.proxy.WatcherClientProxy;
|
||||
import org.elasticsearch.xpack.common.text.TextTemplate;
|
||||
import org.elasticsearch.xpack.watcher.transform.Transform;
|
||||
import org.elasticsearch.xpack.watcher.transform.TransformBuilders;
|
||||
import org.elasticsearch.xpack.watcher.transform.search.ExecutableSearchTransform;
|
||||
|
@ -91,7 +91,8 @@ import static org.joda.time.DateTimeZone.UTC;
|
|||
/**
|
||||
*
|
||||
*/
|
||||
@ClusterScope(scope = SUITE, numClientNodes = 0, transportClientRatio = 0, randomDynamicTemplates = false, numDataNodes = 1)
|
||||
@ClusterScope(scope = SUITE, numClientNodes = 0, transportClientRatio = 0, randomDynamicTemplates = false, supportsDedicatedMasters = false,
|
||||
numDataNodes = 1)
|
||||
public class SearchTransformIT extends ESIntegTestCase {
|
||||
|
||||
@Override
|
||||
|
|
|
@ -17,6 +17,7 @@ integTest {
|
|||
plugin 'x-pack', project(':x-plugins:elasticsearch:x-pack')
|
||||
setting 'xpack.security.audit.enabled', 'true'
|
||||
setting 'xpack.security.audit.outputs', 'index'
|
||||
setting 'logger.level', 'DEBUG'
|
||||
setupCommand 'setupDummyUser',
|
||||
'bin/x-pack/users', 'useradd', 'test_user', '-p', 'changeme', '-r', 'superuser'
|
||||
waitCondition = { node, ant ->
|
||||
|
|
|
@ -9,6 +9,7 @@ import com.carrotsearch.hppc.cursors.ObjectCursor;
|
|||
import org.elasticsearch.action.admin.indices.template.delete.DeleteIndexTemplateResponse;
|
||||
import org.elasticsearch.action.admin.indices.template.get.GetIndexTemplatesResponse;
|
||||
import org.elasticsearch.action.search.SearchResponse;
|
||||
import org.elasticsearch.cluster.ClusterState;
|
||||
import org.elasticsearch.cluster.metadata.IndexTemplateMetaData;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.index.query.QueryBuilders;
|
||||
|
@ -24,6 +25,8 @@ import org.elasticsearch.xpack.XPackPlugin;
|
|||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
import static org.hamcrest.Matchers.greaterThan;
|
||||
import static org.hamcrest.Matchers.is;
|
||||
|
@ -33,29 +36,41 @@ public class IndexAuditIT extends ESIntegTestCase {
|
|||
private static final String PASS = "changeme";
|
||||
|
||||
public void testShieldIndexAuditTrailWorking() throws Exception {
|
||||
HttpResponse response = httpClient().path("/_cluster/health")
|
||||
HttpResponse response = httpClient().path("/")
|
||||
.addHeader("Authorization", UsernamePasswordToken.basicAuthHeaderValue(USER, new SecuredString(PASS.toCharArray())))
|
||||
.execute();
|
||||
assertThat(response.getStatusCode(), is(200));
|
||||
|
||||
final AtomicReference<ClusterState> lastClusterState = new AtomicReference<>();
|
||||
final AtomicBoolean indexExists = new AtomicBoolean(false);
|
||||
boolean found = awaitBusy(() -> {
|
||||
boolean exists = false;
|
||||
for (ObjectCursor<String> cursor :
|
||||
client().admin().cluster().prepareState().get().getState().getMetaData().getIndices().keys()) {
|
||||
if (cursor.value.startsWith(".shield_audit_log")) {
|
||||
exists = true;
|
||||
break;
|
||||
if (indexExists.get() == false) {
|
||||
ClusterState state = client().admin().cluster().prepareState().get().getState();
|
||||
lastClusterState.set(state);
|
||||
for (ObjectCursor<String> cursor : state.getMetaData().getIndices().keys()) {
|
||||
if (cursor.value.startsWith(".shield_audit_log")) {
|
||||
logger.info("found audit index [{}]", cursor.value);
|
||||
indexExists.set(true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (indexExists.get() == false) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (exists == false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
ensureYellow(".shield_audit_log*");
|
||||
ClusterState state = client().admin().cluster().prepareState().get().getState();
|
||||
lastClusterState.set(state);
|
||||
client().admin().indices().prepareRefresh().get();
|
||||
return client().prepareSearch(".shield_audit_log*").setQuery(QueryBuilders.matchQuery("principal", USER))
|
||||
.get().getHits().totalHits() > 0;
|
||||
}, 10L, TimeUnit.SECONDS);
|
||||
|
||||
if (!found) {
|
||||
logger.info("current cluster state: {}", lastClusterState.get());
|
||||
}
|
||||
assertThat(found, is(true));
|
||||
|
||||
SearchResponse searchResponse = client().prepareSearch(".shield_audit_log*").setQuery(
|
||||
|
|
|
@ -21,7 +21,7 @@ import static org.elasticsearch.test.ESIntegTestCase.Scope.TEST;
|
|||
|
||||
/**
|
||||
*/
|
||||
@ESIntegTestCase.ClusterScope(scope = TEST, numDataNodes = 10, numClientNodes = 0)
|
||||
@ESIntegTestCase.ClusterScope(scope = TEST, supportsDedicatedMasters = false, numDataNodes = 10, numClientNodes = 0)
|
||||
public class LicensesServiceNodeTests extends AbstractLicensesIntegrationTestCase {
|
||||
|
||||
@Override
|
||||
|
|
|
@ -58,11 +58,19 @@ public class LicensesTransportTests extends ESSingleNodeTestCase {
|
|||
}
|
||||
|
||||
public void testEmptyGetLicense() throws Exception {
|
||||
final ActionFuture<GetLicenseResponse> getLicenseFuture =
|
||||
new GetLicenseRequestBuilder(client().admin().cluster(), GetLicenseAction.INSTANCE).execute();
|
||||
final GetLicenseResponse getLicenseResponse = getLicenseFuture.get();
|
||||
assertNotNull(getLicenseResponse.license());
|
||||
assertThat(getLicenseResponse.license().operationMode(), equalTo(License.OperationMode.TRIAL));
|
||||
// trail license is added async, we should wait for it
|
||||
assertBusy(() -> {
|
||||
try {
|
||||
final ActionFuture<GetLicenseResponse> getLicenseFuture =
|
||||
new GetLicenseRequestBuilder(client().admin().cluster(), GetLicenseAction.INSTANCE).execute();
|
||||
final GetLicenseResponse getLicenseResponse;
|
||||
getLicenseResponse = getLicenseFuture.get();
|
||||
assertNotNull(getLicenseResponse.license());
|
||||
assertThat(getLicenseResponse.license().operationMode(), equalTo(License.OperationMode.TRIAL));
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("unexpected exception", e);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void testPutLicense() throws Exception {
|
||||
|
|
|
@ -100,7 +100,7 @@ public abstract class TribeTransportTestCase extends ESIntegTestCase {
|
|||
}
|
||||
};
|
||||
final InternalTestCluster cluster2 = new InternalTestCluster(InternalTestCluster.configuredNodeMode(),
|
||||
randomLong(), createTempDir(), 2, 2,
|
||||
randomLong(), createTempDir(), true, 2, 2,
|
||||
UUIDs.randomBase64UUID(random()), nodeConfigurationSource, 1, false, "tribe_node2",
|
||||
getMockPlugins(), getClientWrapper());
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ import static org.hamcrest.Matchers.equalTo;
|
|||
|
||||
//test is just too slow, please fix it to not be sleep-based
|
||||
//@BadApple(bugUrl = "https://github.com/elastic/x-plugins/issues/1007")
|
||||
@ESIntegTestCase.ClusterScope(scope = ESIntegTestCase.Scope.TEST, numDataNodes = 1, numClientNodes = 0)
|
||||
@ESIntegTestCase.ClusterScope(scope = ESIntegTestCase.Scope.TEST, supportsDedicatedMasters = false, numDataNodes = 1, numClientNodes = 0)
|
||||
public class MarvelSettingsTests extends MarvelIntegTestCase {
|
||||
private final TimeValue interval = newRandomTimeValue();
|
||||
private final TimeValue indexStatsTimeout = newRandomTimeValue();
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
/*
|
||||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
||||
* or more contributor license agreements. Licensed under the Elastic License;
|
||||
* you may not use this file except in compliance with the Elastic License.
|
||||
*/
|
||||
package org.elasticsearch.shield.authz.permission;
|
||||
|
||||
import org.elasticsearch.shield.authz.RoleDescriptor;
|
||||
import org.elasticsearch.shield.authz.privilege.ClusterPrivilege;
|
||||
import org.elasticsearch.shield.authz.privilege.Privilege.Name;
|
||||
|
||||
public class KibanaUserRole extends Role {
|
||||
|
||||
private static final String[] CLUSTER_PRIVILEGES = new String[] { "monitor" };
|
||||
private static final RoleDescriptor.IndicesPrivileges[] INDICES_PRIVILEGES = new RoleDescriptor.IndicesPrivileges[] {
|
||||
RoleDescriptor.IndicesPrivileges.builder().indices(".kibana*").privileges("manage", "read", "index", "delete").build() };
|
||||
|
||||
public static final String NAME = "kibana_user";
|
||||
public static final RoleDescriptor DESCRIPTOR = new RoleDescriptor(NAME, CLUSTER_PRIVILEGES, INDICES_PRIVILEGES, null);
|
||||
public static final KibanaUserRole INSTANCE = new KibanaUserRole();
|
||||
|
||||
private KibanaUserRole() {
|
||||
super(DESCRIPTOR.getName(),
|
||||
new ClusterPermission.Core(ClusterPrivilege.get(new Name(DESCRIPTOR.getClusterPrivileges()))),
|
||||
new IndicesPermission.Core(Role.Builder.convertFromIndicesPrivileges(DESCRIPTOR.getIndicesPrivileges())),
|
||||
RunAsPermission.Core.NONE);
|
||||
}
|
||||
}
|
|
@ -10,6 +10,7 @@ import org.elasticsearch.common.util.set.Sets;
|
|||
import org.elasticsearch.shield.SecurityContext;
|
||||
import org.elasticsearch.shield.authz.RoleDescriptor;
|
||||
import org.elasticsearch.shield.authz.permission.KibanaRole;
|
||||
import org.elasticsearch.shield.authz.permission.KibanaUserRole;
|
||||
import org.elasticsearch.shield.authz.permission.Role;
|
||||
import org.elasticsearch.shield.authz.permission.SuperuserRole;
|
||||
import org.elasticsearch.shield.authz.permission.TransportClientRole;
|
||||
|
@ -39,6 +40,8 @@ public class ReservedRolesStore implements RolesStore {
|
|||
return SuperuserRole.INSTANCE;
|
||||
case TransportClientRole.NAME:
|
||||
return TransportClientRole.INSTANCE;
|
||||
case KibanaUserRole.NAME:
|
||||
return KibanaUserRole.INSTANCE;
|
||||
case KibanaRole.NAME:
|
||||
// The only user that should know about this role is the kibana user itself (who has this role). The reason we want to hide
|
||||
// this role is that it was created specifically for kibana, with all the permissions that the kibana user needs.
|
||||
|
@ -58,6 +61,8 @@ public class ReservedRolesStore implements RolesStore {
|
|||
return SuperuserRole.DESCRIPTOR;
|
||||
case TransportClientRole.NAME:
|
||||
return TransportClientRole.DESCRIPTOR;
|
||||
case KibanaUserRole.NAME:
|
||||
return KibanaUserRole.DESCRIPTOR;
|
||||
case KibanaRole.NAME:
|
||||
// The only user that should know about this role is the kibana user itself (who has this role). The reason we want to hide
|
||||
// this role is that it was created specifically for kibana, with all the permissions that the kibana user needs.
|
||||
|
@ -73,19 +78,21 @@ public class ReservedRolesStore implements RolesStore {
|
|||
|
||||
public Collection<RoleDescriptor> roleDescriptors() {
|
||||
if (KibanaUser.is(securityContext.getUser())) {
|
||||
return Arrays.asList(SuperuserRole.DESCRIPTOR, TransportClientRole.DESCRIPTOR, KibanaRole.DESCRIPTOR);
|
||||
return Arrays.asList(SuperuserRole.DESCRIPTOR, TransportClientRole.DESCRIPTOR, KibanaUserRole.DESCRIPTOR,
|
||||
KibanaRole.DESCRIPTOR);
|
||||
}
|
||||
return Arrays.asList(SuperuserRole.DESCRIPTOR, TransportClientRole.DESCRIPTOR);
|
||||
return Arrays.asList(SuperuserRole.DESCRIPTOR, TransportClientRole.DESCRIPTOR, KibanaUserRole.DESCRIPTOR);
|
||||
}
|
||||
|
||||
public static Set<String> names() {
|
||||
return Sets.newHashSet(SuperuserRole.NAME, KibanaRole.NAME, TransportClientRole.NAME);
|
||||
return Sets.newHashSet(SuperuserRole.NAME, KibanaRole.NAME, TransportClientRole.NAME, KibanaUserRole.NAME);
|
||||
}
|
||||
|
||||
public static boolean isReserved(String role) {
|
||||
switch (role) {
|
||||
case SuperuserRole.NAME:
|
||||
case KibanaRole.NAME:
|
||||
case KibanaUserRole.NAME:
|
||||
case TransportClientRole.NAME:
|
||||
case SystemUser.ROLE_NAME:
|
||||
return true;
|
||||
|
|
|
@ -34,7 +34,7 @@ public class RestAuthenticateAction extends BaseRestHandler {
|
|||
public RestAuthenticateAction(Settings settings, RestController controller, Client client, SecurityContext securityContext) {
|
||||
super(settings, client);
|
||||
this.securityContext = securityContext;
|
||||
controller.registerHandler(GET, "/_xpack/security/authenticate", this); // deprecate
|
||||
controller.registerHandler(GET, "/_xpack/security/_authenticate", this);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -5,12 +5,15 @@
|
|||
*/
|
||||
package org.elasticsearch.integration;
|
||||
|
||||
import org.elasticsearch.action.admin.indices.create.CreateIndexResponse;
|
||||
import org.elasticsearch.action.admin.indices.get.GetIndexResponse;
|
||||
import org.elasticsearch.action.admin.indices.mapping.get.GetFieldMappingsResponse;
|
||||
import org.elasticsearch.action.admin.indices.mapping.get.GetFieldMappingsResponse.FieldMappingMetaData;
|
||||
import org.elasticsearch.action.admin.indices.validate.query.ValidateQueryResponse;
|
||||
import org.elasticsearch.action.delete.DeleteResponse;
|
||||
import org.elasticsearch.action.fieldstats.FieldStats;
|
||||
import org.elasticsearch.action.fieldstats.FieldStatsResponse;
|
||||
import org.elasticsearch.action.index.IndexResponse;
|
||||
import org.elasticsearch.action.search.MultiSearchResponse;
|
||||
import org.elasticsearch.action.search.SearchResponse;
|
||||
import org.elasticsearch.index.query.QueryBuilders;
|
||||
|
@ -19,6 +22,8 @@ import org.elasticsearch.shield.authc.support.SecuredString;
|
|||
import org.elasticsearch.shield.authc.support.UsernamePasswordToken;
|
||||
import org.elasticsearch.test.ShieldIntegTestCase;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
import static java.util.Collections.singletonMap;
|
||||
import static org.hamcrest.Matchers.arrayContaining;
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
|
@ -29,7 +34,7 @@ import static org.hamcrest.Matchers.notNullValue;
|
|||
/**
|
||||
*
|
||||
*/
|
||||
public class KibanaRoleTests extends ShieldIntegTestCase {
|
||||
public class KibanaUserRoleIntegTests extends ShieldIntegTestCase {
|
||||
|
||||
protected static final SecuredString USERS_PASSWD = new SecuredString("change_me".toCharArray());
|
||||
protected static final String USERS_PASSWD_HASHED = new String(Hasher.BCRYPT.hash(new SecuredString("change_me".toCharArray())));
|
||||
|
@ -38,18 +43,11 @@ public class KibanaRoleTests extends ShieldIntegTestCase {
|
|||
public String configRoles() {
|
||||
return super.configRoles() + "\n" +
|
||||
"my_kibana_user:\n" +
|
||||
" cluster:\n" +
|
||||
" - monitor\n" +
|
||||
" indices:\n" +
|
||||
" - names: 'logstash-*'\n" +
|
||||
" privileges:\n" +
|
||||
" - view_index_metadata\n" +
|
||||
" - read\n" +
|
||||
" - names: '.kibana*'\n" +
|
||||
" privileges:\n" +
|
||||
" - manage\n" +
|
||||
" - read\n" +
|
||||
" - index";
|
||||
" - read\n";
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -61,7 +59,8 @@ public class KibanaRoleTests extends ShieldIntegTestCase {
|
|||
@Override
|
||||
public String configUsersRoles() {
|
||||
return super.configUsersRoles() +
|
||||
"my_kibana_user:kibana_user";
|
||||
"my_kibana_user:kibana_user\n" +
|
||||
"kibana_user:kibana_user";
|
||||
}
|
||||
|
||||
public void testFieldMappings() throws Exception {
|
||||
|
@ -168,6 +167,33 @@ public class KibanaRoleTests extends ShieldIntegTestCase {
|
|||
assertThat(response.getIndices(), arrayContaining(index));
|
||||
}
|
||||
|
||||
public void testCreateIndexDeleteInKibanaIndex() throws Exception {
|
||||
final String index = randomBoolean()? ".kibana" : ".kibana-" + randomAsciiOfLengthBetween(1, 10).toLowerCase(Locale.ENGLISH);
|
||||
|
||||
if (randomBoolean()) {
|
||||
CreateIndexResponse createIndexResponse = client().filterWithHeader(singletonMap("Authorization",
|
||||
UsernamePasswordToken.basicAuthHeaderValue("kibana_user", USERS_PASSWD)))
|
||||
.admin().indices().prepareCreate(index).get();
|
||||
assertThat(createIndexResponse.isAcknowledged(), is(true));
|
||||
}
|
||||
|
||||
IndexResponse response = client()
|
||||
.filterWithHeader(singletonMap("Authorization", UsernamePasswordToken.basicAuthHeaderValue("kibana_user", USERS_PASSWD)))
|
||||
.prepareIndex()
|
||||
.setIndex(index)
|
||||
.setType("dashboard")
|
||||
.setSource("foo", "bar")
|
||||
.setRefresh(true)
|
||||
.get();
|
||||
assertThat(response.isCreated(), is(true));
|
||||
|
||||
DeleteResponse deleteResponse = client()
|
||||
.filterWithHeader(singletonMap("Authorization", UsernamePasswordToken.basicAuthHeaderValue("kibana_user", USERS_PASSWD)))
|
||||
.prepareDelete(index, "dashboard", response.getId())
|
||||
.get();
|
||||
assertThat(deleteResponse.isFound(), is(true));
|
||||
}
|
||||
|
||||
// TODO: When we have an XPackIntegTestCase, this should test that we can send MonitoringBulkActions
|
||||
|
||||
}
|
|
@ -37,6 +37,6 @@ public class VersionCompatibilityTests extends ESTestCase {
|
|||
*
|
||||
*/
|
||||
assertThat("Remove workaround in LicenseService class when es core supports merging cluster level custom metadata",
|
||||
Version.CURRENT.equals(Version.V_5_0_0_alpha3), is(true));
|
||||
Version.CURRENT.equals(Version.V_5_0_0), is(true));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,9 +13,9 @@ import org.elasticsearch.action.admin.indices.settings.get.GetSettingsResponse;
|
|||
import org.elasticsearch.action.search.SearchResponse;
|
||||
import org.elasticsearch.action.support.IndicesOptions;
|
||||
import org.elasticsearch.client.Client;
|
||||
import org.elasticsearch.cluster.service.ClusterService;
|
||||
import org.elasticsearch.client.Requests;
|
||||
import org.elasticsearch.cluster.health.ClusterHealthStatus;
|
||||
import org.elasticsearch.cluster.service.ClusterService;
|
||||
import org.elasticsearch.common.Priority;
|
||||
import org.elasticsearch.common.inject.util.Providers;
|
||||
import org.elasticsearch.common.network.NetworkAddress;
|
||||
|
@ -36,6 +36,9 @@ import org.elasticsearch.shield.authc.AuthenticationToken;
|
|||
import org.elasticsearch.shield.crypto.InternalCryptoService;
|
||||
import org.elasticsearch.shield.transport.filter.IPFilter;
|
||||
import org.elasticsearch.shield.transport.filter.ShieldIpFilterRule;
|
||||
import org.elasticsearch.shield.transport.netty.ShieldNettyTransport;
|
||||
import org.elasticsearch.shield.user.SystemUser;
|
||||
import org.elasticsearch.shield.user.User;
|
||||
import org.elasticsearch.test.ESIntegTestCase;
|
||||
import org.elasticsearch.test.InternalTestCluster;
|
||||
import org.elasticsearch.test.ShieldIntegTestCase;
|
||||
|
@ -80,7 +83,7 @@ import static org.mockito.Mockito.when;
|
|||
/**
|
||||
*
|
||||
*/
|
||||
@ESIntegTestCase.ClusterScope(scope = SUITE, numDataNodes = 1)
|
||||
@ESIntegTestCase.ClusterScope(scope = SUITE, supportsDedicatedMasters = false, numDataNodes = 1)
|
||||
public class IndexAuditTrailTests extends ShieldIntegTestCase {
|
||||
public static final String SECOND_CLUSTER_NODE_PREFIX = "remote_" + SUITE_CLUSTER_NODE_PREFIX;
|
||||
|
||||
|
@ -143,7 +146,7 @@ public class IndexAuditTrailTests extends ShieldIntegTestCase {
|
|||
return builder.build();
|
||||
}
|
||||
};
|
||||
remoteCluster = new InternalTestCluster("network", randomLong(), createTempDir(), numNodes, numNodes, cluster2Name,
|
||||
remoteCluster = new InternalTestCluster("network", randomLong(), createTempDir(), false, numNodes, numNodes, cluster2Name,
|
||||
cluster2SettingsSource, 0, false, SECOND_CLUSTER_NODE_PREFIX, getMockPlugins(),
|
||||
useShield ? getClientWrapper() : Function.identity());
|
||||
remoteCluster.beforeTest(random(), 0.5);
|
||||
|
|
|
@ -104,8 +104,9 @@ public class RemoteIndexAuditTrailStartingTests extends ShieldIntegTestCase {
|
|||
return builder.build();
|
||||
}
|
||||
};
|
||||
remoteCluster = new InternalTestCluster("network", randomLong(), createTempDir(), numNodes, numNodes, cluster2Name,
|
||||
cluster2SettingsSource, 0, false, SECOND_CLUSTER_NODE_PREFIX, getMockPlugins(), getClientWrapper());
|
||||
remoteCluster = new InternalTestCluster("network", randomLong(), createTempDir(), false,
|
||||
numNodes, numNodes,
|
||||
cluster2Name, cluster2SettingsSource, 0, false, SECOND_CLUSTER_NODE_PREFIX, getMockPlugins(), getClientWrapper());
|
||||
remoteCluster.beforeTest(random(), 0.5);
|
||||
}
|
||||
|
||||
|
|
|
@ -46,7 +46,7 @@ import static org.hamcrest.Matchers.is;
|
|||
/**
|
||||
* Test authentication via PKI on both REST and Transport layers
|
||||
*/
|
||||
@ClusterScope(numClientNodes = 0, numDataNodes = 1)
|
||||
@ClusterScope(numClientNodes = 0, supportsDedicatedMasters = false, numDataNodes = 1)
|
||||
public class PkiAuthenticationTests extends ShieldIntegTestCase {
|
||||
|
||||
@Override
|
||||
|
|
|
@ -33,7 +33,7 @@ import java.util.Locale;
|
|||
|
||||
import static org.hamcrest.Matchers.is;
|
||||
|
||||
@ClusterScope(numClientNodes = 0, numDataNodes = 1)
|
||||
@ClusterScope(numClientNodes = 0, supportsDedicatedMasters = false, numDataNodes = 1)
|
||||
public class PkiWithoutClientAuthenticationTests extends ShieldIntegTestCase {
|
||||
private TrustManager[] trustAllCerts = new TrustManager[] {
|
||||
new X509TrustManager() {
|
||||
|
|
|
@ -21,7 +21,7 @@ import org.elasticsearch.test.rest.client.http.HttpResponse;
|
|||
|
||||
import static org.hamcrest.Matchers.is;
|
||||
|
||||
@ClusterScope(numClientNodes = 0, numDataNodes = 1)
|
||||
@ClusterScope(numClientNodes = 0, supportsDedicatedMasters = false, numDataNodes = 1)
|
||||
public class PkiWithoutSSLTests extends ShieldIntegTestCase {
|
||||
@Override
|
||||
public boolean sslTransportEnabled() {
|
||||
|
|
|
@ -0,0 +1,72 @@
|
|||
/*
|
||||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
||||
* or more contributor license agreements. Licensed under the Elastic License;
|
||||
* you may not use this file except in compliance with the Elastic License.
|
||||
*/
|
||||
package org.elasticsearch.shield.authz.permission;
|
||||
|
||||
import org.elasticsearch.action.admin.cluster.health.ClusterHealthAction;
|
||||
import org.elasticsearch.action.admin.cluster.reroute.ClusterRerouteAction;
|
||||
import org.elasticsearch.action.admin.cluster.settings.ClusterUpdateSettingsAction;
|
||||
import org.elasticsearch.action.admin.cluster.state.ClusterStateAction;
|
||||
import org.elasticsearch.action.admin.cluster.stats.ClusterStatsAction;
|
||||
import org.elasticsearch.action.admin.indices.create.CreateIndexAction;
|
||||
import org.elasticsearch.action.admin.indices.delete.DeleteIndexAction;
|
||||
import org.elasticsearch.action.admin.indices.settings.put.UpdateSettingsAction;
|
||||
import org.elasticsearch.action.admin.indices.template.put.PutIndexTemplateAction;
|
||||
import org.elasticsearch.action.delete.DeleteAction;
|
||||
import org.elasticsearch.action.index.IndexAction;
|
||||
import org.elasticsearch.action.search.MultiSearchAction;
|
||||
import org.elasticsearch.action.search.SearchAction;
|
||||
import org.elasticsearch.marvel.action.MonitoringBulkAction;
|
||||
import org.elasticsearch.shield.user.User;
|
||||
import org.elasticsearch.test.ESTestCase;
|
||||
import org.elasticsearch.transport.TransportRequest;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import static org.hamcrest.Matchers.is;
|
||||
|
||||
public class KibanaUserRoleTests extends ESTestCase {
|
||||
|
||||
public void testCluster() {
|
||||
final User user = new User("joe");
|
||||
final TransportRequest request = new TransportRequest.Empty();
|
||||
assertThat(KibanaUserRole.INSTANCE.cluster().check(ClusterHealthAction.NAME, request, user), is(true));
|
||||
assertThat(KibanaUserRole.INSTANCE.cluster().check(ClusterStateAction.NAME, request, user), is(true));
|
||||
assertThat(KibanaUserRole.INSTANCE.cluster().check(ClusterStatsAction.NAME, request, user), is(true));
|
||||
assertThat(KibanaUserRole.INSTANCE.cluster().check(PutIndexTemplateAction.NAME, request, user), is(false));
|
||||
assertThat(KibanaUserRole.INSTANCE.cluster().check(ClusterRerouteAction.NAME, request, user), is(false));
|
||||
assertThat(KibanaUserRole.INSTANCE.cluster().check(ClusterUpdateSettingsAction.NAME, request, user), is(false));
|
||||
|
||||
assertThat(KibanaUserRole.INSTANCE.cluster().check(MonitoringBulkAction.NAME, request, user), is(false));
|
||||
}
|
||||
|
||||
public void testRunAs() {
|
||||
assertThat(KibanaUserRole.INSTANCE.runAs().isEmpty(), is(true));
|
||||
}
|
||||
|
||||
public void testUnauthorizedIndices() {
|
||||
assertThat(KibanaUserRole.INSTANCE.indices().allowedIndicesMatcher(IndexAction.NAME).test("foo"), is(false));
|
||||
assertThat(KibanaUserRole.INSTANCE.indices().allowedIndicesMatcher(IndexAction.NAME).test(".reporting"), is(false));
|
||||
assertThat(KibanaUserRole.INSTANCE.indices().allowedIndicesMatcher("indices:foo")
|
||||
.test(randomAsciiOfLengthBetween(8, 24)), is(false));
|
||||
}
|
||||
|
||||
public void testKibanaIndices() {
|
||||
Arrays.asList(".kibana", ".kibana-devnull").forEach(this::testIndexAccess);
|
||||
}
|
||||
|
||||
private void testIndexAccess(String index) {
|
||||
assertThat(KibanaUserRole.INSTANCE.indices().allowedIndicesMatcher("indices:foo").test(index), is(false));
|
||||
assertThat(KibanaUserRole.INSTANCE.indices().allowedIndicesMatcher("indices:bar").test(index), is(false));
|
||||
|
||||
assertThat(KibanaUserRole.INSTANCE.indices().allowedIndicesMatcher(DeleteAction.NAME).test(index), is(true));
|
||||
assertThat(KibanaUserRole.INSTANCE.indices().allowedIndicesMatcher(DeleteIndexAction.NAME).test(index), is(true));
|
||||
assertThat(KibanaUserRole.INSTANCE.indices().allowedIndicesMatcher(CreateIndexAction.NAME).test(index), is(true));
|
||||
assertThat(KibanaUserRole.INSTANCE.indices().allowedIndicesMatcher(IndexAction.NAME).test(index), is(true));
|
||||
assertThat(KibanaUserRole.INSTANCE.indices().allowedIndicesMatcher(SearchAction.NAME).test(index), is(true));
|
||||
assertThat(KibanaUserRole.INSTANCE.indices().allowedIndicesMatcher(MultiSearchAction.NAME).test(index), is(true));
|
||||
assertThat(KibanaUserRole.INSTANCE.indices().allowedIndicesMatcher(UpdateSettingsAction.NAME).test(index), is(true));
|
||||
}
|
||||
}
|
|
@ -7,6 +7,7 @@ package org.elasticsearch.shield.authz.store;
|
|||
|
||||
import org.elasticsearch.shield.SecurityContext;
|
||||
import org.elasticsearch.shield.authz.permission.KibanaRole;
|
||||
import org.elasticsearch.shield.authz.permission.KibanaUserRole;
|
||||
import org.elasticsearch.shield.authz.permission.SuperuserRole;
|
||||
import org.elasticsearch.shield.authz.permission.TransportClientRole;
|
||||
import org.elasticsearch.shield.user.ElasticUser;
|
||||
|
@ -50,7 +51,11 @@ public class ReservedRolesStoreTests extends ESTestCase {
|
|||
assertThat(reservedRolesStore.role(TransportClientRole.NAME), sameInstance(TransportClientRole.INSTANCE));
|
||||
assertThat(reservedRolesStore.roleDescriptor(TransportClientRole.NAME), sameInstance(TransportClientRole.DESCRIPTOR));
|
||||
|
||||
assertThat(reservedRolesStore.roleDescriptors(), contains(SuperuserRole.DESCRIPTOR, TransportClientRole.DESCRIPTOR));
|
||||
assertThat(reservedRolesStore.role(KibanaUserRole.NAME), sameInstance(KibanaUserRole.INSTANCE));
|
||||
assertThat(reservedRolesStore.roleDescriptor(KibanaUserRole.NAME), sameInstance(KibanaUserRole.DESCRIPTOR));
|
||||
|
||||
assertThat(reservedRolesStore.roleDescriptors(),
|
||||
contains(SuperuserRole.DESCRIPTOR, TransportClientRole.DESCRIPTOR, KibanaUserRole.DESCRIPTOR));
|
||||
|
||||
assertThat(reservedRolesStore.role(KibanaRole.NAME), nullValue());
|
||||
assertThat(reservedRolesStore.roleDescriptor(KibanaRole.NAME), nullValue());
|
||||
|
@ -66,10 +71,13 @@ public class ReservedRolesStoreTests extends ESTestCase {
|
|||
assertThat(reservedRolesStore.role(TransportClientRole.NAME), sameInstance(TransportClientRole.INSTANCE));
|
||||
assertThat(reservedRolesStore.roleDescriptor(TransportClientRole.NAME), sameInstance(TransportClientRole.DESCRIPTOR));
|
||||
|
||||
assertThat(reservedRolesStore.role(KibanaUserRole.NAME), sameInstance(KibanaUserRole.INSTANCE));
|
||||
assertThat(reservedRolesStore.roleDescriptor(KibanaUserRole.NAME), sameInstance(KibanaUserRole.DESCRIPTOR));
|
||||
|
||||
assertThat(reservedRolesStore.role(KibanaRole.NAME), sameInstance(KibanaRole.INSTANCE));
|
||||
assertThat(reservedRolesStore.roleDescriptor(KibanaRole.NAME), sameInstance(KibanaRole.DESCRIPTOR));
|
||||
assertThat(reservedRolesStore.roleDescriptors(),
|
||||
contains(SuperuserRole.DESCRIPTOR, TransportClientRole.DESCRIPTOR, KibanaRole.DESCRIPTOR));
|
||||
contains(SuperuserRole.DESCRIPTOR, TransportClientRole.DESCRIPTOR, KibanaUserRole.DESCRIPTOR, KibanaRole.DESCRIPTOR));
|
||||
|
||||
assertThat(reservedRolesStore.role(SystemUser.ROLE_NAME), nullValue());
|
||||
}
|
||||
|
@ -80,5 +88,6 @@ public class ReservedRolesStoreTests extends ESTestCase {
|
|||
assertThat(ReservedRolesStore.isReserved("foobar"), is(false));
|
||||
assertThat(ReservedRolesStore.isReserved(SystemUser.ROLE_NAME), is(true));
|
||||
assertThat(ReservedRolesStore.isReserved(TransportClientRole.NAME), is(true));
|
||||
assertThat(ReservedRolesStore.isReserved(KibanaUserRole.NAME), is(true));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -47,7 +47,7 @@ public class RestAuthenticateActionTests extends ShieldIntegTestCase {
|
|||
}
|
||||
|
||||
public void testAuthenticateApi() throws Exception {
|
||||
HttpResponse response = httpClient().method("GET").path("/_xpack/security/authenticate")
|
||||
HttpResponse response = httpClient().method("GET").path("/_xpack/security/_authenticate")
|
||||
.addHeader("Authorization", basicAuthHeaderValue(ShieldSettingsSource.DEFAULT_USER_NAME,
|
||||
new SecuredString(ShieldSettingsSource.DEFAULT_PASSWORD.toCharArray())))
|
||||
.execute();
|
||||
|
@ -61,7 +61,7 @@ public class RestAuthenticateActionTests extends ShieldIntegTestCase {
|
|||
}
|
||||
|
||||
public void testAuthenticateApiWithoutAuthentication() throws Exception {
|
||||
HttpResponse response = httpClient().method("GET").path("/_xpack/security/authenticate")
|
||||
HttpResponse response = httpClient().method("GET").path("/_xpack/security/_authenticate")
|
||||
.execute();
|
||||
|
||||
if (anonymousEnabled) {
|
||||
|
|
|
@ -32,6 +32,7 @@ import javax.net.ssl.SSLSocketFactory;
|
|||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.net.SocketException;
|
||||
import java.nio.file.AtomicMoveNotSupportedException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
|
@ -45,6 +46,7 @@ import java.util.Map.Entry;
|
|||
import java.util.concurrent.CountDownLatch;
|
||||
|
||||
import static org.hamcrest.Matchers.containsString;
|
||||
import static org.hamcrest.Matchers.is;
|
||||
|
||||
/**
|
||||
* Integration tests for SSL reloading support
|
||||
|
@ -113,9 +115,10 @@ public class SSLReloadIntegTests extends ShieldIntegTestCase {
|
|||
InetSocketTransportAddress address = (InetSocketTransportAddress) internalCluster()
|
||||
.getInstance(Transport.class, node).boundAddress().publishAddress();
|
||||
try (SSLSocket socket = (SSLSocket) sslSocketFactory.createSocket(address.getAddress(), address.getPort())) {
|
||||
assertThat(socket.isConnected(), is(true));
|
||||
socket.startHandshake();
|
||||
fail("handshake should not have been successful!");
|
||||
} catch (SSLHandshakeException expected) {
|
||||
} catch (SSLHandshakeException | SocketException expected) {
|
||||
}
|
||||
|
||||
KeyStore nodeStore = KeyStore.getInstance("jks");
|
||||
|
|
|
@ -20,7 +20,7 @@ import static org.elasticsearch.test.ESIntegTestCase.Scope.TEST;
|
|||
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
|
||||
import static org.hamcrest.Matchers.is;
|
||||
|
||||
@ClusterScope(scope = TEST, numDataNodes = 1)
|
||||
@ClusterScope(scope = TEST, supportsDedicatedMasters = false, numDataNodes = 1)
|
||||
public class IpFilteringUpdateTests extends ShieldIntegTestCase {
|
||||
|
||||
private static int randomClientPort;
|
||||
|
|
|
@ -59,13 +59,20 @@ public abstract class ShieldIntegTestCase extends ESIntegTestCase {
|
|||
private static int maxNumberOfNodes() {
|
||||
ClusterScope clusterScope = ShieldIntegTestCase.class.getAnnotation(ClusterScope.class);
|
||||
if (clusterScope == null) {
|
||||
return InternalTestCluster.DEFAULT_MAX_NUM_DATA_NODES + InternalTestCluster.DEFAULT_MAX_NUM_CLIENT_NODES;
|
||||
return InternalTestCluster.DEFAULT_HIGH_NUM_MASTER_NODES +
|
||||
InternalTestCluster.DEFAULT_MAX_NUM_DATA_NODES +
|
||||
InternalTestCluster.DEFAULT_MAX_NUM_CLIENT_NODES;
|
||||
} else {
|
||||
if (clusterScope.numClientNodes() < 0) {
|
||||
return clusterScope.maxNumDataNodes() + InternalTestCluster.DEFAULT_MAX_NUM_CLIENT_NODES;
|
||||
} else {
|
||||
return clusterScope.maxNumDataNodes() + clusterScope.numClientNodes();
|
||||
int clientNodes = clusterScope.numClientNodes();
|
||||
if (clientNodes < 0) {
|
||||
clientNodes = InternalTestCluster.DEFAULT_MAX_NUM_CLIENT_NODES;
|
||||
}
|
||||
int masterNodes = 0;
|
||||
if (clusterScope.supportsDedicatedMasters()) {
|
||||
masterNodes = InternalTestCluster.DEFAULT_HIGH_NUM_MASTER_NODES;
|
||||
}
|
||||
|
||||
return masterNodes + clusterScope.maxNumDataNodes() + clientNodes;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -15,7 +15,6 @@ import org.elasticsearch.shield.action.ShieldActionModule;
|
|||
import org.elasticsearch.test.ESIntegTestCase.ClusterScope;
|
||||
import org.elasticsearch.test.ShieldIntegTestCase;
|
||||
import org.elasticsearch.xpack.XPackPlugin;
|
||||
import org.elasticsearch.xpack.watcher.Watcher;
|
||||
import org.junit.BeforeClass;
|
||||
|
||||
import java.io.IOException;
|
||||
|
@ -43,7 +42,7 @@ import static org.hamcrest.CoreMatchers.hasItems;
|
|||
import static org.hamcrest.Matchers.hasItem;
|
||||
import static org.hamcrest.Matchers.is;
|
||||
|
||||
@ClusterScope(numClientNodes = 0, numDataNodes = 1)
|
||||
@ClusterScope(numClientNodes = 0, supportsDedicatedMasters = false, numDataNodes = 1)
|
||||
public class KnownActionsTests extends ShieldIntegTestCase {
|
||||
private static Set<String> knownActions;
|
||||
private static Set<String> knownHandlers;
|
||||
|
|
|
@ -42,6 +42,7 @@ indices:admin/open
|
|||
indices:admin/refresh
|
||||
indices:admin/settings/update
|
||||
indices:admin/shards/search_shards
|
||||
indices:admin/shrink
|
||||
indices:admin/template/delete
|
||||
indices:admin/template/get
|
||||
indices:admin/template/put
|
||||
|
|
|
@ -73,8 +73,6 @@ indices:monitor/stats[n]
|
|||
indices:monitor/upgrade[n]
|
||||
indices:monitor/upgrade
|
||||
internal:admin/tasks/ban
|
||||
internal:cluster/node/index/deleted
|
||||
internal:cluster/node/index_store/deleted
|
||||
internal:cluster/node/mapping/refresh
|
||||
internal:cluster/nodes/indices/shard/store
|
||||
internal:cluster/nodes/indices/shard/store[n]
|
||||
|
|
|
@ -3,8 +3,8 @@
|
|||
"documentation": "Retrieve details about the currently authenticated user",
|
||||
"methods": [ "GET" ],
|
||||
"url": {
|
||||
"path": "/_xpack/security/authenticate",
|
||||
"paths": [ "/_xpack/security/authenticate" ],
|
||||
"path": "/_xpack/security/_authenticate",
|
||||
"paths": [ "/_xpack/security/_authenticate" ],
|
||||
"parts": {},
|
||||
"params": {}
|
||||
},
|
||||
|
|
|
@ -43,6 +43,7 @@ import org.elasticsearch.xpack.rest.action.RestXPackInfoAction;
|
|||
import org.elasticsearch.xpack.common.text.TextTemplateModule;
|
||||
import org.elasticsearch.xpack.rest.action.RestXPackUsageAction;
|
||||
import org.elasticsearch.xpack.watcher.Watcher;
|
||||
import org.elasticsearch.xpack.support.clock.ClockModule;
|
||||
|
||||
import java.nio.file.Path;
|
||||
import java.security.AccessController;
|
||||
|
@ -137,6 +138,7 @@ public class XPackPlugin extends Plugin {
|
|||
public Collection<Module> nodeModules() {
|
||||
ArrayList<Module> modules = new ArrayList<>();
|
||||
modules.add(new LazyInitializationModule());
|
||||
modules.add(new ClockModule());
|
||||
modules.addAll(notification.nodeModules());
|
||||
modules.addAll(licensing.nodeModules());
|
||||
modules.addAll(security.nodeModules());
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
* or more contributor license agreements. Licensed under the Elastic License;
|
||||
* you may not use this file except in compliance with the Elastic License.
|
||||
*/
|
||||
package org.elasticsearch.xpack.watcher.support.clock;
|
||||
package org.elasticsearch.xpack.support.clock;
|
||||
|
||||
import org.elasticsearch.common.unit.TimeValue;
|
||||
import org.joda.time.DateTime;
|
|
@ -3,7 +3,7 @@
|
|||
* or more contributor license agreements. Licensed under the Elastic License;
|
||||
* you may not use this file except in compliance with the Elastic License.
|
||||
*/
|
||||
package org.elasticsearch.xpack.watcher.support.clock;
|
||||
package org.elasticsearch.xpack.support.clock;
|
||||
|
||||
import org.elasticsearch.common.inject.AbstractModule;
|
||||
|
|
@ -3,7 +3,7 @@
|
|||
* or more contributor license agreements. Licensed under the Elastic License;
|
||||
* you may not use this file except in compliance with the Elastic License.
|
||||
*/
|
||||
package org.elasticsearch.xpack.watcher.support.clock;
|
||||
package org.elasticsearch.xpack.support.clock;
|
||||
|
||||
import org.elasticsearch.common.unit.TimeValue;
|
||||
import org.joda.time.DateTime;
|
|
@ -3,7 +3,7 @@
|
|||
* or more contributor license agreements. Licensed under the Elastic License;
|
||||
* you may not use this file except in compliance with the Elastic License.
|
||||
*/
|
||||
package org.elasticsearch.xpack.watcher.support.clock;
|
||||
package org.elasticsearch.xpack.support.clock;
|
||||
|
||||
import org.elasticsearch.common.unit.TimeValue;
|
||||
import org.joda.time.DateTime;
|
|
@ -5,13 +5,43 @@
|
|||
*/
|
||||
package org.elasticsearch.xpack;
|
||||
|
||||
import org.elasticsearch.common.inject.Module;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.xpack.support.clock.Clock;
|
||||
import org.elasticsearch.xpack.support.clock.ClockMock;
|
||||
import org.elasticsearch.xpack.support.clock.ClockModule;
|
||||
import org.elasticsearch.xpack.watcher.test.TimeWarpedWatcher;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
public class TimeWarpedXPackPlugin extends XPackPlugin {
|
||||
|
||||
public TimeWarpedXPackPlugin(Settings settings) {
|
||||
super(settings);
|
||||
watcher = new TimeWarpedWatcher(settings);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<Module> nodeModules() {
|
||||
List<Module> modules = new ArrayList<>(super.nodeModules());
|
||||
for (int i = 0; i < modules.size(); ++i) {
|
||||
Module module = modules.get(i);
|
||||
if (module instanceof ClockModule) {
|
||||
// replacing the clock module so we'll be able
|
||||
// to control time in tests
|
||||
modules.set(i, new MockClockModule());
|
||||
}
|
||||
}
|
||||
return modules;
|
||||
}
|
||||
|
||||
public static class MockClockModule extends ClockModule {
|
||||
@Override
|
||||
protected void configure() {
|
||||
bind(ClockMock.class).asEagerSingleton();
|
||||
bind(Clock.class).to(ClockMock.class);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
* or more contributor license agreements. Licensed under the Elastic License;
|
||||
* you may not use this file except in compliance with the Elastic License.
|
||||
*/
|
||||
package org.elasticsearch.xpack.watcher.support.clock;
|
||||
package org.elasticsearch.xpack.support.clock;
|
||||
|
||||
import org.elasticsearch.common.unit.TimeValue;
|
||||
import org.joda.time.DateTime;
|
|
@ -3,7 +3,7 @@
|
|||
* or more contributor license agreements. Licensed under the Elastic License;
|
||||
* you may not use this file except in compliance with the Elastic License.
|
||||
*/
|
||||
package org.elasticsearch.xpack.watcher.support.clock;
|
||||
package org.elasticsearch.xpack.support.clock;
|
||||
|
||||
import org.elasticsearch.test.ESTestCase;
|
||||
|
|
@ -43,7 +43,6 @@ import org.elasticsearch.xpack.watcher.rest.action.RestWatcherStatsAction;
|
|||
import org.elasticsearch.xpack.common.ScriptServiceProxy;
|
||||
import org.elasticsearch.xpack.watcher.support.WatcherIndexTemplateRegistry;
|
||||
import org.elasticsearch.xpack.watcher.support.WatcherIndexTemplateRegistry.TemplateConfig;
|
||||
import org.elasticsearch.xpack.watcher.support.clock.ClockModule;
|
||||
import org.elasticsearch.xpack.watcher.support.init.proxy.WatcherClientProxy;
|
||||
import org.elasticsearch.xpack.watcher.support.validation.WatcherSettingsValidation;
|
||||
import org.elasticsearch.xpack.watcher.transform.TransformModule;
|
||||
|
@ -110,7 +109,6 @@ public class Watcher {
|
|||
modules.add(new WatcherModule(enabled, transportClient));
|
||||
if (enabled && transportClient == false) {
|
||||
modules.add(new WatchModule());
|
||||
modules.add(new ClockModule());
|
||||
modules.add(new WatcherClientModule());
|
||||
modules.add(new TransformModule());
|
||||
modules.add(new TriggerModule(settings));
|
||||
|
|
|
@ -17,7 +17,7 @@ import org.elasticsearch.common.unit.TimeValue;
|
|||
import org.elasticsearch.index.engine.VersionConflictEngineException;
|
||||
import org.elasticsearch.xpack.watcher.execution.ExecutionService;
|
||||
import org.elasticsearch.xpack.watcher.support.WatcherIndexTemplateRegistry;
|
||||
import org.elasticsearch.xpack.watcher.support.clock.Clock;
|
||||
import org.elasticsearch.xpack.support.clock.Clock;
|
||||
import org.elasticsearch.xpack.watcher.trigger.TriggerService;
|
||||
import org.elasticsearch.xpack.watcher.watch.Watch;
|
||||
import org.elasticsearch.xpack.watcher.watch.WatchLockService;
|
||||
|
|
|
@ -9,7 +9,7 @@ import org.elasticsearch.ElasticsearchParseException;
|
|||
import org.elasticsearch.common.inject.Inject;
|
||||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
import org.elasticsearch.xpack.watcher.WatcherLicensee;
|
||||
import org.elasticsearch.xpack.watcher.support.clock.Clock;
|
||||
import org.elasticsearch.xpack.support.clock.Clock;
|
||||
import org.elasticsearch.xpack.watcher.support.validation.Validation;
|
||||
import org.elasticsearch.xpack.watcher.transform.TransformRegistry;
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ import org.elasticsearch.xpack.watcher.actions.throttler.Throttler;
|
|||
import org.elasticsearch.xpack.watcher.execution.WatchExecutionContext;
|
||||
import org.elasticsearch.xpack.watcher.WatcherLicensee;
|
||||
import org.elasticsearch.xpack.watcher.support.WatcherDateTimeUtils;
|
||||
import org.elasticsearch.xpack.watcher.support.clock.Clock;
|
||||
import org.elasticsearch.xpack.support.clock.Clock;
|
||||
import org.elasticsearch.xpack.watcher.transform.ExecutableTransform;
|
||||
import org.elasticsearch.xpack.watcher.transform.Transform;
|
||||
import org.elasticsearch.xpack.watcher.transform.TransformRegistry;
|
||||
|
|
|
@ -9,7 +9,7 @@ import org.elasticsearch.common.Nullable;
|
|||
import org.elasticsearch.common.unit.TimeValue;
|
||||
import org.elasticsearch.xpack.watcher.execution.WatchExecutionContext;
|
||||
import org.elasticsearch.xpack.watcher.WatcherLicensee;
|
||||
import org.elasticsearch.xpack.watcher.support.clock.Clock;
|
||||
import org.elasticsearch.xpack.support.clock.Clock;
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
|
@ -9,7 +9,7 @@ import org.elasticsearch.common.Nullable;
|
|||
import org.elasticsearch.common.unit.TimeValue;
|
||||
import org.elasticsearch.xpack.watcher.actions.ActionStatus;
|
||||
import org.elasticsearch.xpack.watcher.execution.WatchExecutionContext;
|
||||
import org.elasticsearch.xpack.watcher.support.clock.Clock;
|
||||
import org.elasticsearch.xpack.support.clock.Clock;
|
||||
import org.joda.time.PeriodType;
|
||||
|
||||
/**
|
||||
|
|
|
@ -11,7 +11,7 @@ import org.elasticsearch.xpack.watcher.condition.ExecutableCondition;
|
|||
import org.elasticsearch.xpack.watcher.execution.WatchExecutionContext;
|
||||
import org.elasticsearch.xpack.watcher.support.Variables;
|
||||
import org.elasticsearch.xpack.watcher.support.WatcherDateTimeUtils;
|
||||
import org.elasticsearch.xpack.watcher.support.clock.Clock;
|
||||
import org.elasticsearch.xpack.support.clock.Clock;
|
||||
import org.elasticsearch.xpack.watcher.support.xcontent.ObjectPath;
|
||||
import org.joda.time.DateTime;
|
||||
import org.joda.time.DateTimeZone;
|
||||
|
|
|
@ -10,7 +10,7 @@ import org.elasticsearch.common.logging.Loggers;
|
|||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
import org.elasticsearch.xpack.watcher.condition.ConditionFactory;
|
||||
import org.elasticsearch.xpack.watcher.support.clock.Clock;
|
||||
import org.elasticsearch.xpack.support.clock.Clock;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
package org.elasticsearch.xpack.watcher.condition.compare;
|
||||
|
||||
import org.elasticsearch.common.logging.ESLogger;
|
||||
import org.elasticsearch.xpack.watcher.support.clock.Clock;
|
||||
import org.elasticsearch.xpack.support.clock.Clock;
|
||||
import org.elasticsearch.xpack.watcher.support.xcontent.ObjectPath;
|
||||
|
||||
import java.util.Map;
|
||||
|
|
|
@ -10,7 +10,7 @@ import org.elasticsearch.common.logging.Loggers;
|
|||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
import org.elasticsearch.xpack.watcher.condition.ConditionFactory;
|
||||
import org.elasticsearch.xpack.watcher.support.clock.Clock;
|
||||
import org.elasticsearch.xpack.support.clock.Clock;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@ package org.elasticsearch.xpack.watcher.condition.compare.array;
|
|||
|
||||
import org.elasticsearch.common.logging.ESLogger;
|
||||
import org.elasticsearch.xpack.watcher.condition.compare.AbstractExecutableCompareCondition;
|
||||
import org.elasticsearch.xpack.watcher.support.clock.Clock;
|
||||
import org.elasticsearch.xpack.support.clock.Clock;
|
||||
import org.elasticsearch.xpack.watcher.support.xcontent.ObjectPath;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
|
|
@ -18,7 +18,7 @@ import org.elasticsearch.xpack.watcher.condition.Condition;
|
|||
import org.elasticsearch.xpack.watcher.history.HistoryStore;
|
||||
import org.elasticsearch.xpack.watcher.history.WatchRecord;
|
||||
import org.elasticsearch.xpack.watcher.input.Input;
|
||||
import org.elasticsearch.xpack.watcher.support.clock.Clock;
|
||||
import org.elasticsearch.xpack.support.clock.Clock;
|
||||
import org.elasticsearch.xpack.watcher.support.validation.WatcherSettingsValidation;
|
||||
import org.elasticsearch.xpack.watcher.transform.Transform;
|
||||
import org.elasticsearch.xpack.watcher.trigger.TriggerEvent;
|
||||
|
|
|
@ -14,7 +14,7 @@ import org.elasticsearch.common.unit.TimeValue;
|
|||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
import org.elasticsearch.index.mapper.core.DateFieldMapper;
|
||||
import org.elasticsearch.xpack.watcher.support.clock.Clock;
|
||||
import org.elasticsearch.xpack.support.clock.Clock;
|
||||
import org.joda.time.DateTime;
|
||||
import org.joda.time.DateTimeZone;
|
||||
|
||||
|
|
|
@ -15,8 +15,8 @@ import org.elasticsearch.common.Nullable;
|
|||
import org.elasticsearch.common.xcontent.XContentLocation;
|
||||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
import org.elasticsearch.common.xcontent.XContentType;
|
||||
import org.elasticsearch.xpack.watcher.support.clock.Clock;
|
||||
import org.elasticsearch.xpack.watcher.support.clock.SystemClock;
|
||||
import org.elasticsearch.xpack.support.clock.Clock;
|
||||
import org.elasticsearch.xpack.support.clock.SystemClock;
|
||||
import org.elasticsearch.xpack.common.secret.Secret;
|
||||
import org.elasticsearch.xpack.common.secret.SecretService;
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@ import org.elasticsearch.xpack.watcher.execution.ManualExecutionContext;
|
|||
import org.elasticsearch.xpack.watcher.history.WatchRecord;
|
||||
import org.elasticsearch.xpack.watcher.input.simple.SimpleInput;
|
||||
import org.elasticsearch.xpack.watcher.WatcherLicensee;
|
||||
import org.elasticsearch.xpack.watcher.support.clock.Clock;
|
||||
import org.elasticsearch.xpack.support.clock.Clock;
|
||||
import org.elasticsearch.xpack.watcher.support.xcontent.WatcherParams;
|
||||
import org.elasticsearch.xpack.watcher.transport.actions.WatcherTransportAction;
|
||||
import org.elasticsearch.xpack.watcher.trigger.TriggerEvent;
|
||||
|
|
|
@ -9,7 +9,7 @@ import org.elasticsearch.common.Nullable;
|
|||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
import org.elasticsearch.xpack.watcher.support.WatcherDateTimeUtils;
|
||||
import org.elasticsearch.xpack.watcher.support.clock.Clock;
|
||||
import org.elasticsearch.xpack.support.clock.Clock;
|
||||
import org.elasticsearch.xpack.watcher.trigger.AbstractTriggerEngine;
|
||||
import org.elasticsearch.xpack.watcher.trigger.TriggerService;
|
||||
import org.joda.time.DateTime;
|
||||
|
|
|
@ -11,7 +11,7 @@ import org.elasticsearch.common.ParseFieldMatcher;
|
|||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
import org.elasticsearch.xpack.watcher.support.WatcherDateTimeUtils;
|
||||
import org.elasticsearch.xpack.watcher.support.clock.Clock;
|
||||
import org.elasticsearch.xpack.support.clock.Clock;
|
||||
import org.elasticsearch.xpack.watcher.trigger.TriggerEvent;
|
||||
import org.joda.time.DateTime;
|
||||
import org.joda.time.DateTimeZone;
|
||||
|
|
|
@ -9,7 +9,7 @@ import org.elasticsearch.common.inject.Inject;
|
|||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.util.concurrent.EsExecutors;
|
||||
import org.elasticsearch.common.util.concurrent.FutureUtils;
|
||||
import org.elasticsearch.xpack.watcher.support.clock.Clock;
|
||||
import org.elasticsearch.xpack.support.clock.Clock;
|
||||
import org.elasticsearch.xpack.watcher.trigger.TriggerEvent;
|
||||
import org.elasticsearch.xpack.watcher.trigger.schedule.Schedule;
|
||||
import org.elasticsearch.xpack.watcher.trigger.schedule.ScheduleRegistry;
|
||||
|
|
|
@ -8,7 +8,7 @@ package org.elasticsearch.xpack.watcher.trigger.schedule.engine;
|
|||
import org.elasticsearch.common.inject.Inject;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.unit.TimeValue;
|
||||
import org.elasticsearch.xpack.watcher.support.clock.Clock;
|
||||
import org.elasticsearch.xpack.support.clock.Clock;
|
||||
import org.elasticsearch.xpack.watcher.trigger.TriggerEvent;
|
||||
import org.elasticsearch.xpack.watcher.trigger.schedule.Schedule;
|
||||
import org.elasticsearch.xpack.watcher.trigger.schedule.ScheduleRegistry;
|
||||
|
|
|
@ -13,7 +13,6 @@ import org.elasticsearch.common.bytes.BytesReference;
|
|||
import org.elasticsearch.common.component.AbstractComponent;
|
||||
import org.elasticsearch.common.inject.Inject;
|
||||
import org.elasticsearch.common.lucene.uid.Versions;
|
||||
import org.elasticsearch.common.settings.Setting;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.unit.TimeValue;
|
||||
import org.elasticsearch.common.xcontent.ToXContent;
|
||||
|
@ -32,8 +31,8 @@ import org.elasticsearch.xpack.watcher.input.ExecutableInput;
|
|||
import org.elasticsearch.xpack.watcher.input.InputRegistry;
|
||||
import org.elasticsearch.xpack.watcher.input.none.ExecutableNoneInput;
|
||||
import org.elasticsearch.xpack.watcher.support.WatcherDateTimeUtils;
|
||||
import org.elasticsearch.xpack.watcher.support.clock.Clock;
|
||||
import org.elasticsearch.xpack.watcher.support.clock.HaltedClock;
|
||||
import org.elasticsearch.xpack.support.clock.Clock;
|
||||
import org.elasticsearch.xpack.support.clock.HaltedClock;
|
||||
import org.elasticsearch.xpack.common.secret.SecretService;
|
||||
import org.elasticsearch.xpack.watcher.support.xcontent.WatcherParams;
|
||||
import org.elasticsearch.xpack.watcher.support.xcontent.WatcherXContentParser;
|
||||
|
|
|
@ -19,7 +19,7 @@ import org.elasticsearch.common.xcontent.XContentParser;
|
|||
import org.elasticsearch.xpack.watcher.actions.Action;
|
||||
import org.elasticsearch.xpack.watcher.actions.ActionStatus;
|
||||
import org.elasticsearch.xpack.watcher.actions.throttler.AckThrottler;
|
||||
import org.elasticsearch.xpack.watcher.support.clock.SystemClock;
|
||||
import org.elasticsearch.xpack.support.clock.SystemClock;
|
||||
import org.elasticsearch.xpack.watcher.support.xcontent.WatcherXContentParser;
|
||||
import org.joda.time.DateTime;
|
||||
import org.joda.time.DateTimeZone;
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
},
|
||||
{
|
||||
"disabled_search_request_body_fields": {
|
||||
"path_match": "result\\.(input|(transform(\\..+)*)|(actions\\.transform(\\..+)*))\\.search\\.request\\.(body|template)",
|
||||
"path_match": "result\\.(input(\\..+)|(transform(\\..+)*)|(actions\\.transform(\\..+)*))\\.search\\.request\\.(body|template)",
|
||||
"match_pattern": "regex",
|
||||
"mapping": {
|
||||
"type": "object",
|
||||
|
|
|
@ -0,0 +1,52 @@
|
|||
/*
|
||||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
||||
* or more contributor license agreements. Licensed under the Elastic License;
|
||||
* you may not use this file except in compliance with the Elastic License.
|
||||
*/
|
||||
package org.elasticsearch.watcher.test.integration;
|
||||
|
||||
import org.elasticsearch.action.search.SearchRequestBuilder;
|
||||
import org.elasticsearch.action.search.SearchResponse;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.search.sort.SortBuilders;
|
||||
import org.elasticsearch.search.sort.SortOrder;
|
||||
import org.elasticsearch.xpack.watcher.actions.ActionBuilders;
|
||||
import org.elasticsearch.xpack.watcher.client.WatchSourceBuilder;
|
||||
import org.elasticsearch.xpack.watcher.client.WatchSourceBuilders;
|
||||
import org.elasticsearch.xpack.watcher.input.InputBuilders;
|
||||
import org.elasticsearch.xpack.watcher.test.AbstractWatcherIntegrationTestCase;
|
||||
import org.elasticsearch.xpack.watcher.transport.actions.put.PutWatchResponse;
|
||||
import org.elasticsearch.xpack.watcher.trigger.TriggerBuilders;
|
||||
import org.elasticsearch.xpack.watcher.trigger.schedule.Schedules;
|
||||
|
||||
import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder;
|
||||
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertHitCount;
|
||||
import static org.hamcrest.Matchers.is;
|
||||
|
||||
public class HistoryIntegrationTests extends AbstractWatcherIntegrationTestCase {
|
||||
|
||||
// issue: https://github.com/elastic/x-plugins/issues/2338
|
||||
public void testThatHistoryIsWrittenWithChainedInput() throws Exception {
|
||||
XContentBuilder xContentBuilder = jsonBuilder().startObject().startObject("inner").field("date", "2015-06-06").endObject()
|
||||
.endObject();
|
||||
index("foo", "bar", "1", xContentBuilder);
|
||||
refresh();
|
||||
|
||||
WatchSourceBuilder builder = WatchSourceBuilders.watchBuilder()
|
||||
.trigger(TriggerBuilders.schedule(Schedules.interval("10s")))
|
||||
.addAction("logging", ActionBuilders.loggingAction("foo"));
|
||||
|
||||
SearchRequestBuilder searchRequestBuilder = client().prepareSearch("foo").addSort(SortBuilders.fieldSort("inner.date").order
|
||||
(SortOrder.DESC));
|
||||
builder.input(InputBuilders.chainInput().add("first", InputBuilders.searchInput(searchRequestBuilder)));
|
||||
|
||||
PutWatchResponse response = watcherClient().preparePutWatch("test_watch").setSource(builder).get();
|
||||
assertThat(response.isCreated(), is(true));
|
||||
|
||||
watcherClient().prepareExecuteWatch("test_watch").setRecordExecution(true).get();
|
||||
|
||||
flushAndRefresh(".watcher-history-*");
|
||||
SearchResponse searchResponse = client().prepareSearch(".watcher-history-*").get();
|
||||
assertHitCount(searchResponse, 1);
|
||||
}
|
||||
}
|
|
@ -16,8 +16,8 @@ import org.elasticsearch.common.unit.TimeValue;
|
|||
import org.elasticsearch.test.ESTestCase;
|
||||
import org.elasticsearch.xpack.watcher.execution.ExecutionService;
|
||||
import org.elasticsearch.xpack.watcher.support.WatcherIndexTemplateRegistry;
|
||||
import org.elasticsearch.xpack.watcher.support.clock.ClockMock;
|
||||
import org.elasticsearch.xpack.watcher.support.clock.SystemClock;
|
||||
import org.elasticsearch.xpack.support.clock.ClockMock;
|
||||
import org.elasticsearch.xpack.support.clock.SystemClock;
|
||||
import org.elasticsearch.xpack.watcher.trigger.Trigger;
|
||||
import org.elasticsearch.xpack.watcher.trigger.TriggerEngine;
|
||||
import org.elasticsearch.xpack.watcher.trigger.TriggerService;
|
||||
|
|
|
@ -8,7 +8,7 @@ package org.elasticsearch.xpack.watcher.actions.throttler;
|
|||
import org.elasticsearch.test.ESTestCase;
|
||||
import org.elasticsearch.xpack.watcher.actions.ActionStatus;
|
||||
import org.elasticsearch.xpack.watcher.execution.WatchExecutionContext;
|
||||
import org.elasticsearch.xpack.watcher.support.clock.SystemClock;
|
||||
import org.elasticsearch.xpack.support.clock.SystemClock;
|
||||
import org.elasticsearch.xpack.watcher.watch.Watch;
|
||||
import org.elasticsearch.xpack.watcher.watch.WatchStatus;
|
||||
import org.joda.time.DateTime;
|
||||
|
|
|
@ -18,7 +18,7 @@ import org.elasticsearch.xpack.watcher.execution.ActionExecutionMode;
|
|||
import org.elasticsearch.xpack.watcher.execution.ExecutionState;
|
||||
import org.elasticsearch.xpack.watcher.execution.ManualExecutionContext;
|
||||
import org.elasticsearch.xpack.watcher.history.WatchRecord;
|
||||
import org.elasticsearch.xpack.watcher.support.clock.SystemClock;
|
||||
import org.elasticsearch.xpack.support.clock.SystemClock;
|
||||
import org.elasticsearch.xpack.common.http.HttpRequestTemplate;
|
||||
import org.elasticsearch.xpack.common.text.TextTemplate;
|
||||
import org.elasticsearch.xpack.watcher.support.xcontent.ObjectPath;
|
||||
|
|
|
@ -9,7 +9,7 @@ import org.elasticsearch.common.unit.TimeValue;
|
|||
import org.elasticsearch.test.ESTestCase;
|
||||
import org.elasticsearch.xpack.watcher.actions.ActionStatus;
|
||||
import org.elasticsearch.xpack.watcher.execution.WatchExecutionContext;
|
||||
import org.elasticsearch.xpack.watcher.support.clock.SystemClock;
|
||||
import org.elasticsearch.xpack.support.clock.SystemClock;
|
||||
import org.elasticsearch.xpack.watcher.watch.WatchStatus;
|
||||
import org.joda.time.PeriodType;
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ import org.elasticsearch.search.internal.InternalSearchHit;
|
|||
import org.elasticsearch.search.internal.InternalSearchHits;
|
||||
import org.elasticsearch.search.internal.InternalSearchResponse;
|
||||
import org.elasticsearch.xpack.watcher.execution.WatchExecutionContext;
|
||||
import org.elasticsearch.xpack.watcher.support.clock.SystemClock;
|
||||
import org.elasticsearch.xpack.support.clock.SystemClock;
|
||||
import org.elasticsearch.xpack.watcher.test.AbstractWatcherIntegrationTestCase;
|
||||
import org.elasticsearch.xpack.watcher.watch.Payload;
|
||||
|
||||
|
|
|
@ -13,8 +13,8 @@ import org.elasticsearch.common.xcontent.json.JsonXContent;
|
|||
import org.elasticsearch.test.ESTestCase;
|
||||
import org.elasticsearch.xpack.watcher.condition.compare.CompareCondition.Op;
|
||||
import org.elasticsearch.xpack.watcher.execution.WatchExecutionContext;
|
||||
import org.elasticsearch.xpack.watcher.support.clock.ClockMock;
|
||||
import org.elasticsearch.xpack.watcher.support.clock.SystemClock;
|
||||
import org.elasticsearch.xpack.support.clock.ClockMock;
|
||||
import org.elasticsearch.xpack.support.clock.SystemClock;
|
||||
import org.elasticsearch.xpack.watcher.watch.Payload;
|
||||
import org.joda.time.DateTime;
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ import org.elasticsearch.action.search.SearchResponse;
|
|||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.search.aggregations.AggregationBuilders;
|
||||
import org.elasticsearch.xpack.watcher.execution.WatchExecutionContext;
|
||||
import org.elasticsearch.xpack.watcher.support.clock.SystemClock;
|
||||
import org.elasticsearch.xpack.support.clock.SystemClock;
|
||||
import org.elasticsearch.xpack.watcher.test.AbstractWatcherIntegrationTestCase;
|
||||
import org.elasticsearch.xpack.watcher.watch.Payload;
|
||||
|
||||
|
|
|
@ -12,8 +12,8 @@ import org.elasticsearch.common.xcontent.XContentParser;
|
|||
import org.elasticsearch.common.xcontent.json.JsonXContent;
|
||||
import org.elasticsearch.test.ESTestCase;
|
||||
import org.elasticsearch.xpack.watcher.execution.WatchExecutionContext;
|
||||
import org.elasticsearch.xpack.watcher.support.clock.ClockMock;
|
||||
import org.elasticsearch.xpack.watcher.support.clock.SystemClock;
|
||||
import org.elasticsearch.xpack.support.clock.ClockMock;
|
||||
import org.elasticsearch.xpack.support.clock.SystemClock;
|
||||
import org.elasticsearch.xpack.watcher.watch.Payload;
|
||||
import org.junit.Rule;
|
||||
import org.junit.rules.ExpectedException;
|
||||
|
|
|
@ -23,8 +23,8 @@ import org.elasticsearch.xpack.watcher.history.HistoryStore;
|
|||
import org.elasticsearch.xpack.watcher.history.WatchRecord;
|
||||
import org.elasticsearch.xpack.watcher.input.ExecutableInput;
|
||||
import org.elasticsearch.xpack.watcher.input.Input;
|
||||
import org.elasticsearch.xpack.watcher.support.clock.Clock;
|
||||
import org.elasticsearch.xpack.watcher.support.clock.ClockMock;
|
||||
import org.elasticsearch.xpack.support.clock.Clock;
|
||||
import org.elasticsearch.xpack.support.clock.ClockMock;
|
||||
import org.elasticsearch.xpack.watcher.support.validation.WatcherSettingsValidation;
|
||||
import org.elasticsearch.xpack.watcher.transform.ExecutableTransform;
|
||||
import org.elasticsearch.xpack.watcher.transform.Transform;
|
||||
|
|
|
@ -17,7 +17,7 @@ import org.elasticsearch.xpack.watcher.condition.always.AlwaysCondition;
|
|||
import org.elasticsearch.xpack.watcher.history.HistoryStore;
|
||||
import org.elasticsearch.xpack.watcher.history.WatchRecord;
|
||||
import org.elasticsearch.xpack.watcher.input.simple.SimpleInput;
|
||||
import org.elasticsearch.xpack.watcher.support.clock.SystemClock;
|
||||
import org.elasticsearch.xpack.support.clock.SystemClock;
|
||||
import org.elasticsearch.xpack.watcher.support.xcontent.ObjectPath;
|
||||
import org.elasticsearch.xpack.watcher.test.AbstractWatcherIntegrationTestCase;
|
||||
import org.elasticsearch.xpack.watcher.transport.actions.execute.ExecuteWatchRequest;
|
||||
|
|
|
@ -21,7 +21,8 @@ import static org.hamcrest.core.Is.is;
|
|||
/**
|
||||
*/
|
||||
@TestLogging("cluster:DEBUG,action.admin.cluster.settings:DEBUG,watcher:DEBUG")
|
||||
@ESIntegTestCase.ClusterScope(scope = TEST, numClientNodes = 0, transportClientRatio = 0, randomDynamicTemplates = false, numDataNodes = 1)
|
||||
@ESIntegTestCase.ClusterScope(scope = TEST, numClientNodes = 0, transportClientRatio = 0, randomDynamicTemplates = false,
|
||||
supportsDedicatedMasters = false, numDataNodes = 1)
|
||||
public class HistoryStoreSettingsTests extends AbstractWatcherIntegrationTestCase {
|
||||
|
||||
public void testChangeSettings() throws Exception {
|
||||
|
|
|
@ -11,7 +11,6 @@ import org.elasticsearch.common.settings.Settings;
|
|||
import org.elasticsearch.common.settings.SettingsModule;
|
||||
import org.elasticsearch.plugins.Plugin;
|
||||
import org.elasticsearch.test.ESIntegTestCase;
|
||||
import org.elasticsearch.xpack.watcher.WatcherModule;
|
||||
import org.elasticsearch.xpack.watcher.test.AbstractWatcherIntegrationTestCase;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
@ -25,7 +24,8 @@ import static org.hamcrest.core.Is.is;
|
|||
|
||||
/**
|
||||
*/
|
||||
@ESIntegTestCase.ClusterScope(scope = TEST, numClientNodes = 0, transportClientRatio = 0, randomDynamicTemplates = false, numDataNodes = 1)
|
||||
@ESIntegTestCase.ClusterScope(scope = TEST, numClientNodes = 0, transportClientRatio = 0, randomDynamicTemplates = false,
|
||||
supportsDedicatedMasters = false, numDataNodes = 1)
|
||||
public class WatcherIndexTemplateRegistryTests extends AbstractWatcherIntegrationTestCase {
|
||||
|
||||
@Override
|
||||
|
|
|
@ -45,7 +45,7 @@ import org.elasticsearch.script.Template;
|
|||
import org.elasticsearch.search.builder.SearchSourceBuilder;
|
||||
import org.elasticsearch.test.ESTestCase;
|
||||
import org.elasticsearch.xpack.watcher.input.search.ExecutableSearchInput;
|
||||
import org.elasticsearch.xpack.watcher.support.clock.SystemClock;
|
||||
import org.elasticsearch.xpack.support.clock.SystemClock;
|
||||
import org.elasticsearch.xpack.common.text.TextTemplate;
|
||||
import org.joda.time.DateTime;
|
||||
|
||||
|
|
|
@ -48,7 +48,7 @@ import org.elasticsearch.xpack.watcher.execution.ExecutionState;
|
|||
import org.elasticsearch.xpack.watcher.history.HistoryStore;
|
||||
import org.elasticsearch.xpack.watcher.WatcherLicensee;
|
||||
import org.elasticsearch.xpack.watcher.support.WatcherIndexTemplateRegistry;
|
||||
import org.elasticsearch.xpack.watcher.support.clock.ClockMock;
|
||||
import org.elasticsearch.xpack.support.clock.ClockMock;
|
||||
import org.elasticsearch.xpack.common.http.HttpClient;
|
||||
import org.elasticsearch.xpack.common.ScriptServiceProxy;
|
||||
import org.elasticsearch.xpack.watcher.support.xcontent.XContentSource;
|
||||
|
|
|
@ -12,9 +12,6 @@ import org.elasticsearch.xpack.watcher.Watcher;
|
|||
import org.elasticsearch.xpack.watcher.execution.ExecutionModule;
|
||||
import org.elasticsearch.xpack.watcher.execution.SyncTriggerListener;
|
||||
import org.elasticsearch.xpack.watcher.execution.WatchExecutor;
|
||||
import org.elasticsearch.xpack.watcher.support.clock.Clock;
|
||||
import org.elasticsearch.xpack.watcher.support.clock.ClockMock;
|
||||
import org.elasticsearch.xpack.watcher.support.clock.ClockModule;
|
||||
import org.elasticsearch.xpack.watcher.trigger.ScheduleTriggerEngineMock;
|
||||
import org.elasticsearch.xpack.watcher.trigger.TriggerModule;
|
||||
import org.elasticsearch.xpack.watcher.trigger.manual.ManualTriggerEngine;
|
||||
|
@ -49,10 +46,6 @@ public class TimeWarpedWatcher extends Watcher {
|
|||
// replacing scheduler module so we'll
|
||||
// have control on when it fires a job
|
||||
modules.set(i, new MockTriggerModule(settings));
|
||||
} else if (module instanceof ClockModule) {
|
||||
// replacing the clock module so we'll be able
|
||||
// to control time in tests
|
||||
modules.set(i, new MockClockModule());
|
||||
} else if (module instanceof ExecutionModule) {
|
||||
// replacing the execution module so all the watches will be
|
||||
// executed on the same thread as the trigger engine
|
||||
|
@ -76,14 +69,6 @@ public class TimeWarpedWatcher extends Watcher {
|
|||
}
|
||||
}
|
||||
|
||||
public static class MockClockModule extends ClockModule {
|
||||
@Override
|
||||
protected void configure() {
|
||||
bind(ClockMock.class).asEagerSingleton();
|
||||
bind(Clock.class).to(ClockMock.class);
|
||||
}
|
||||
}
|
||||
|
||||
public static class MockExecutionModule extends ExecutionModule {
|
||||
|
||||
public MockExecutionModule() {
|
||||
|
|
|
@ -9,7 +9,7 @@ import org.elasticsearch.common.Randomness;
|
|||
import org.elasticsearch.common.SuppressForbidden;
|
||||
import org.elasticsearch.common.metrics.MeanMetric;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.xpack.watcher.support.clock.SystemClock;
|
||||
import org.elasticsearch.xpack.support.clock.SystemClock;
|
||||
import org.elasticsearch.xpack.watcher.trigger.Trigger;
|
||||
import org.elasticsearch.xpack.watcher.trigger.TriggerEngine;
|
||||
import org.elasticsearch.xpack.watcher.trigger.TriggerEvent;
|
||||
|
|
|
@ -34,7 +34,7 @@ import org.elasticsearch.xpack.watcher.actions.logging.LoggingLevel;
|
|||
import org.elasticsearch.xpack.watcher.client.WatchSourceBuilder;
|
||||
import org.elasticsearch.xpack.watcher.client.WatcherClient;
|
||||
import org.elasticsearch.xpack.watcher.history.HistoryStore;
|
||||
import org.elasticsearch.xpack.watcher.support.clock.Clock;
|
||||
import org.elasticsearch.xpack.support.clock.Clock;
|
||||
import org.elasticsearch.xpack.watcher.watch.WatchStore;
|
||||
import org.elasticsearch.xpack.XPackPlugin;
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ import org.elasticsearch.xpack.watcher.client.WatchSourceBuilder;
|
|||
import org.elasticsearch.xpack.watcher.client.WatcherClient;
|
||||
import org.elasticsearch.xpack.watcher.condition.compare.CompareCondition;
|
||||
import org.elasticsearch.xpack.watcher.support.WatcherUtils;
|
||||
import org.elasticsearch.xpack.watcher.support.clock.SystemClock;
|
||||
import org.elasticsearch.xpack.support.clock.SystemClock;
|
||||
import org.elasticsearch.xpack.watcher.support.xcontent.XContentSource;
|
||||
import org.elasticsearch.xpack.watcher.test.AbstractWatcherIntegrationTestCase;
|
||||
import org.elasticsearch.xpack.watcher.transport.actions.delete.DeleteWatchResponse;
|
||||
|
|
|
@ -11,8 +11,8 @@ import org.elasticsearch.common.logging.Loggers;
|
|||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.unit.TimeValue;
|
||||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
import org.elasticsearch.xpack.watcher.support.clock.Clock;
|
||||
import org.elasticsearch.xpack.watcher.support.clock.ClockMock;
|
||||
import org.elasticsearch.xpack.support.clock.Clock;
|
||||
import org.elasticsearch.xpack.support.clock.ClockMock;
|
||||
import org.elasticsearch.xpack.watcher.trigger.schedule.ScheduleRegistry;
|
||||
import org.elasticsearch.xpack.watcher.trigger.schedule.ScheduleTrigger;
|
||||
import org.elasticsearch.xpack.watcher.trigger.schedule.ScheduleTriggerEngine;
|
||||
|
|
|
@ -11,7 +11,7 @@ import org.elasticsearch.common.xcontent.XContentFactory;
|
|||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
import org.elasticsearch.common.xcontent.json.JsonXContent;
|
||||
import org.elasticsearch.test.ESTestCase;
|
||||
import org.elasticsearch.xpack.watcher.support.clock.SystemClock;
|
||||
import org.elasticsearch.xpack.support.clock.SystemClock;
|
||||
|
||||
import static org.hamcrest.Matchers.is;
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
package org.elasticsearch.xpack.watcher.trigger.schedule.engine;
|
||||
|
||||
import org.elasticsearch.test.ESTestCase;
|
||||
import org.elasticsearch.xpack.watcher.support.clock.SystemClock;
|
||||
import org.elasticsearch.xpack.support.clock.SystemClock;
|
||||
import org.elasticsearch.xpack.watcher.trigger.Trigger;
|
||||
import org.elasticsearch.xpack.watcher.trigger.TriggerEngine;
|
||||
import org.elasticsearch.xpack.watcher.trigger.TriggerEvent;
|
||||
|
|
|
@ -7,7 +7,7 @@ package org.elasticsearch.xpack.watcher.trigger.schedule.engine;
|
|||
|
||||
import org.apache.lucene.util.LuceneTestCase.BadApple;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.xpack.watcher.support.clock.SystemClock;
|
||||
import org.elasticsearch.xpack.support.clock.SystemClock;
|
||||
import org.elasticsearch.xpack.watcher.trigger.TriggerEngine;
|
||||
import org.elasticsearch.xpack.watcher.trigger.schedule.ScheduleRegistry;
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@ package org.elasticsearch.xpack.watcher.trigger.schedule.engine;
|
|||
|
||||
import org.apache.lucene.util.LuceneTestCase.BadApple;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.xpack.watcher.support.clock.SystemClock;
|
||||
import org.elasticsearch.xpack.support.clock.SystemClock;
|
||||
import org.elasticsearch.xpack.watcher.trigger.TriggerEngine;
|
||||
import org.elasticsearch.xpack.watcher.trigger.schedule.ScheduleRegistry;
|
||||
|
||||
|
|
|
@ -71,9 +71,9 @@ import org.elasticsearch.xpack.watcher.input.simple.SimpleInputFactory;
|
|||
import org.elasticsearch.xpack.watcher.WatcherLicensee;
|
||||
import org.elasticsearch.xpack.watcher.support.Script;
|
||||
import org.elasticsearch.xpack.watcher.support.WatcherUtils;
|
||||
import org.elasticsearch.xpack.watcher.support.clock.Clock;
|
||||
import org.elasticsearch.xpack.watcher.support.clock.ClockMock;
|
||||
import org.elasticsearch.xpack.watcher.support.clock.SystemClock;
|
||||
import org.elasticsearch.xpack.support.clock.Clock;
|
||||
import org.elasticsearch.xpack.support.clock.ClockMock;
|
||||
import org.elasticsearch.xpack.support.clock.SystemClock;
|
||||
import org.elasticsearch.xpack.common.http.HttpClient;
|
||||
import org.elasticsearch.xpack.common.http.HttpMethod;
|
||||
import org.elasticsearch.xpack.common.http.HttpRequestTemplate;
|
||||
|
|
Loading…
Reference in New Issue