test(auth): resource use connector provided default port

This commit is contained in:
JimMoen 2022-01-28 14:18:51 +08:00
parent 28735dc6d7
commit 2a1fba97da
15 changed files with 56 additions and 92 deletions

View File

@ -129,7 +129,7 @@ $(PROFILES:%=clean-%):
rm rebar.lock \ rm rebar.lock \
rm -rf _build/$(@:clean-%=%)/rel; \ rm -rf _build/$(@:clean-%=%)/rel; \
$(FIND) _build/$(@:clean-%=%) -name '*.beam' -o -name '*.so' -o -name '*.app' -o -name '*.appup' -o -name '*.o' -o -name '*.d' -type f | xargs rm -f; \ $(FIND) _build/$(@:clean-%=%) -name '*.beam' -o -name '*.so' -o -name '*.app' -o -name '*.appup' -o -name '*.o' -o -name '*.d' -type f | xargs rm -f; \
$(FIND) _build/$(@:clean-%=%) -type l -delete; \ $(FIND) _build/$(@:clean-%=%) -type l -delete; \
fi fi
.PHONY: clean-all .PHONY: clean-all

View File

@ -19,13 +19,13 @@
-compile(nowarn_export_all). -compile(nowarn_export_all).
-compile(export_all). -compile(export_all).
-include("emqx_connector.hrl").
-include("emqx_authn.hrl"). -include("emqx_authn.hrl").
-include_lib("eunit/include/eunit.hrl"). -include_lib("eunit/include/eunit.hrl").
-include_lib("common_test/include/ct.hrl"). -include_lib("common_test/include/ct.hrl").
-define(MONGO_HOST, "mongo"). -define(MONGO_HOST, "mongo").
-define(MONGO_PORT, 27017).
-define(MONGO_CLIENT, 'emqx_authn_mongo_SUITE_client'). -define(MONGO_CLIENT, 'emqx_authn_mongo_SUITE_client').
-define(PATH, [authentication]). -define(PATH, [authentication]).
@ -47,7 +47,7 @@ end_per_testcase(_TestCase, _Config) ->
init_per_suite(Config) -> init_per_suite(Config) ->
_ = application:load(emqx_conf), _ = application:load(emqx_conf),
case emqx_common_test_helpers:is_tcp_server_available(?MONGO_HOST, ?MONGO_PORT) of case emqx_common_test_helpers:is_tcp_server_available(?MONGO_HOST, ?MONGO_DEFAULT_PORT) of
true -> true ->
ok = emqx_common_test_helpers:start_apps([emqx_authn]), ok = emqx_common_test_helpers:start_apps([emqx_authn]),
ok = start_apps([emqx_resource, emqx_connector]), ok = start_apps([emqx_resource, emqx_connector]),
@ -386,16 +386,13 @@ drop_seeds() ->
ok. ok.
mongo_server() -> mongo_server() ->
iolist_to_binary( iolist_to_binary(io_lib:format("~s",[?MONGO_HOST])).
io_lib:format(
"~s:~b",
[?MONGO_HOST, ?MONGO_PORT])).
mongo_config() -> mongo_config() ->
[ [
{database, <<"mqtt">>}, {database, <<"mqtt">>},
{host, ?MONGO_HOST}, {host, ?MONGO_HOST},
{port, ?MONGO_PORT}, {port, ?MONGO_DEFAULT_PORT},
{register, ?MONGO_CLIENT} {register, ?MONGO_CLIENT}
]. ].

View File

