Fixed rest runners that check watcher+shield and an expired license.
* The watcher+shield test failed, but the error was ignored due to a buggy if statement that existed for the hijack rest test. * Blacklisted the hijack test. * Also ade sure that we run the watcher+rest test with an user that doesn't have credentials. Original commit: elastic/x-pack-elasticsearch@61b1bf0142
This commit is contained in:
parent
1b72f13458
commit
f726a8a017
|
@ -24,6 +24,7 @@
|
|||
<elasticsearch.integ.antfile>dev-tools/integration-tests.xml</elasticsearch.integ.antfile>
|
||||
<tests.rest.load_packaged>false</tests.rest.load_packaged>
|
||||
<tests.timewarp>true</tests.timewarp>
|
||||
<tests.rest.blacklist>hijack/10_basic/*</tests.rest.blacklist>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue