diff --git a/apps/emqx_authz/test/emqx_authz_redis_SUITE.erl b/apps/emqx_authz/test/emqx_authz_redis_SUITE.erl index ebf2b4d06..54d7a406c 100644 --- a/apps/emqx_authz/test/emqx_authz_redis_SUITE.erl +++ b/apps/emqx_authz/test/emqx_authz_redis_SUITE.erl @@ -161,12 +161,13 @@ t_lookups(_Config) -> ] ). -t_create_invalid(_Config) -> +%% should still succeed to create even if the config will not work, +%% because it's not a part of the schema check +t_create_with_config_values_wont_works(_Config) -> AuthzConfig = raw_redis_authz_config(), InvalidConfigs = [ - maps:without([<<"server">>], AuthzConfig), AuthzConfig#{<<"server">> => <<"unknownhost:3333">>}, AuthzConfig#{<<"password">> => <<"wrongpass">>}, AuthzConfig#{<<"database">> => <<"5678">>} @@ -180,6 +181,15 @@ t_create_invalid(_Config) -> InvalidConfigs ). +%% creating without a require filed should return error +t_create_invalid_schema(_Config) -> + AuthzConfig = raw_redis_authz_config(), + C = maps:without([<<"server">>], AuthzConfig), + ?assertMatch( + {error, {emqx_conf_schema, _}}, + emqx_authz:update(?CMD_REPLACE, [C]) + ). + t_redis_error(_Config) -> ok = setup_config(#{<<"cmd">> => <<"INVALID COMMAND">>}), diff --git a/apps/emqx_resource/src/emqx_resource_validator.erl b/apps/emqx_resource/src/emqx_resource_validator.erl index 7623ae7fa..a5404a65e 100644 --- a/apps/emqx_resource/src/emqx_resource_validator.erl +++ b/apps/emqx_resource/src/emqx_resource_validator.erl @@ -30,6 +30,7 @@ min(Type, Min) -> not_empty(ErrMsg) -> fun + (undefined) -> {error, ErrMsg}; (<<>>) -> {error, ErrMsg}; (_) -> ok end.