@ -19,6 +19,7 @@
-compile(nowarn_export_all). -compile(nowarn_export_all).
-compile(export_all). -compile(export_all).
-include("emqx_connector.hrl").
-include("emqx_authn.hrl"). -include("emqx_authn.hrl").
-include_lib("eunit/include/eunit.hrl"). -include_lib("eunit/include/eunit.hrl").
-include_lib("common_test/include/ct.hrl"). -include_lib("common_test/include/ct.hrl").
@ -26,7 +27,6 @@
-define(MONGO_HOST, "mongo-tls"). -define(MONGO_HOST, "mongo-tls").
-define(MONGO_PORT, 27017).
-define(PATH, [authentication]). -define(PATH, [authentication]).
@ -43,7 +43,7 @@ init_per_testcase(_TestCase, Config) ->
init_per_suite(Config) -> init_per_suite(Config) ->
_ = application:load(emqx_conf), _ = application:load(emqx_conf),
case emqx_common_test_helpers:is_tcp_server_available(?MONGO_HOST, ?MONGO_PORT) of case emqx_common_test_helpers:is_tcp_server_available(?MONGO_HOST, ?MONGO_DEFAULT_PORT) of
true -> true ->
ok = emqx_common_test_helpers:start_apps([emqx_authn]), ok = emqx_common_test_helpers:start_apps([emqx_authn]),
ok = start_apps([emqx_resource, emqx_connector]), ok = start_apps([emqx_resource, emqx_connector]),
@ -174,10 +174,7 @@ raw_mongo_auth_config(SpecificSSLOpts) ->
}. }.
mongo_server() -> mongo_server() ->
iolist_to_binary( iolist_to_binary(io_lib:format("~s",[?MONGO_HOST])).
io_lib:format(
"~s:~b",
[?MONGO_HOST, ?MONGO_PORT])).
start_apps(Apps) -> start_apps(Apps) ->
lists:foreach(fun application:ensure_all_started/1, Apps). lists:foreach(fun application:ensure_all_started/1, Apps).

View File

@ -19,12 +19,12 @@
-compile(nowarn_export_all). -compile(nowarn_export_all).
-compile(export_all). -compile(export_all).
-include("emqx_connector.hrl").
-include("emqx_authn.hrl"). -include("emqx_authn.hrl").
-include_lib("eunit/include/eunit.hrl"). -include_lib("eunit/include/eunit.hrl").
-include_lib("common_test/include/ct.hrl"). -include_lib("common_test/include/ct.hrl").
-define(MYSQL_HOST, "mysql"). -define(MYSQL_HOST, "mysql").
-define(MYSQL_PORT, 3306).
-define(MYSQL_RESOURCE, <<"emqx_authn_mysql_SUITE">>). -define(MYSQL_RESOURCE, <<"emqx_authn_mysql_SUITE">>).
-define(PATH, [authentication]). -define(PATH, [authentication]).
@ -53,7 +53,7 @@ end_per_group(require_seeds, Config) ->
init_per_suite(Config) -> init_per_suite(Config) ->
_ = application:load(emqx_conf), _ = application:load(emqx_conf),
case emqx_common_test_helpers:is_tcp_server_available(?MYSQL_HOST, ?MYSQL_PORT) of case emqx_common_test_helpers:is_tcp_server_available(?MYSQL_HOST, ?MYSQL_DEFAULT_PORT) of
true -> true ->
ok = emqx_common_test_helpers:start_apps([emqx_authn]), ok = emqx_common_test_helpers:start_apps([emqx_authn]),
ok = start_apps([emqx_resource, emqx_connector]), ok = start_apps([emqx_resource, emqx_connector]),
@ -391,10 +391,7 @@ drop_seeds() ->
ok = q("DROP TABLE IF EXISTS users"). ok = q("DROP TABLE IF EXISTS users").
mysql_server() -> mysql_server() ->
iolist_to_binary( iolist_to_binary(io_lib:format("~s",[?MYSQL_HOST])).
io_lib:format(
"~s:~b",
[?MYSQL_HOST, ?MYSQL_PORT])).
mysql_config() -> mysql_config() ->
#{auto_reconnect => true, #{auto_reconnect => true,
@ -402,7 +399,7 @@ mysql_config() ->
username => <<"root">>, username => <<"root">>,
password => <<"public">>, password => <<"public">>,
pool_size => 8, pool_size => 8,
server => {?MYSQL_HOST, ?MYSQL_PORT}, server => {?MYSQL_HOST, ?MYSQL_DEFAULT_PORT},
ssl => #{enable => false} ssl => #{enable => false}
}. }.

