test: that one cannot register a schema with the magic SparkplugB name

This commit is contained in:
Kjell Winblad 2023-07-03 19:18:43 +02:00
parent b5e91422de
commit 70ce781cc0
1 changed files with 14 additions and 1 deletions

View File

@ -12,6 +12,8 @@
-include_lib("common_test/include/ct.hrl").
-include_lib("snabbkaffe/include/snabbkaffe.hrl").
-include("emqx_ee_schema_registry.hrl").
-define(APPS, [emqx_conf, emqx_ee_schema_registry]).
%%------------------------------------------------------------------------------
@ -182,7 +184,6 @@ t_crud(Config) ->
}},
request({delete, SchemaName})
),
%% create a schema
?assertMatch(
{ok, 201, #{
@ -193,6 +194,18 @@ t_crud(Config) ->
}},
request({post, Params})
),
%% Test that we can't create a schema with the special Sparkplug B name
%% (the special Sparkplug B name contains a random sequence of chars so
%% should be very unlikely that users try to do this)
ParmsWithForbiddenName = maps:put(
<<"name">>, ?EMQX_SCHEMA_REGISTRY_SPARKPLUGB_SCHEMA_NAME, Params
),
?assertMatch(
{ok, 400, #{
<<"code">> := <<"BAD_REQUEST">>
}},
request({post, ParmsWithForbiddenName})
),
?assertMatch(
{ok, 200, #{
<<"type">> := SerdeTypeBin,