fix(oracle): require either sid or service name
Fixes https://emqx.atlassian.net/browse/EMQX-9980
This commit is contained in:
parent
b7c72e6cfb
commit
3a6ad3b049
|
@ -1,6 +1,6 @@
|
|||
{application, emqx_bridge_oracle, [
|
||||
{description, "EMQX Enterprise Oracle Database Bridge"},
|
||||
{vsn, "0.1.1"},
|
||||
{vsn, "0.1.2"},
|
||||
{registered, []},
|
||||
{applications, [
|
||||
kernel,
|
||||
|
|
|
@ -16,7 +16,8 @@
|
|||
namespace/0,
|
||||
roots/0,
|
||||
fields/1,
|
||||
desc/1
|
||||
desc/1,
|
||||
config_validator/1
|
||||
]).
|
||||
|
||||
-define(DEFAULT_SQL, <<
|
||||
|
@ -107,3 +108,12 @@ type_field(Type) ->
|
|||
|
||||
name_field() ->
|
||||
{name, hoconsc:mk(binary(), #{required => true, desc => ?DESC("desc_name")})}.
|
||||
|
||||
config_validator(#{<<"server">> := Server} = Config) when
|
||||
not is_map(Server) andalso
|
||||
not is_map_key(<<"sid">>, Config) andalso
|
||||
not is_map_key(<<"service_name">>, Config)
|
||||
->
|
||||
{error, "neither SID nor Service Name was set"};
|
||||
config_validator(_) ->
|
||||
ok.
|
||||
|
|
|
@ -517,3 +517,15 @@ t_on_get_status(Config) ->
|
|||
?assertEqual({ok, connected}, emqx_resource_manager:health_check(ResourceId))
|
||||
),
|
||||
ok.
|
||||
|
||||
t_no_sid_nor_service_name(Config0) ->
|
||||
OracleConfig0 = ?config(oracle_config, Config0),
|
||||
OracleConfig1 = maps:remove(<<"sid">>, OracleConfig0),
|
||||
OracleConfig = maps:remove(<<"service_name">>, OracleConfig1),
|
||||
NewOracleConfig = {oracle_config, OracleConfig},
|
||||
Config = lists:keyreplace(oracle_config, 1, Config0, NewOracleConfig),
|
||||
?assertMatch(
|
||||
{error, #{kind := validation_error}},
|
||||
create_bridge(Config)
|
||||
),
|
||||
ok.
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
Require that SID or Service Name is set on Oracle Database bridge creation.
|
|
@ -186,6 +186,7 @@ fields(bridges) ->
|
|||
hoconsc:map(name, ref(emqx_bridge_oracle, "config")),
|
||||
#{
|
||||
desc => <<"Oracle Bridge Config">>,
|
||||
validator => fun emqx_bridge_oracle:config_validator/1,
|
||||
required => false
|
||||
}
|
||||
)},
|
||||
|
|
Loading…
Reference in New Issue