use of org.apereo.cas.couchbase.core.DefaultCouchbaseClientFactory in project cas by apereo.
the class CouchbaseAuthenticationHandlerTests method verifyBadRecord.
@Test
public void verifyBadRecord() {
val props = casProperties.getAuthn().getCouchbase();
val factory = new DefaultCouchbaseClientFactory(props);
val handler = new CouchbaseAuthenticationHandler(mock(ServicesManager.class), PrincipalFactoryUtils.newPrincipalFactory(), factory, props);
handler.setPasswordEncoder(new SCryptPasswordEncoder());
val c = CoreAuthenticationTestUtils.getCredentialsWithDifferentUsernameAndPassword("nopsw", "Mellon");
assertThrows(FailedLoginException.class, () -> handler.authenticate(c));
}
use of org.apereo.cas.couchbase.core.DefaultCouchbaseClientFactory in project cas by apereo.
the class CouchbaseAuthenticationHandlerTests method verifyMissingUser.
@Test
public void verifyMissingUser() {
val props = casProperties.getAuthn().getCouchbase();
val factory = new DefaultCouchbaseClientFactory(props);
val handler = new CouchbaseAuthenticationHandler(mock(ServicesManager.class), PrincipalFactoryUtils.newPrincipalFactory(), factory, props);
val c = CoreAuthenticationTestUtils.getCredentialsWithDifferentUsernameAndPassword("casuser-missing", "Mellon");
assertThrows(AccountNotFoundException.class, () -> handler.authenticate(c));
}
use of org.apereo.cas.couchbase.core.DefaultCouchbaseClientFactory in project cas by apereo.
the class CouchbasePersonDirectoryConfiguration method couchbasePersonAttributeDao.
@ConditionalOnMissingBean(name = "couchbasePersonAttributeDao")
@Bean
@RefreshScope(proxyMode = ScopedProxyMode.DEFAULT)
public IPersonAttributeDao couchbasePersonAttributeDao(final ConfigurableApplicationContext applicationContext, final CasConfigurationProperties casProperties) throws Exception {
return BeanSupplier.of(IPersonAttributeDao.class).when(CONDITION.given(applicationContext.getEnvironment())).supply(() -> {
val couchbase = casProperties.getAuthn().getAttributeRepository().getCouchbase();
val cb = new CouchbasePersonAttributeDao(couchbase, new DefaultCouchbaseClientFactory(couchbase));
cb.setOrder(couchbase.getOrder());
FunctionUtils.doIfNotNull(couchbase.getId(), cb::setId);
return cb;
}).otherwiseProxy().get();
}
use of org.apereo.cas.couchbase.core.DefaultCouchbaseClientFactory in project cas by apereo.
the class CouchbaseAuthenticationHandlerTests method verify.
@Test
public void verify() throws Exception {
val props = casProperties.getAuthn().getCouchbase();
val factory = new DefaultCouchbaseClientFactory(props);
val handler = new CouchbaseAuthenticationHandler(mock(ServicesManager.class), PrincipalFactoryUtils.newPrincipalFactory(), factory, props);
val c = CoreAuthenticationTestUtils.getCredentialsWithDifferentUsernameAndPassword("casuser", "Mellon");
val result = handler.authenticate(c);
assertNotNull(result);
val attributes = result.getPrincipal().getAttributes();
assertEquals(2, attributes.size());
assertTrue(attributes.containsKey("firstname"));
assertTrue(attributes.containsKey("lastname"));
}
use of org.apereo.cas.couchbase.core.DefaultCouchbaseClientFactory in project cas by apereo.
the class CouchbaseAuthenticationHandlerTests method verifyBadEncoding.
@Test
public void verifyBadEncoding() {
val props = casProperties.getAuthn().getCouchbase();
val factory = new DefaultCouchbaseClientFactory(props);
val handler = new CouchbaseAuthenticationHandler(mock(ServicesManager.class), PrincipalFactoryUtils.newPrincipalFactory(), factory, props);
handler.setPasswordEncoder(new SCryptPasswordEncoder());
val c = CoreAuthenticationTestUtils.getCredentialsWithDifferentUsernameAndPassword("casuser", "Mellon");
assertThrows(FailedLoginException.class, () -> handler.authenticate(c));
}
Aggregations