View File

@ -19,12 +19,12 @@
-compile(nowarn_export_all). -compile(nowarn_export_all).
-compile(export_all). -compile(export_all).
-include("emqx_connector.hrl").
-include("emqx_authn.hrl"). -include("emqx_authn.hrl").
-include_lib("eunit/include/eunit.hrl"). -include_lib("eunit/include/eunit.hrl").
-include_lib("common_test/include/ct.hrl"). -include_lib("common_test/include/ct.hrl").
-define(MYSQL_HOST, "mysql-tls"). -define(MYSQL_HOST, "mysql-tls").
-define(MYSQL_PORT, 3306).
-define(PATH, [authentication]). -define(PATH, [authentication]).
@ -44,7 +44,7 @@ init_per_testcase(_, Config) ->
init_per_suite(Config) -> init_per_suite(Config) ->
_ = application:load(emqx_conf), _ = application:load(emqx_conf),
case emqx_common_test_helpers:is_tcp_server_available(?MYSQL_HOST, ?MYSQL_PORT) of case emqx_common_test_helpers:is_tcp_server_available(?MYSQL_HOST, ?MYSQL_DEFAULT_PORT) of
true -> true ->
ok = emqx_common_test_helpers:start_apps([emqx_authn]), ok = emqx_common_test_helpers:start_apps([emqx_authn]),
ok = start_apps([emqx_resource, emqx_connector]), ok = start_apps([emqx_resource, emqx_connector]),
@ -132,10 +132,7 @@ raw_mysql_auth_config(SpecificSSLOpts) ->
}. }.
mysql_server() -> mysql_server() ->
iolist_to_binary( iolist_to_binary(io_lib:format("~s",[?MYSQL_HOST])).
io_lib:format(
"~s:~b",
[?MYSQL_HOST, ?MYSQL_PORT])).
start_apps(Apps) -> start_apps(Apps) ->
lists:foreach(fun application:ensure_all_started/1, Apps). lists:foreach(fun application:ensure_all_started/1, Apps).

View File

@ -19,13 +19,13 @@
-compile(nowarn_export_all). -compile(nowarn_export_all).
-compile(export_all). -compile(export_all).
-include("emqx_connector.hrl").
-include("emqx_authn.hrl"). -include("emqx_authn.hrl").
-include_lib("eunit/include/eunit.hrl"). -include_lib("eunit/include/eunit.hrl").
-include_lib("common_test/include/ct.hrl"). -include_lib("common_test/include/ct.hrl").
-include_lib("emqx/include/emqx_placeholder.hrl"). -include_lib("emqx/include/emqx_placeholder.hrl").
-define(PGSQL_HOST, "pgsql"). -define(PGSQL_HOST, "pgsql").
-define(PGSQL_PORT, 5432).
-define(PGSQL_RESOURCE, <<"emqx_authn_pgsql_SUITE">>). -define(PGSQL_RESOURCE, <<"emqx_authn_pgsql_SUITE">>).
-define(PATH, [authentication]). -define(PATH, [authentication]).
@ -54,7 +54,7 @@ end_per_group(require_seeds, Config) ->
init_per_suite(Config) -> init_per_suite(Config) ->
_ = application:load(emqx_conf), _ = application:load(emqx_conf),
case emqx_common_test_helpers:is_tcp_server_available(?PGSQL_HOST, ?PGSQL_PORT) of case emqx_common_test_helpers:is_tcp_server_available(?PGSQL_HOST, ?PGSQL_DEFAULT_PORT) of
true -> true ->
ok = emqx_common_test_helpers:start_apps([emqx_authn]), ok = emqx_common_test_helpers:start_apps([emqx_authn]),
ok = start_apps([emqx_resource, emqx_connector]), ok = start_apps([emqx_resource, emqx_connector]),
@ -439,10 +439,7 @@ drop_seeds() ->
ok. ok.
pgsql_server() -> pgsql_server() ->
iolist_to_binary( iolist_to_binary(io_lib:format("~s",[?PGSQL_HOST])).
io_lib:format(
"~s:~b",
[?PGSQL_HOST, ?PGSQL_PORT])).
pgsql_config() -> pgsql_config() ->
#{auto_reconnect => true, #{auto_reconnect => true,
@ -450,7 +447,7 @@ pgsql_config() ->
username => <<"root">>, username => <<"root">>,
password => <<"public">>, password => <<"public">>,
pool_size => 8, pool_size => 8,
server => {?PGSQL_HOST, ?PGSQL_PORT}, server => {?PGSQL_HOST, ?PGSQL_DEFAULT_PORT},
ssl => #{enable => false} ssl => #{enable => false}
}. }.

