use of com.ibm.cloud.cloudant.security.CouchDbSessionAuthenticator in project cloudant-java-sdk by IBM.
the class DelegatingAuthenticatorFactoryTest method getAuthenticatorForSessionAuthType.
@Test
void getAuthenticatorForSessionAuthType() {
Authenticator authenticator = DelegatingAuthenticatorFactory.getAuthenticator("test", getServicePropsWithAuthType(Authenticator.PROPNAME_AUTH_TYPE, "COUCHDB_SESSION"));
assertTrue(authenticator instanceof CouchDbSessionAuthenticator, "Should return an " + "instance of CouchDbSessionAuthenticator");
}
use of com.ibm.cloud.cloudant.security.CouchDbSessionAuthenticator in project cloudant-java-sdk by IBM.
the class DelegatingAuthenticatorFactoryTest method getAuthenticatorForSessionAuthTypeAlias.
@Test
void getAuthenticatorForSessionAuthTypeAlias() {
Authenticator authenticator = DelegatingAuthenticatorFactory.getAuthenticator("test", getServicePropsWithAuthType("AUTHTYPE", "COUCHDB_SESSION"));
assertTrue(authenticator instanceof CouchDbSessionAuthenticator, "Should return an " + "instance of CouchDbSessionAuthenticator");
}
use of com.ibm.cloud.cloudant.security.CouchDbSessionAuthenticator in project cloudant-java-sdk by IBM.
the class DelegatingAuthenticatorFactoryTest method getAuthenticatorForOtherAuthType.
@Test
void getAuthenticatorForOtherAuthType() {
Authenticator authenticator = DelegatingAuthenticatorFactory.getAuthenticator("test", getServicePropsWithAuthType(Authenticator.PROPNAME_AUTH_TYPE, "BASIC"));
assertFalse(authenticator instanceof CouchDbSessionAuthenticator, "Should not return " + "an instance of CouchDbSessionAuthenticator");
}
use of com.ibm.cloud.cloudant.security.CouchDbSessionAuthenticator in project cloudant-java-sdk by IBM.
the class SdkTimeoutTest method testSessionAuthTimeout.
@Test
void testSessionAuthTimeout() throws NoSuchFieldException, IllegalAccessException {
CouchDbSessionAuthenticator sessionAuth = (CouchDbSessionAuthenticator) CouchDbSessionAuthenticator.newAuthenticator("user", "pass");
CloudantBaseService myService = createCloudantBaseService(sessionAuth, "http://" + mockedServer.getHostName() + ":" + mockedServer.getPort());
Request testRequest = createTestRequest(myService);
for (int i = 0; i < 2; i++) {
setupSessionAuthRespones();
if (i == 1) {
setCustomTimeout(myService, testCases[i]);
}
RealCall testRequestCall = createServiceCall(myService, testRequest);
assertEquals(TimeUnit.MILLISECONDS.toSeconds(testRequestCall.getClient().readTimeoutMillis()), testCases[i]);
CouchDbSessionAuthenticator auth = (CouchDbSessionAuthenticator) myService.getAuthenticator();
Field clientField = auth.getClass().getDeclaredField("client");
clientField.setAccessible(true);
OkHttpClient c = (OkHttpClient) clientField.get(auth);
assertEquals(TimeUnit.MILLISECONDS.toSeconds(c.readTimeoutMillis()), authenticationTimeoutValue);
}
}
Aggregations