HaloAuthenticator implements Authenticator { public void flushSession() { mSessionManager.flushSession(HaloAuthenticator.HALO_SESSION_NAME); } HaloAuthenticator(@NonNull HaloFramework framework,
                             @NonNull HaloManagerApi managerApi,
                             @NonNull HaloSessionManager sessionManager,
                             @NonNull Credentials credentials); @Override synchronized Request authenticate(Route route, Response response); void setAuthenticationRecover(@NonNull AuthenticationRecover authenticationRecover); @Nullable AuthenticationRecover getAuthenticationRecover(); synchronized void setCredentials(@NonNull Credentials credentials); void logout(); @NonNull synchronized Credentials getCredentials(); void flushSession(); HaloSessionManager getSessionManager(); @Keep
    static final String HALO_SESSION_NAME; static final String AUTHENTICATION_HEADER; }
@Test public void thatCanFlushASession() { mSessionManager.setSession(HaloAuthenticator.HALO_SESSION_NAME, new Session(givenAToken())); mAuthenticator.flushSession(); assertThat(mSessionManager.getSession(HaloAuthenticator.HALO_SESSION_NAME)).isNull(); }
@Test public void thatSessionHeaderInterceptsNoSession() throws IOException { mSessionManager.flushSession(HaloAuthenticator.HALO_SESSION_NAME); Interceptor.Chain chain = mock(Interceptor.Chain.class); Interceptor interceptor = mFramework.network().client().ok().interceptors().get(0); when(chain.request()).thenReturn(new Request.Builder().url("http: when(chain.proceed(any(Request.class))).thenAnswer(new Answer<Object>() { @Override public Object answer(InvocationOnMock invocation) throws Throwable { assertThat(((Request) invocation.getArguments()[0]).headers("Authorization").isEmpty()).isTrue(); return null; } }); interceptor.intercept(chain); }