chore(bridge): cover username/password auth for cassandra bridges

This commit is contained in:
JianBo He 2023-03-21 13:55:53 +08:00
parent ae5c24445b
commit 539ec2f774
5 changed files with 16 additions and 11 deletions

View File

@ -100,7 +100,7 @@ batchlog_replay_throttle_in_kb: 1024
# users. It keeps usernames and hashed passwords in system_auth.roles table.
# Please increase system_auth keyspace replication factor if you use this authenticator.
# If using PasswordAuthenticator, CassandraRoleManager must also be used (see below)
authenticator: AllowAllAuthenticator
authenticator: PasswordAuthenticator
# Authorization backend, implementing IAuthorizer; used to limit access/provide permissions
# Out of the box, Cassandra provides org.apache.cassandra.auth.{AllowAllAuthorizer,

View File

@ -22,9 +22,9 @@ services:
- -c
- |
/opt/cassandra/bin/cassandra -f -R > /cassandra.log &
/opt/cassandra/bin/cqlsh -e "CREATE KEYSPACE mqtt WITH REPLICATION = { 'class':'SimpleStrategy','replication_factor':1};"
while [[ $$? -ne 0 ]];do sleep 5; /opt/cassandra/bin/cqlsh -e "CREATE KEYSPACE mqtt WITH REPLICATION = { 'class':'SimpleStrategy','replication_factor':1};"; done
/opt/cassandra/bin/cqlsh -e "describe keyspaces;"
/opt/cassandra/bin/cqlsh -u cassandra -p cassandra -e "CREATE KEYSPACE mqtt WITH REPLICATION = { 'class':'SimpleStrategy','replication_factor':1};"
while [[ $$? -ne 0 ]];do sleep 5; /opt/cassandra/bin/cqlsh -u cassandra -p cassandra -e "CREATE KEYSPACE mqtt WITH REPLICATION = { 'class':'SimpleStrategy','replication_factor':1};"; done
/opt/cassandra/bin/cqlsh -u cassandra -p cassandra -e "describe keyspaces;"
tail -f /cassandra.log
networks:
- emqx_bridge

View File

@ -33,8 +33,8 @@
% DB defaults
-define(CASSA_KEYSPACE, "mqtt").
-define(CASSA_USERNAME, "root").
-define(CASSA_PASSWORD, "public").
-define(CASSA_USERNAME, "cassandra").
-define(CASSA_PASSWORD, "cassandra").
-define(BATCH_SIZE, 10).
%% cert files for client

View File

@ -37,6 +37,11 @@
%%
%% sudo docker run --rm -d --name cassandra --network host cassandra:3.11.14
%% Cassandra default username & password once enable `authenticator: PasswordAuthenticator`
%% in cassandra config
-define(CASSA_USERNAME, <<"cassandra">>).
-define(CASSA_PASSWORD, <<"cassandra">>).
all() ->
emqx_common_test_helpers:all(?MODULE).
@ -62,8 +67,8 @@ init_per_suite(Config) ->
{ok, Conn} =
ecql:connect([
{nodes, cassandra_servers()},
{username, <<"admin">>},
{password, <<"public">>},
{username, ?CASSA_USERNAME},
{password, ?CASSA_PASSWORD},
{keyspace, "mqtt"}
]),
ecql:close(Conn),
@ -175,8 +180,8 @@ cassandra_config() ->
#{
auto_reconnect => true,
keyspace => <<"mqtt">>,
username => <<"default">>,
password => <<"public">>,
username => ?CASSA_USERNAME,
password => ?CASSA_PASSWORD,
pool_size => 8,
servers => iolist_to_binary(
io_lib:format(

View File

@ -171,7 +171,7 @@ for dep in ${CT_DEPS}; do
FILES+=( '.ci/docker-compose-file/docker-compose-dynamo.yaml' )
;;
cassandra)
FILES+=( '.ci/docker-compose-file/docker-compose-cassandra-tcp.yaml' )
FILES+=( '.ci/docker-compose-file/docker-compose-cassandra.yaml' )
;;
*)
echo "unknown_ct_dependency $dep"