use of com.burgstaller.okhttp.digest.Credentials in project okhttp-digest by rburgst.
the class BasicAuthenticatorWithMockWebserverTest method setUp.
@Before
public void setUp() throws Exception {
credentials = new Credentials("user1", "user1");
sut = new BasicAuthenticator(credentials);
OkHttpClient.Builder builder = new OkHttpClient.Builder();
final Map<String, CachingAuthenticator> authCache = new ConcurrentHashMap<>();
HttpLoggingInterceptor logger = new HttpLoggingInterceptor(new StdOutLogger());
logger.setLevel(HttpLoggingInterceptor.Level.HEADERS);
spy = spy(sut);
client = builder.authenticator(new CachingAuthenticatorDecorator(spy, authCache)).addInterceptor(new AuthenticationCacheInterceptor(authCache)).addNetworkInterceptor(logger).build();
unauthorizedResponse = new MockResponse().setResponseCode(401).addHeader("WWW-Authenticate", "Basic realm=\"myrealm\"");
successResponse = new MockResponse().setBody("OK");
}
Aggregations