View File

@ -19,12 +19,12 @@
-compile(nowarn_export_all). -compile(nowarn_export_all).
-compile(export_all). -compile(export_all).
-include("emqx_connector.hrl").
-include("emqx_authn.hrl"). -include("emqx_authn.hrl").
-include_lib("eunit/include/eunit.hrl"). -include_lib("eunit/include/eunit.hrl").
-include_lib("common_test/include/ct.hrl"). -include_lib("common_test/include/ct.hrl").
-define(PGSQL_HOST, "pgsql-tls"). -define(PGSQL_HOST, "pgsql-tls").
-define(PGSQL_PORT, 5432).
-define(PATH, [authentication]). -define(PATH, [authentication]).
@ -44,7 +44,7 @@ init_per_testcase(_, Config) ->
init_per_suite(Config) -> init_per_suite(Config) ->
_ = application:load(emqx_conf), _ = application:load(emqx_conf),
case emqx_common_test_helpers:is_tcp_server_available(?PGSQL_HOST, ?PGSQL_PORT) of case emqx_common_test_helpers:is_tcp_server_available(?PGSQL_HOST, ?PGSQL_DEFAULT_PORT) of
true -> true ->
ok = emqx_common_test_helpers:start_apps([emqx_authn]), ok = emqx_common_test_helpers:start_apps([emqx_authn]),
ok = start_apps([emqx_resource, emqx_connector]), ok = start_apps([emqx_resource, emqx_connector]),
@ -131,14 +131,10 @@ raw_pgsql_auth_config(SpecificSSLOpts) ->
}. }.
pgsql_server() -> pgsql_server() ->
iolist_to_binary( iolist_to_binary(io_lib:format("~s",[?PGSQL_HOST])).
io_lib:format(
"~s:~b",
[?PGSQL_HOST, ?PGSQL_PORT])).
start_apps(Apps) -> start_apps(Apps) ->
lists:foreach(fun application:ensure_all_started/1, Apps). lists:foreach(fun application:ensure_all_started/1, Apps).
stop_apps(Apps) -> stop_apps(Apps) ->
lists:foreach(fun application:stop/1, Apps). lists:foreach(fun application:stop/1, Apps).

View File

