File tree Expand file tree Collapse file tree 4 files changed +33
-7
lines changed
Expand file tree Collapse file tree 4 files changed +33
-7
lines changed Original file line number Diff line number Diff line change 2929local schema = {
3030 type = " object" ,
3131 properties = {
32- protocol_name = {type = " string" },
32+ protocol_name = {type = " string" , default = " MQTT " },
3333 protocol_level = {type = " integer" }
3434 },
35- required = {" protocol_name " , " protocol_level" },
35+ required = {" protocol_level" },
3636}
3737
3838
Original file line number Diff line number Diff line change @@ -37,7 +37,7 @@ This Plugin supports both the protocols [3.1.*](http://docs.oasis-open.org/mqtt/
3737
3838| Name | Type | Required | Description |
3939| ----------------| ---------| ------------| -----------------------------------------------------------------------------------|
40- | protocol_name | string | True | Name of the protocol. Generally ` MQTT ` . |
40+ | protocol_name | string | False | Name of the protocol. Defaults to ` MQTT ` . |
4141| protocol_level | integer | True | Level of the protocol. It should be ` 4 ` for MQTT ` 3.1.* ` and ` 5 ` for MQTT ` 5.0 ` . |
4242
4343## Enable Plugin
Original file line number Diff line number Diff line change @@ -35,10 +35,10 @@ description: 本文档介绍了 Apache APISIX mqtt-proxy 插件的信息,通
3535
3636## 属性
3737
38- | 名称 | 类型 | 必选项 | 描述 |
39- | -------------- | ------- | ----- | ------------------------------------------------------ |
40- | protocol_name | string | 是 | 协议名称,正常情况下应为 ` MQTT ` 。 |
41- | protocol_level | integer | 是 | 协议级别,MQTT ` 3.1.* ` 为 ` 4 ` ,MQTT ` 5.0 ` 应是` 5 ` 。 |
38+ | 名称 | 类型 | 必选项 | 描述 |
39+ | -------------- | ------- | ----- | --------------------------------------------------- |
40+ | protocol_name | string | 否 | 协议名称,默认为 ` MQTT ` 。 |
41+ | protocol_level | integer | 是 | 协议级别,MQTT ` 3.1.* ` 为 ` 4 ` ,MQTT ` 5.0 ` 应是` 5 ` 。 |
4242
4343## 启用插件
4444
Original file line number Diff line number Diff line change @@ -182,3 +182,29 @@ qr/(mqtt client id: \w+|proxy request to \S+)/
182182-- - grep_error_log_out
183183mqtt client id: g
184184proxy request to 127.0 . 0. 1: 1995
185+
186+
187+
188+ === TEST 8 : sanity
189+ -- - config
190+ location / t {
191+ content_by_lua_block {
192+ local test_cases = {
193+ {protocol_name = " MQTT" , protocol_level = 4 },
194+ {protocol_name = " MQTT" },
195+ {protocol_level = 4 },
196+ }
197+
198+ local stream_plugin = require (" apisix.stream.plugins.mqtt-proxy" )
199+ for _, case in ipairs(test_cases) do
200+ local ok , err = stream_plugin. check_schema(case)
201+ ngx. say (ok and " done" or err)
202+ end
203+ }
204+ }
205+ -- - request
206+ GET / t
207+ -- - response_body
208+ done
209+ property " protocol_level" is required
210+ done
You can’t perform that action at this time.
0 commit comments