diff --git a/watcher/pom.xml b/watcher/pom.xml
index 181579c6135..e52fbc98a0a 100644
--- a/watcher/pom.xml
+++ b/watcher/pom.xml
@@ -24,6 +24,7 @@
dev-tools/integration-tests.xml
false
true
+ hijack/10_basic/*
diff --git a/watcher/src/test/java/org/elasticsearch/watcher/test/rest/WatcherDisabledLicenseRestTests.java b/watcher/src/test/java/org/elasticsearch/watcher/test/rest/WatcherDisabledLicenseRestTests.java
index ba12e1229eb..75df4daf8d3 100644
--- a/watcher/src/test/java/org/elasticsearch/watcher/test/rest/WatcherDisabledLicenseRestTests.java
+++ b/watcher/src/test/java/org/elasticsearch/watcher/test/rest/WatcherDisabledLicenseRestTests.java
@@ -31,16 +31,14 @@ public class WatcherDisabledLicenseRestTests extends WatcherRestTests {
@Test
public void test() throws IOException {
- disableLicensing();
try {
+ disableLicensing();
super.test();
fail();
- } catch(AssertionError ae) {
- if (ae.getMessage() == null || ae.getMessage().contains("not supported")){
- //This was a test testing the "hijacked" methods
- return;
- }
- assertThat(ae.getMessage(), containsString("license expired for feature [watcher]"));
+ } catch(AssertionError e) {
+ assertThat(e.getMessage(), containsString("license expired for feature [watcher]"));
+ } finally {
+ enableLicensing();
}
}
@@ -49,4 +47,15 @@ public class WatcherDisabledLicenseRestTests extends WatcherRestTests {
service.disable();
}
}
+
+ public static void enableLicensing() {
+ for (MockLicenseService service : internalCluster().getInstances(MockLicenseService.class)) {
+ service.enable();
+ }
+ }
+
+ @Override
+ protected boolean enableShield() {
+ return false;
+ }
}
diff --git a/watcher/src/test/java/org/elasticsearch/watcher/test/rest/WatcherShieldAuthorizationFailedRestTests.java b/watcher/src/test/java/org/elasticsearch/watcher/test/rest/WatcherShieldAuthorizationFailedRestTests.java
index 2fc4a8238e5..b5ebd58690e 100644
--- a/watcher/src/test/java/org/elasticsearch/watcher/test/rest/WatcherShieldAuthorizationFailedRestTests.java
+++ b/watcher/src/test/java/org/elasticsearch/watcher/test/rest/WatcherShieldAuthorizationFailedRestTests.java
@@ -6,27 +6,13 @@
package org.elasticsearch.watcher.test.rest;
import com.carrotsearch.randomizedtesting.annotations.Name;
-import org.elasticsearch.ElasticsearchException;
import org.elasticsearch.client.support.Headers;
-import org.elasticsearch.common.io.FileSystemUtils;
-import org.elasticsearch.common.io.Streams;
import org.elasticsearch.common.settings.Settings;
-import org.elasticsearch.license.plugin.LicensePlugin;
-import org.elasticsearch.node.Node;
-import org.elasticsearch.plugins.PluginsService;
-import org.elasticsearch.shield.ShieldPlugin;
-import org.elasticsearch.shield.authc.esusers.ESUsersRealm;
-import org.elasticsearch.shield.authc.support.Hasher;
import org.elasticsearch.shield.authc.support.SecuredString;
import org.elasticsearch.test.rest.RestTestCandidate;
-import org.elasticsearch.watcher.WatcherPlugin;
-import org.elasticsearch.watcher.test.AbstractWatcherIntegrationTests;
import org.junit.Test;
-import java.io.File;
import java.io.IOException;
-import java.nio.file.Files;
-import java.nio.file.Path;
import static org.elasticsearch.shield.authc.support.UsernamePasswordToken.basicAuthHeaderValue;
import static org.hamcrest.Matchers.containsString;
@@ -50,12 +36,16 @@ public class WatcherShieldAuthorizationFailedRestTests extends WatcherRestTests
super.test();
fail();
} catch(AssertionError ae) {
- if (ae.getMessage() == null || ae.getMessage().contains("not supported")){
- //This was a test testing the "hijacked" methods
- return;
- }
assertThat(ae.getMessage(), containsString("returned [403 Forbidden]"));
- assertThat(ae.getMessage(), containsString("is unauthorized for user [admin]"));
+ assertThat(ae.getMessage(), containsString("is unauthorized for user [test]"));
}
}
+
+ @Override
+ protected Settings restClientSettings() {
+ String token = basicAuthHeaderValue("test", new SecuredString("changeme".toCharArray()));
+ return Settings.builder()
+ .put(Headers.PREFIX + ".Authorization", token)
+ .build();
+ }
}