@ -19,12 +19,12 @@
-compile(nowarn_export_all). -compile(nowarn_export_all).
-compile(export_all). -compile(export_all).
-include("emqx_connector.hrl").
-include("emqx_authn.hrl"). -include("emqx_authn.hrl").
-include_lib("eunit/include/eunit.hrl"). -include_lib("eunit/include/eunit.hrl").
-include_lib("common_test/include/ct.hrl"). -include_lib("common_test/include/ct.hrl").
-define(REDIS_HOST, "redis"). -define(REDIS_HOST, "redis").
-define(REDIS_PORT, 6379).
-define(REDIS_RESOURCE, <<"emqx_authn_redis_SUITE">>). -define(REDIS_RESOURCE, <<"emqx_authn_redis_SUITE">>).
-define(PATH, [authentication]). -define(PATH, [authentication]).
@ -53,7 +53,7 @@ end_per_group(require_seeds, Config) ->
init_per_suite(Config) -> init_per_suite(Config) ->
_ = application:load(emqx_conf), _ = application:load(emqx_conf),
case emqx_common_test_helpers:is_tcp_server_available(?REDIS_HOST, ?REDIS_PORT) of case emqx_common_test_helpers:is_tcp_server_available(?REDIS_HOST, ?REDIS_DEFAULT_PORT) of
true -> true ->
ok = emqx_common_test_helpers:start_apps([emqx_authn]), ok = emqx_common_test_helpers:start_apps([emqx_authn]),
ok = start_apps([emqx_resource, emqx_connector]), ok = start_apps([emqx_resource, emqx_connector]),
@ -380,10 +380,7 @@ drop_seeds() ->
user_seeds()). user_seeds()).
redis_server() -> redis_server() ->
iolist_to_binary( iolist_to_binary(io_lib:format("~s",[?REDIS_HOST])).
io_lib:format(
"~s:~b",
[?REDIS_HOST, ?REDIS_PORT])).
redis_config() -> redis_config() ->
#{auto_reconnect => true, #{auto_reconnect => true,
@ -391,7 +388,7 @@ redis_config() ->
pool_size => 8, pool_size => 8,
redis_type => single, redis_type => single,
password => "public", password => "public",
server => {?REDIS_HOST, ?REDIS_PORT}, server => {?REDIS_HOST, ?REDIS_DEFAULT_PORT},
ssl => #{enable => false} ssl => #{enable => false}
}. }.

View File

@ -19,12 +19,13 @@
-compile(nowarn_export_all). -compile(nowarn_export_all).
-compile(export_all). -compile(export_all).
-include("emqx_connector.hrl").
-include("emqx_authn.hrl"). -include("emqx_authn.hrl").
-include_lib("eunit/include/eunit.hrl"). -include_lib("eunit/include/eunit.hrl").
-include_lib("common_test/include/ct.hrl"). -include_lib("common_test/include/ct.hrl").
-define(REDIS_HOST, "redis-tls"). -define(REDIS_HOST, "redis-tls").
-define(REDIS_PORT, 6380). -define(REDIS_TLS_PORT, 6380).
-define(PATH, [authentication]). -define(PATH, [authentication]).
@ -44,7 +45,7 @@ init_per_testcase(_, Config) ->
init_per_suite(Config) -> init_per_suite(Config) ->
_ = application:load(emqx_conf), _ = application:load(emqx_conf),
case emqx_common_test_helpers:is_tcp_server_available(?REDIS_HOST, ?REDIS_PORT) of case emqx_common_test_helpers:is_tcp_server_available(?REDIS_HOST, ?REDIS_TLS_PORT) of
true -> true ->
ok = emqx_common_test_helpers:start_apps([emqx_authn]), ok = emqx_common_test_helpers:start_apps([emqx_authn]),
ok = start_apps([emqx_resource, emqx_connector]), ok = start_apps([emqx_resource, emqx_connector]),
@ -127,10 +128,7 @@ raw_redis_auth_config(SpecificSSLOpts) ->
}. }.
redis_server() -> redis_server() ->
iolist_to_binary( iolist_to_binary(io_lib:format("~s:~b",[?REDIS_HOST, ?REDIS_TLS_PORT])).
io_lib:format(
"~s:~b",
[?REDIS_HOST, ?REDIS_PORT])).
start_apps(Apps) -> start_apps(Apps) ->
lists:foreach(fun application:ensure_all_started/1, Apps). lists:foreach(fun application:ensure_all_started/1, Apps).

View File

