[TEST] fix apache ds cleanup issues

Original commit: elastic/x-pack-elasticsearch@235a5de900
This commit is contained in:
javanna 2014-09-19 15:01:19 +02:00 committed by Luca Cavanna
parent d5d4be018d
commit 932cfd9a33
2 changed files with 15 additions and 5 deletions

View File

@ -8,6 +8,7 @@ package org.elasticsearch.shield.authc.ldap;
import org.elasticsearch.common.settings.ImmutableSettings;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.test.ElasticsearchTestCase;
import org.junit.AfterClass;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
@ -26,6 +27,12 @@ public class LdapConnectionTests extends ElasticsearchTestCase {
@Rule
public static ApacheDsRule apacheDsRule = new ApacheDsRule(temporaryFolder);
@AfterClass
public static void cleanup() {
temporaryFolder = null;
apacheDsRule = null;
}
@Test
public void testBindWithTemplates() {
String[] ldapUrls = new String[]{apacheDsRule.getUrl()};
@ -45,7 +52,7 @@ public class LdapConnectionTests extends ElasticsearchTestCase {
LdapConnection ldap = connectionFactory.bind(user, userPass);
Map<String, String[]> attrs = ldap.getUserAttrs(ldap.getAuthenticatedUserDn());
assertThat( attrs, hasKey("uid"));
assertThat(attrs, hasKey("uid"));
assertThat( attrs.get("uid"), arrayContaining("hhornblo"));
}
@Test

View File

@ -14,10 +14,7 @@ import org.elasticsearch.shield.authc.support.UsernamePasswordToken;
import org.elasticsearch.test.ElasticsearchTestCase;
import org.elasticsearch.threadpool.ThreadPool;
import org.elasticsearch.watcher.ResourceWatcherService;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Rule;
import org.junit.Test;
import org.junit.*;
import org.junit.rules.TemporaryFolder;
import static org.hamcrest.Matchers.*;
@ -47,6 +44,12 @@ public class LdapRealmTest extends ElasticsearchTestCase {
@Rule
public static ApacheDsRule apacheDsRule = new ApacheDsRule(temporaryFolder);
@AfterClass
public static void cleanup() {
temporaryFolder = null;
apacheDsRule = null;
}
@Test
public void testRestHeaderRegistration() {
new LdapRealm(ImmutableSettings.EMPTY, mock(LdapConnectionFactory.class), mock(LdapGroupToRoleMapper.class), restController);