use of org.apache.http.auth.Credentials in project janusgraph by JanusGraph.
the class RestClientSetupTest method testHttpBasicAuthConfiguration.
@Test
public void testHttpBasicAuthConfiguration() throws Exception {
// testing that the appropriate values are passed to the client builder via credentials provider
final String testRealm = "testRealm";
final String testUser = "testUser";
final String testPassword = "testPassword";
final CredentialsProvider cp = basicAuthTestBase(ImmutableMap.<String, String>builder().build(), testRealm, testUser, testPassword);
final Credentials credentials = cp.getCredentials(new AuthScope(AuthScope.ANY_HOST, AuthScope.ANY_PORT, testRealm));
assertNotNull(credentials);
assertEquals(testUser, credentials.getUserPrincipal().getName());
assertEquals(testPassword, credentials.getPassword());
}
use of org.apache.http.auth.Credentials in project janusgraph by JanusGraph.
the class BasicAuthHttpClientConfigCallbackTest method testSetDefaultCredentialsProviderNoRealm.
@Test
public void testSetDefaultCredentialsProviderNoRealm() throws Exception {
final CredentialsProvider cp = basicAuthTestBase("");
// expected: will match any host and any realm
final Credentials credentialsForRealm1 = cp.getCredentials(new AuthScope("dummyhost1", 1234, "dummyrealm1"));
assertEquals(HTTP_USER, credentialsForRealm1.getUserPrincipal().getName());
assertEquals(HTTP_PASSWORD, credentialsForRealm1.getPassword());
}
Aggregations