@ -26,7 +26,10 @@
-define(HOST, "http://127.0.0.1:18083/"). -define(HOST, "http://127.0.0.1:18083/").
-define(API_VERSION, "v5"). -define(API_VERSION, "v5").
-define(BASE_PATH, "api"). -define(BASE_PATH, "api").
-define(MONGO_SINGLE_HOST, "mongo:27017"). -define(MONGO_SINGLE_HOST, "mongo").
-define(MYSQL_HOST, "mysql:3306").
-define(PGSQL_HOST, "pgsql").
-define(REDIS_SINGLE_HOST, "redis").
-define(SOURCE1, #{<<"type">> => <<"http">>, -define(SOURCE1, #{<<"type">> => <<"http">>,
<<"enable">> => true, <<"enable">> => true,
@ -48,7 +51,7 @@
}). }).
-define(SOURCE3, #{<<"type">> => <<"mysql">>, -define(SOURCE3, #{<<"type">> => <<"mysql">>,
<<"enable">> => true, <<"enable">> => true,
<<"server">> => <<"mysql:3306">>, <<"server">> => <<?MYSQL_HOST>>,
<<"pool_size">> => 1, <<"pool_size">> => 1,
<<"database">> => <<"mqtt">>, <<"database">> => <<"mqtt">>,
<<"username">> => <<"xx">>, <<"username">> => <<"xx">>,
@ -59,7 +62,7 @@
}). }).
-define(SOURCE4, #{<<"type">> => <<"postgresql">>, -define(SOURCE4, #{<<"type">> => <<"postgresql">>,
<<"enable">> => true, <<"enable">> => true,
<<"server">> => <<"pgsql:5432">>, <<"server">> => <<?PGSQL_HOST>>,
<<"pool_size">> => 1, <<"pool_size">> => 1,
<<"database">> => <<"mqtt">>, <<"database">> => <<"mqtt">>,
<<"username">> => <<"xx">>, <<"username">> => <<"xx">>,
@ -70,7 +73,7 @@
}). }).
-define(SOURCE5, #{<<"type">> => <<"redis">>, -define(SOURCE5, #{<<"type">> => <<"redis">>,
<<"enable">> => true, <<"enable">> => true,
<<"servers">> => <<"redis:6379,127.0.0.1:6380">>, <<"servers">> => <<?REDIS_SINGLE_HOST, ",127.0.0.1:6380">>,
<<"pool_size">> => 1, <<"pool_size">> => 1,
<<"database">> => 0, <<"database">> => 0,
<<"password">> => <<"ee">>, <<"password">> => <<"ee">>,

View File

@ -18,13 +18,13 @@
-compile(nowarn_export_all). -compile(nowarn_export_all).
-compile(export_all). -compile(export_all).
-include("emqx_connector.hrl").
-include("emqx_authz.hrl"). -include("emqx_authz.hrl").
-include_lib("eunit/include/eunit.hrl"). -include_lib("eunit/include/eunit.hrl").
-include_lib("common_test/include/ct.hrl"). -include_lib("common_test/include/ct.hrl").
-include_lib("emqx/include/emqx_placeholder.hrl"). -include_lib("emqx/include/emqx_placeholder.hrl").
-define(MONGO_HOST, "mongo"). -define(MONGO_HOST, "mongo").
-define(MONGO_PORT, 27017).
-define(MONGO_CLIENT, 'emqx_authz_mongo_SUITE_client'). -define(MONGO_CLIENT, 'emqx_authz_mongo_SUITE_client').
all() -> all() ->
@ -34,7 +34,7 @@ groups() ->
[]. [].
init_per_suite(Config) -> init_per_suite(Config) ->
case emqx_common_test_helpers:is_tcp_server_available(?MONGO_HOST, ?MONGO_PORT) of case emqx_common_test_helpers:is_tcp_server_available(?MONGO_HOST, ?MONGO_DEFAULT_PORT) of
true -> true ->
ok = emqx_common_test_helpers:start_apps( ok = emqx_common_test_helpers:start_apps(
[emqx_conf, emqx_authz], [emqx_conf, emqx_authz],
@ -237,16 +237,13 @@ raw_mongo_authz_config() ->
}. }.
mongo_server() -> mongo_server() ->
iolist_to_binary( iolist_to_binary(io_lib:format("~s",[?MONGO_HOST])).
io_lib:format(
"~s:~b",
[?MONGO_HOST, ?MONGO_PORT])).
mongo_config() -> mongo_config() ->
[ [
{database, <<"mqtt">>}, {database, <<"mqtt">>},
{host, ?MONGO_HOST}, {host, ?MONGO_HOST},
{port, ?MONGO_PORT}, {port, ?MONGO_DEFAULT_PORT},
{register, ?MONGO_CLIENT} {register, ?MONGO_CLIENT}
]. ].

View File

@ -18,13 +18,12 @@
-compile(nowarn_export_all). -compile(nowarn_export_all).
-compile(export_all). -compile(export_all).
-include("emqx_connector.hrl").
-include("emqx_authz.hrl"). -include("emqx_authz.hrl").
-include_lib("eunit/include/eunit.hrl"). -include_lib("eunit/include/eunit.hrl").
-include_lib("common_test/include/ct.hrl"). -include_lib("common_test/include/ct.hrl").
-define(MYSQL_HOST, "mysql"). -define(MYSQL_HOST, "mysql").
-define(MYSQL_PORT, 3306).
-define(MYSQL_RESOURCE, <<"emqx_authz_mysql_SUITE">>). -define(MYSQL_RESOURCE, <<"emqx_authz_mysql_SUITE">>).
all() -> all() ->
@ -34,7 +33,7 @@ groups() ->
[]. [].
init_per_suite(Config) -> init_per_suite(Config) ->
case emqx_common_test_helpers:is_tcp_server_available(?MYSQL_HOST, ?MYSQL_PORT) of case emqx_common_test_helpers:is_tcp_server_available(?MYSQL_HOST, ?MYSQL_DEFAULT_PORT) of
true -> true ->
ok = emqx_common_test_helpers:start_apps( ok = emqx_common_test_helpers:start_apps(
[emqx_conf, emqx_authz], [emqx_conf, emqx_authz],
@ -274,10 +273,7 @@ setup_config(SpecialParams) ->
SpecialParams). SpecialParams).
mysql_server() -> mysql_server() ->
iolist_to_binary( iolist_to_binary(io_lib:format("~s",[?MYSQL_HOST])).
io_lib:format(
"~s:~b",
[?MYSQL_HOST, ?MYSQL_PORT])).
mysql_config() -> mysql_config() ->
#{auto_reconnect => true, #{auto_reconnect => true,
@ -285,7 +281,7 @@ mysql_config() ->
username => <<"root">>, username => <<"root">>,
password => <<"public">>, password => <<"public">>,
pool_size => 8, pool_size => 8,
server => {?MYSQL_HOST, ?MYSQL_PORT}, server => {?MYSQL_HOST, ?MYSQL_DEFAULT_PORT},
ssl => #{enable => false} ssl => #{enable => false}
}. }.

