jsevellec / cassandra-unit

Utility tool to load Data into Cassandra to help you writing good isolated JUnit Test into your application
GNU Lesser General Public License v3.0
424 stars 1 forks source link

impossible to use cassandra-unit with authentification/authorization both enabled #245

Open JCL38-ORANGE opened 7 years ago

JCL38-ORANGE commented 7 years ago

Hello,

I have enabled authentification and authorization in my cassandra.yml file like this because my unit tests must cover roles and permissions : ... authenticator: PasswordAuthenticator authorizer: CassandraAuthorizer ...

The startup of cassandra-unit fails with the error : 17:49:27.894 [cluster1-nio-worker-0] DEBUG com.datastax.driver.core.Host.STATES - Defuncting Connection[localhost/127.0.0.1:9142-1, inFlight=0, closed=false] because: Authentication error on host localhost/127.0.0.1:9142: Host localhost/127.0.0.1:9142 requires authentication, but no authenticator found in Cluster configuration

Startup code : ... try { EmbeddedCassandraServerHelper.startEmbeddedCassandra("cu-cassandra.yaml"); } catch (TTransportException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } ... Is there a way to solve this problem ? Regards,

OrangeDog commented 7 years ago

229

mcbailey commented 7 years ago

I have a workaround that just sets the default credentials when EmbeddedCassandraServerHelper.startEmbeddedCassandra(..) is called. You can see here: https://github.com/mcbailey/cassandra-unit/commit/e010788a2f6c37c4eac7d277929f68f568ed0962

JCL38-ORANGE commented 7 years ago

Hello,

Thanks for this workaround. I have tested it but it is a partial one (random result). The whole solution is your workaround and the following line : ... System.setProperty("cassandra.superuser_setup_delay_ms", "0"); ...
It works fine for me in all cases. Jérémy, is it possible to add the whole patch in the master branch and to deliver a new release ? Please keep me informed. Thanks and regards, Jean-Christophe.