test: reset anonymous after test to avoid messing with other tests
Closes elastic/elasticsearch#1956 Original commit: elastic/x-pack-elasticsearch@9b57d295c8
This commit is contained in:
parent
931c67b49c
commit
b56e2f3bca
|
@ -28,6 +28,7 @@ import org.elasticsearch.test.ESTestCase;
|
|||
import org.elasticsearch.test.rest.FakeRestRequest;
|
||||
import org.elasticsearch.threadpool.ThreadPool;
|
||||
import org.elasticsearch.transport.TransportMessage;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.rules.ExpectedException;
|
||||
|
@ -105,11 +106,15 @@ public class InternalAuthenticationServiceTests extends ESTestCase {
|
|||
threadPool = mock(ThreadPool.class);
|
||||
threadContext = new ThreadContext(Settings.EMPTY);
|
||||
when(threadPool.getThreadContext()).thenReturn(threadContext);
|
||||
AnonymousUser.initialize(Settings.EMPTY);
|
||||
service = new InternalAuthenticationService(Settings.EMPTY, realms, auditTrail, cryptoService,
|
||||
new DefaultAuthenticationFailureHandler(), threadPool);
|
||||
}
|
||||
|
||||
@After
|
||||
public void resetAnonymous() {
|
||||
AnonymousUser.initialize(Settings.EMPTY);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public void testTokenFirstMissingSecondFound() throws Exception {
|
||||
when(firstRealm.token(threadContext)).thenReturn(null);
|
||||
|
|
|
@ -70,6 +70,7 @@ import org.elasticsearch.shield.authz.store.RolesStore;
|
|||
import org.elasticsearch.test.ESTestCase;
|
||||
import org.elasticsearch.threadpool.ThreadPool;
|
||||
import org.elasticsearch.transport.TransportRequest;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
@ -104,11 +105,15 @@ public class InternalAuthorizationServiceTests extends ESTestCase {
|
|||
threadPool = mock(ThreadPool.class);
|
||||
when(threadPool.getThreadContext()).thenReturn(threadContext);
|
||||
|
||||
AnonymousUser.initialize(Settings.EMPTY);
|
||||
internalAuthorizationService = new InternalAuthorizationService(Settings.EMPTY, rolesStore, clusterService,
|
||||
auditTrail, new DefaultAuthenticationFailureHandler(), threadPool);
|
||||
}
|
||||
|
||||
@After
|
||||
public void resetAnonymous() {
|
||||
AnonymousUser.initialize(Settings.EMPTY);
|
||||
}
|
||||
|
||||
public void testActionsSystemUserIsAuthorized() {
|
||||
TransportRequest request = mock(TransportRequest.class);
|
||||
|
||||
|
|
Loading…
Reference in New Issue