View File

@ -18,13 +18,12 @@
-compile(nowarn_export_all). -compile(nowarn_export_all).
-compile(export_all). -compile(export_all).
-include("emqx_connector.hrl").
-include("emqx_authz.hrl"). -include("emqx_authz.hrl").
-include_lib("eunit/include/eunit.hrl"). -include_lib("eunit/include/eunit.hrl").
-include_lib("common_test/include/ct.hrl"). -include_lib("common_test/include/ct.hrl").
-define(PGSQL_HOST, "pgsql"). -define(PGSQL_HOST, "pgsql").
-define(PGSQL_PORT, 5432).
-define(PGSQL_RESOURCE, <<"emqx_authz_pgsql_SUITE">>). -define(PGSQL_RESOURCE, <<"emqx_authz_pgsql_SUITE">>).
all() -> all() ->
@ -34,7 +33,7 @@ groups() ->
[]. [].
init_per_suite(Config) -> init_per_suite(Config) ->
case emqx_common_test_helpers:is_tcp_server_available(?PGSQL_HOST, ?PGSQL_PORT) of case emqx_common_test_helpers:is_tcp_server_available(?PGSQL_HOST, ?PGSQL_DEFAULT_PORT) of
true -> true ->
ok = emqx_common_test_helpers:start_apps( ok = emqx_common_test_helpers:start_apps(
[emqx_conf, emqx_authz], [emqx_conf, emqx_authz],
@ -278,10 +277,7 @@ setup_config(SpecialParams) ->
SpecialParams). SpecialParams).
pgsql_server() -> pgsql_server() ->
iolist_to_binary( iolist_to_binary(io_lib:format("~s",[?PGSQL_HOST])).
io_lib:format(
"~s:~b",
[?PGSQL_HOST, ?PGSQL_PORT])).
pgsql_config() -> pgsql_config() ->
#{auto_reconnect => true, #{auto_reconnect => true,
@ -289,7 +285,7 @@ pgsql_config() ->
username => <<"root">>, username => <<"root">>,
password => <<"public">>, password => <<"public">>,
pool_size => 8, pool_size => 8,
server => {?PGSQL_HOST, ?PGSQL_PORT}, server => {?PGSQL_HOST, ?PGSQL_DEFAULT_PORT},
ssl => #{enable => false} ssl => #{enable => false}
}. }.

