shield rest tests use the ElasticsearchRestTestCase nodeSettings

Original commit: elastic/x-pack-elasticsearch@855014dd4b
This commit is contained in:
jaymode 2015-07-16 06:19:57 -04:00
parent d6d13661e8
commit f95f86764c
1 changed files with 27 additions and 19 deletions

View File

@ -38,32 +38,16 @@ import static org.elasticsearch.shield.authc.support.UsernamePasswordToken.basic
@Slow
public abstract class ShieldRestTestCase extends ShieldIntegrationTest {
private final ElasticsearchRestTestCase delegate;
private final DelegatedRestTestCase delegate;
public ShieldRestTestCase(@Name("yaml") RestTestCandidate testCandidate) {
delegate = new ElasticsearchRestTestCase(testCandidate) {
@Override
protected Settings restClientSettings() {
return Settings.builder()
.put(Headers.PREFIX + "." + UsernamePasswordToken.BASIC_AUTH_HEADER, basicAuthHeaderValue(ShieldSettingsSource.DEFAULT_USER_NAME,
new SecuredString(ShieldSettingsSource.DEFAULT_PASSWORD.toCharArray()))).build();
}
@Override
protected Settings nodeSettings(int nodeOrdinal) {
return ShieldRestTestCase.this.nodeSettings(nodeOrdinal);
}
@Override
protected Settings transportClientSettings() {
return ShieldRestTestCase.this.transportClientSettings();
}
};
delegate = new DelegatedRestTestCase(testCandidate);
}
@Override
protected Settings nodeSettings(int nodeOrdinal) {
return Settings.builder()
.put(delegate.nodeSettings(nodeOrdinal))
.put(super.nodeSettings(nodeOrdinal))
.put(Node.HTTP_ENABLED, true)
.build();
@ -88,4 +72,28 @@ public abstract class ShieldRestTestCase extends ShieldIntegrationTest {
public void reset() throws IOException, RestException {
delegate.reset();
}
class DelegatedRestTestCase extends ElasticsearchRestTestCase {
DelegatedRestTestCase(RestTestCandidate candidate) {
super(candidate);
}
@Override
protected Settings restClientSettings() {
return Settings.builder()
.put(Headers.PREFIX + "." + UsernamePasswordToken.BASIC_AUTH_HEADER, basicAuthHeaderValue(ShieldSettingsSource.DEFAULT_USER_NAME,
new SecuredString(ShieldSettingsSource.DEFAULT_PASSWORD.toCharArray()))).build();
}
@Override
public Settings nodeSettings(int ordinal) {
return super.nodeSettings(ordinal);
}
@Override
protected Settings transportClientSettings() {
return ShieldRestTestCase.this.transportClientSettings();
}
}
}