This is an automated email from the ASF dual-hosted git repository.
spacewander pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/apisix.git
The following commit(s) were added to refs/heads/master by this push:
new 16c8648 refactor: ssl schema (#3969)
16c8648 is described below
commit 16c8648aa0b9c7036b32cc7efaa380cdb75c9e13
Author: 罗泽轩 <[email protected]>
AuthorDate: Wed Apr 7 09:02:22 2021 +0800
refactor: ssl schema (#3969)
Signed-off-by: spacewander <[email protected]>
---
apisix/schema_def.lua | 30 ++++++++++++++----------------
t/admin/schema.t | 33 ++-------------------------------
2 files changed, 16 insertions(+), 47 deletions(-)
diff --git a/apisix/schema_def.lua b/apisix/schema_def.lua
index f26ef3c..6e171a7 100644
--- a/apisix/schema_def.lua
+++ b/apisix/schema_def.lua
@@ -598,16 +598,22 @@ _M.consumer = {
_M.upstream = upstream_schema
+local certificate_scheme = {
+ type = "string", minLength = 128, maxLength = 64*1024
+}
+
+
+local private_key_schema = {
+ type = "string", minLength = 128, maxLength = 64*1024
+}
+
+
_M.ssl = {
type = "object",
properties = {
id = id_schema,
- cert = {
- type = "string", minLength = 128, maxLength = 64*1024
- },
- key = {
- type = "string", minLength = 128, maxLength = 64*1024
- },
+ cert = certificate_scheme,
+ key = private_key_schema,
sni = {
type = "string",
pattern = [[^\*?[0-9a-zA-Z-.]+$]],
@@ -622,19 +628,11 @@ _M.ssl = {
},
certs = {
type = "array",
- items = {
- type = "string",
- minLength = 128,
- maxLength = 64*1024,
- }
+ items = certificate_scheme,
},
keys = {
type = "array",
- items = {
- type = "string",
- minLength = 128,
- maxLength = 64*1024,
- }
+ items = private_key_schema,
},
exptime = {
type = "integer",
diff --git a/t/admin/schema.t b/t/admin/schema.t
index 83d1b7e..3c0ddbc 100644
--- a/t/admin/schema.t
+++ b/t/admin/schema.t
@@ -92,41 +92,12 @@ POST /apisix/admin/schema/service
--- config
location /t {
content_by_lua_block {
+ local ssl = require("apisix.schema_def").ssl
local t = require("lib.test_admin").test
local code, body = t('/apisix/admin/schema/ssl',
ngx.HTTP_GET,
nil,
- {
- type = "object",
- properties = {
- cert = {
- type = "string", minLength = 128, maxLength = 64*1024
- },
- key = {
- type = "string", minLength = 128, maxLength = 64*1024
- },
- sni = {
- type = "string",
- pattern = [[^\*?[0-9a-zA-Z-.]+$]],
- },
- snis = {
- type = "array",
- items = {
- type = "string",
- pattern = [[^\*?[0-9a-zA-Z-.]+$]],
- }
- },
- exptime = {
- type = "integer",
- minimum = 1588262400, -- 2020/5/1 0:0:0
- },
- },
- oneOf = {
- {required = {"sni", "key", "cert"}},
- {required = {"snis", "key", "cert"}}
- },
- additionalProperties = false,
- }
+ ssl
)
ngx.status = code