View File

@ -19,13 +19,12 @@
-compile(nowarn_export_all). -compile(nowarn_export_all).
-compile(export_all). -compile(export_all).
-include("emqx_connector.hrl").
-include("emqx_authz.hrl"). -include("emqx_authz.hrl").
-include_lib("eunit/include/eunit.hrl"). -include_lib("eunit/include/eunit.hrl").
-include_lib("common_test/include/ct.hrl"). -include_lib("common_test/include/ct.hrl").
-define(REDIS_HOST, "redis"). -define(REDIS_HOST, "redis").
-define(REDIS_PORT, 6379).
-define(REDIS_RESOURCE, <<"emqx_authz_redis_SUITE">>). -define(REDIS_RESOURCE, <<"emqx_authz_redis_SUITE">>).
all() -> all() ->
@ -35,7 +34,7 @@ groups() ->
[]. [].
init_per_suite(Config) -> init_per_suite(Config) ->
case emqx_common_test_helpers:is_tcp_server_available(?REDIS_HOST, ?REDIS_PORT) of case emqx_common_test_helpers:is_tcp_server_available(?REDIS_HOST, ?REDIS_DEFAULT_PORT) of
true -> true ->
ok = emqx_common_test_helpers:start_apps( ok = emqx_common_test_helpers:start_apps(
[emqx_conf, emqx_authz], [emqx_conf, emqx_authz],
@ -219,10 +218,7 @@ raw_redis_authz_config() ->
}. }.
redis_server() -> redis_server() ->
iolist_to_binary( iolist_to_binary(io_lib:format("~s",[?REDIS_HOST])).
io_lib:format(
"~s:~b",
[?REDIS_HOST, ?REDIS_PORT])).
q(Command) -> q(Command) ->
emqx_resource:query( emqx_resource:query(
@ -235,7 +231,7 @@ redis_config() ->
pool_size => 8, pool_size => 8,
redis_type => single, redis_type => single,
password => "public", password => "public",
server => {?REDIS_HOST, ?REDIS_PORT}, server => {?REDIS_HOST, ?REDIS_DEFAULT_PORT},
ssl => #{enable => false} ssl => #{enable => false}
}. }.

View File

@ -361,7 +361,7 @@ schema("/ref/complicated_type") ->
200 => [ 200 => [
{no_neg_integer, hoconsc:mk(non_neg_integer(), #{})}, {no_neg_integer, hoconsc:mk(non_neg_integer(), #{})},
{url, hoconsc:mk(emqx_connector_http:url(), #{})}, {url, hoconsc:mk(emqx_connector_http:url(), #{})},
{server, hoconsc:mk(emqx_connector_redis:server(), #{})}, {server, hoconsc:mk(emqx_schema:ip_port(), #{})},
{connect_timeout, hoconsc:mk(emqx_connector_http:connect_timeout(), #{})}, {connect_timeout, hoconsc:mk(emqx_connector_http:connect_timeout(), #{})},
{pool_type, hoconsc:mk(emqx_connector_http:pool_type(), #{})}, {pool_type, hoconsc:mk(emqx_connector_http:pool_type(), #{})},
{timeout, hoconsc:mk(timeout(), #{})}, {timeout, hoconsc:mk(timeout(), #{})},