DATACASS-263 - Fix authentication configuration in CassandraCqlClusterFactoryBean.

Configuring username/password authentication does no longer require setting of an AuthProvider which would be overwritten by the username/password authenticator.
This commit is contained in:
Mark Paluch
2016-06-03 10:08:23 +02:00
parent 1d1ba3d998
commit abcac5f5ee
2 changed files with 21 additions and 19 deletions

View File

@@ -173,27 +173,31 @@ public class CassandraCqlClusterFactoryBeanUnitTests {
/**
* @see DATACASS-226
* @see DATACASS-263
* @throws Exception
*/
@Test
public void doesNotSetPlainTextAuthenticationUnlessAuthProviderIsSet() throws Exception {
public void shouldSetAuthenticationProvider() throws Exception {
CassandraCqlClusterFactoryBean bean = new CassandraCqlClusterFactoryBean();
bean.setUsername("user");
bean.setPassword("password");
bean.afterPropertiesSet();
AuthProvider result = getConfiguration(bean).getProtocolOptions().getAuthProvider();
assertThat(result, is(AuthProvider.NONE));
}
@Test
public void shouldSetAuthentication() throws Exception {
PlainTextAuthProvider authProvider = new PlainTextAuthProvider("x", "y");
AuthProvider authProvider = new PlainTextAuthProvider("x", "y");
CassandraCqlClusterFactoryBean bean = new CassandraCqlClusterFactoryBean();
bean.setAuthProvider(authProvider);
bean.afterPropertiesSet();
AuthProvider result = getConfiguration(bean).getProtocolOptions().getAuthProvider();
assertThat(result, is(equalTo(authProvider)));
}
/**
* @see DATACASS-226
* @see DATACASS-263
* @throws Exception
*/
@Test
public void shouldSetAuthentication() throws Exception {
CassandraCqlClusterFactoryBean bean = new CassandraCqlClusterFactoryBean();
bean.setUsername("user");
bean.setPassword("password");
bean.afterPropertiesSet();