diff --git a/.github/labeler.yml b/.github/labeler.yml index f8539e47407..60d10cb3059 100644 --- a/.github/labeler.yml +++ b/.github/labeler.yml @@ -109,9 +109,6 @@ plugins/key-auth: plugins/ldap-auth: - kong/plugins/ldap-auth/**/* -plugins/log-serializers: -- kong/plugins/log-serializers/**/* - plugins/loggly: - kong/plugins/loggly/**/* diff --git a/CHANGELOG.md b/CHANGELOG.md index 26a4885964c..7b7af63ba95 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -82,6 +82,27 @@ the time comes from a driver like `pgmoon` or `lmdb`. This was done for performance reasons. Deep copying on `"select"` context can still be done before calling this function. [#8796](https://github.com/Kong/kong/pull/8796) +- The deprecated alias of `Kong.serve_admin_api` was removed. If your custom Nginx + templates still use it, please change it to `Kong.admin_content`. + [#8815](https://github.com/Kong/kong/pull/8815) +- The deprecated `shorthands` field in Kong Plugin or DAO schemas was removed in favor + or the typed `shorthand_fields`. If your custom schemas still use `shorthands`, you + need to update them to use `shorhand_fields`. + [#8815](https://github.com/Kong/kong/pull/8815) +- The support for deprecated legacy plugin schemas was removed. If your custom plugins + still use the old (`0.x era`) schemas, you are now forced to upgrade them. + [#8815](https://github.com/Kong/kong/pull/8815) +- The old `kong.plugins.log-serializers.basic` library was removed in favor of the PDK + function `kong.log.serialize`, please upgrade your plugins to use PDK. + [#8815](https://github.com/Kong/kong/pull/8815) +- The Kong constant `CREDENTIAL_USERNAME` with value of `X-Credential-Username` was + removed. Kong plugins in general have moved (since [#5516](https://github.com/Kong/kong/pull/5516)) + to use constant `CREDENTIAL_IDENTIFIER` with value of `X-Credential-Identifier` when + setting the upstream headers for a credential. + [#8815](https://github.com/Kong/kong/pull/8815) +- The support for deprecated hash structured custom plugin DAOs (using `daos.lua`) was + removed. Please upgrade the legacy plugin DAO schemas. + [#8815](https://github.com/Kong/kong/pull/8815) #### Admin API diff --git a/kong-2.8.0-0.rockspec b/kong-2.8.0-0.rockspec index 1ed7e6fd9c3..f565c27d017 100644 --- a/kong-2.8.0-0.rockspec +++ b/kong-2.8.0-0.rockspec @@ -286,9 +286,6 @@ build = { ["kong.plugins.oauth2.daos"] = "kong/plugins/oauth2/daos.lua", ["kong.plugins.oauth2.daos.oauth2_tokens"] = "kong/plugins/oauth2/daos/oauth2_tokens.lua", - - ["kong.plugins.log-serializers.basic"] = "kong/plugins/log-serializers/basic.lua", - ["kong.plugins.tcp-log.handler"] = "kong/plugins/tcp-log/handler.lua", ["kong.plugins.tcp-log.schema"] = "kong/plugins/tcp-log/schema.lua", diff --git a/kong/constants.lua b/kong/constants.lua index d41f03d561c..5fbdbcae2da 100644 --- a/kong/constants.lua +++ b/kong/constants.lua @@ -97,7 +97,6 @@ local constants = { CONSUMER_ID = "X-Consumer-ID", CONSUMER_CUSTOM_ID = "X-Consumer-Custom-ID", CONSUMER_USERNAME = "X-Consumer-Username", - CREDENTIAL_USERNAME = "X-Credential-Username", -- TODO: deprecated, use CREDENTIAL_IDENTIFIER instead CREDENTIAL_IDENTIFIER = "X-Credential-Identifier", RATELIMIT_LIMIT = "X-RateLimit-Limit", RATELIMIT_REMAINING = "X-RateLimit-Remaining", diff --git a/kong/db/schema/init.lua b/kong/db/schema/init.lua index 7ea22ab15d7..38c8c21a9a7 100644 --- a/kong/db/schema/init.lua +++ b/kong/db/schema/init.lua @@ -1647,24 +1647,6 @@ function Schema:process_auto_fields(data, context, nulls, opts) end end - -- deprecated - local shorthands = self.shorthands - if shorthands then - for i = 1, #shorthands do - local sname, sfunc = next(shorthands[i]) - local value = data[sname] - if value ~= nil then - data[sname] = nil - local new_values = sfunc(value) - if new_values then - for k, v in pairs(new_values) do - data[k] = v - end - end - end - end - end - local now_s local now_ms diff --git a/kong/db/schema/metaschema.lua b/kong/db/schema/metaschema.lua index fd0a36eae5d..599327a71c1 100644 --- a/kong/db/schema/metaschema.lua +++ b/kong/db/schema/metaschema.lua @@ -263,19 +263,6 @@ local entity_checks_schema = { } -local shorthands_array = { - type = "array", - elements = { - type = "map", - keys = { type = "string" }, - values = { type = "function" }, - required = true, - len_eq = 1, - }, - nilable = true, -} - - local shorthand_fields_array = { type = "array", elements = { @@ -290,7 +277,6 @@ local shorthand_fields_array = { insert(field_schema, { entity_checks = entity_checks_schema }) -insert(field_schema, { shorthands = shorthands_array }) insert(field_schema, { shorthand_fields = shorthand_fields_array }) @@ -652,9 +638,6 @@ local MetaSchema = Schema.new({ { entity_checks = entity_checks_schema, }, - { - shorthands = shorthands_array, - }, { shorthand_fields = shorthand_fields_array, }, @@ -664,7 +647,7 @@ local MetaSchema = Schema.new({ { check = { type = "function", - nilable = true + nilable = true, }, }, { @@ -675,10 +658,6 @@ local MetaSchema = Schema.new({ }, }, - entity_checks = { - { only_one_of = { "shorthands", "shorthand_fields" } }, - }, - check = function(schema) local errors = {} local fields = schema.fields @@ -843,9 +822,6 @@ MetaSchema.MetaSubSchema = Schema.new({ { entity_checks = entity_checks_schema, }, - { - shorthands = shorthands_array, - }, { shorthand_fields = shorthand_fields_array, }, diff --git a/kong/db/schema/plugin_loader.lua b/kong/db/schema/plugin_loader.lua index 3dd3fa54bda..7f1ee14a74d 100644 --- a/kong/db/schema/plugin_loader.lua +++ b/kong/db/schema/plugin_loader.lua @@ -1,232 +1,14 @@ local MetaSchema = require "kong.db.schema.metaschema" -local socket_url = require "socket.url" -local typedefs = require "kong.db.schema.typedefs" local Entity = require "kong.db.schema.entity" local utils = require "kong.tools.utils" local plugin_servers = require "kong.runloop.plugin_servers" -local utils_toposort = utils.topological_sort - - -local plugin_loader = {} local fmt = string.format -local next = next -local type = type -local insert = table.insert -local ipairs = ipairs - - --- Given a hash of daos_schemas (a hash of tables, --- direct parsing of a plugin's daos.lua file) return an array --- of schemas in which: --- * If entity B has a foreign key to A, then B appears after A --- * If there's no foreign keys, schemas are sorted alphabetically by name -local function sort_daos_schemas_topologically(daos_schemas) - local schema_defs = {} - local len = 0 - local schema_defs_by_name = {} - - for name, schema_def in pairs(daos_schemas) do - if name ~= "tables" or schema_def.fields then - len = len + 1 - schema_defs[len] = schema_def - schema_defs_by_name[schema_def.name] = schema_def - end - end - - -- initially sort by schema name - table.sort(schema_defs, function(a, b) - return a.name > b.name - end) - - -- given a schema_def, return all the schema defs to which it has references - -- (and are on the list of schemas provided) - local get_schema_def_neighbors = function(schema_def) - local neighbors = {} - local neighbors_len = 0 - local neighbor - - for _, field in ipairs(schema_def.fields) do - if field.type == "foreign" then - neighbor = schema_defs_by_name[field.reference] -- services - if neighbor then - neighbors_len = neighbors_len + 1 - neighbors[neighbors_len] = neighbor - end - -- else the neighbor points to an unknown/uninteresting schema. This might happen in tests. - end - end - - return neighbors - end - - return utils_toposort(schema_defs, get_schema_def_neighbors) -end - - ---- Check if a string is a parseable URL. --- @param v input string string --- @return boolean indicating whether string is an URL. -local function validate_url(v) - if v and type(v) == "string" then - local url = socket_url.parse(v) - if url and not url.path then - url.path = "/" - end - return not not (url and url.path and url.host and url.scheme) - end -end - - ---- Read a plugin schema table in the old-DAO format and produce a --- best-effort translation of it into a plugin subschema in the new-DAO format. --- @param name a string with the schema name. --- @param old_schema the old-format schema table. --- @return a table with a new-format plugin subschema; or nil and a message. -local function convert_legacy_schema(name, old_schema) - local new_schema = { - name = name, - fields = { - { config = { - type = "record", - required = true, - fields = {} - }} - }, - entity_checks = old_schema.entity_checks, - } - - for old_fname, old_fdata in pairs(old_schema.fields) do - local new_fdata = {} - local new_field = { [old_fname] = new_fdata } - local elements = {} - for k, v in pairs(old_fdata) do - - if k == "type" then - if v == "url" then - new_fdata.type = "string" - new_fdata.custom_validator = validate_url - - elseif v == "table" then - if old_fdata.schema and old_fdata.schema.flexible then - new_fdata.type = "map" - else - new_fdata.type = "record" - if new_fdata.required == nil then - new_fdata.required = true - end - end - - elseif v == "array" then - new_fdata.type = "array" - elements.type = "string" - -- FIXME stored as JSON in old db - - elseif v == "timestamp" then - new_fdata = typedefs.timestamp - - elseif v == "string" then - new_fdata.type = v - new_fdata.len_min = 0 - - elseif v == "number" - or v == "boolean" then - new_fdata.type = v - - else - return nil, "unkown legacy field type: " .. v - end - - elseif k == "schema" then - local rfields, err = convert_legacy_schema("fields", v) - if err then - return nil, err - end - rfields = rfields.fields[1].config.fields +local tostring = tostring - if v.flexible then - new_fdata.keys = { type = "string" } - new_fdata.values = { - type = "record", - required = true, - fields = rfields, - } - else - new_fdata.fields = rfields - local rdefault = {} - local has_default = false - for _, field in ipairs(rfields) do - local fname = next(field) - local fdata = field[fname] - if fdata.default then - rdefault[fname] = fdata.default - has_default = true - end - end - if has_default then - new_fdata.default = rdefault - end - end - elseif k == "immutable" then - -- FIXME really ignore? - kong.log.debug("ignoring 'immutable' property") - - elseif k == "enum" then - if old_fdata.type == "array" then - elements.one_of = v - else - new_fdata.one_of = v - end - - elseif k == "default" - or k == "required" - or k == "unique" then - new_fdata[k] = v - - elseif k == "func" then - -- FIXME some should become custom validators, some entity checks - new_fdata.custom_validator = nil -- v - - elseif k == "new_type" then - new_field[old_fname] = v - break - - else - return nil, "unknown legacy field attribute: " .. require"inspect"(k) - end - - end - if new_fdata.type == "array" then - new_fdata.elements = elements - end - - if (new_fdata.type == "map" and new_fdata.keys == nil) - or (new_fdata.type == "record" and new_fdata.fields == nil) then - new_fdata.type = "map" - new_fdata.keys = { type = "string" } - new_fdata.values = { type = "string" } - end - - if new_fdata.type == nil then - new_fdata.type = "string" - end - - insert(new_schema.fields[1].config.fields, new_field) - end - - if old_schema.no_route then - insert(new_schema.fields, { route = typedefs.no_route }) - end - if old_schema.no_service then - insert(new_schema.fields, { service = typedefs.no_service }) - end - if old_schema.no_consumer then - insert(new_schema.fields, { consumer = typedefs.no_consumer }) - end - return new_schema -end +local plugin_loader = {} function plugin_loader.load_subschema(parent_schema, plugin, errors) @@ -240,28 +22,13 @@ function plugin_loader.load_subschema(parent_schema, plugin, errors) return nil, "no configuration schema found for plugin: " .. plugin end - local err - local is_legacy = false - if not schema.name then - is_legacy = true - schema, err = convert_legacy_schema(plugin, schema) - end - - if not err then - local err_t - ok, err_t = MetaSchema.MetaSubSchema:validate(schema) - if not ok then - err = tostring(errors:schema_violation(err_t)) - end - end - - if err then - if is_legacy then - err = "failed converting legacy schema for " .. plugin .. ": " .. err - end - return nil, err + local err_t + ok, err_t = MetaSchema.MetaSubSchema:validate(schema) + if not ok then + return nil, tostring(errors:schema_violation(err_t)) end + local err ok, err = Entity.new_subschema(parent_schema, plugin, schema) if not ok then return nil, "error initializing schema for plugin: " .. err @@ -293,16 +60,6 @@ function plugin_loader.load_entities(plugin, errors, loader_fn) if not has_daos then return {} end - if not daos_schemas[1] and next(daos_schemas) then - -- daos_schemas is a non-empty hash (old syntax). Sort it topologically in order to avoid errors when loading - -- relationships before loading entities within the same plugin - daos_schemas = sort_daos_schemas_topologically(daos_schemas) - - kong.log.deprecation("The plugin ", plugin, - " is using a hash-like syntax on its `daos.lua` file. ", - "Please replace the hash table with a sequential array of schemas.", - { after = "2.6.0", removal = "3.0.0" }) - end local res = {} local schema_def, ret, err diff --git a/kong/init.lua b/kong/init.lua index 93db2fa3cfd..34a920cda10 100644 --- a/kong/init.lua +++ b/kong/init.lua @@ -1444,10 +1444,6 @@ function Kong.admin_content(options) end --- TODO: deprecate the following alias -Kong.serve_admin_api = Kong.admin_content - - function Kong.admin_header_filter() local ctx = ngx.ctx @@ -1504,6 +1500,7 @@ function Kong.serve_cluster_listener(options) return kong.clustering:handle_cp_websocket() end + function Kong.serve_wrpc_listener(options) log_init_worker_errors() diff --git a/kong/plugins/basic-auth/access.lua b/kong/plugins/basic-auth/access.lua index 93dfbbe6990..2f8eced0db2 100644 --- a/kong/plugins/basic-auth/access.lua +++ b/kong/plugins/basic-auth/access.lua @@ -134,10 +134,8 @@ local function set_consumer(consumer, credential) if credential and credential.username then set_header(constants.HEADERS.CREDENTIAL_IDENTIFIER, credential.username) - set_header(constants.HEADERS.CREDENTIAL_USERNAME, credential.username) else clear_header(constants.HEADERS.CREDENTIAL_IDENTIFIER) - clear_header(constants.HEADERS.CREDENTIAL_USERNAME) end if credential then diff --git a/kong/plugins/hmac-auth/access.lua b/kong/plugins/hmac-auth/access.lua index be052cc8f70..6a2b3743768 100644 --- a/kong/plugins/hmac-auth/access.lua +++ b/kong/plugins/hmac-auth/access.lua @@ -265,10 +265,8 @@ local function set_consumer(consumer, credential) if credential and credential.username then set_header(constants.HEADERS.CREDENTIAL_IDENTIFIER, credential.username) - set_header(constants.HEADERS.CREDENTIAL_USERNAME, credential.username) else clear_header(constants.HEADERS.CREDENTIAL_IDENTIFIER) - clear_header(constants.HEADERS.CREDENTIAL_USERNAME) end if credential then diff --git a/kong/plugins/jwt/handler.lua b/kong/plugins/jwt/handler.lua index 87bcc8b5541..834c1cfa551 100644 --- a/kong/plugins/jwt/handler.lua +++ b/kong/plugins/jwt/handler.lua @@ -105,8 +105,6 @@ local function set_consumer(consumer, credential, token) clear_header(constants.HEADERS.CREDENTIAL_IDENTIFIER) end - clear_header(constants.HEADERS.CREDENTIAL_USERNAME) - if credential then clear_header(constants.HEADERS.ANONYMOUS) else diff --git a/kong/plugins/key-auth/handler.lua b/kong/plugins/key-auth/handler.lua index d4b758c1eb4..17fe5dca9a1 100644 --- a/kong/plugins/key-auth/handler.lua +++ b/kong/plugins/key-auth/handler.lua @@ -58,8 +58,6 @@ local function set_consumer(consumer, credential) clear_header(constants.HEADERS.CREDENTIAL_IDENTIFIER) end - clear_header(constants.HEADERS.CREDENTIAL_USERNAME) - if credential then clear_header(constants.HEADERS.ANONYMOUS) else diff --git a/kong/plugins/ldap-auth/access.lua b/kong/plugins/ldap-auth/access.lua index 0fd912e4d53..4e236e19f07 100644 --- a/kong/plugins/ldap-auth/access.lua +++ b/kong/plugins/ldap-auth/access.lua @@ -185,10 +185,8 @@ local function set_consumer(consumer, credential) if credential and credential.username then set_header(constants.HEADERS.CREDENTIAL_IDENTIFIER, credential.username) - set_header(constants.HEADERS.CREDENTIAL_USERNAME, credential.username) else clear_header(constants.HEADERS.CREDENTIAL_IDENTIFIER) - clear_header(constants.HEADERS.CREDENTIAL_USERNAME) end if credential then diff --git a/kong/plugins/log-serializers/basic.lua b/kong/plugins/log-serializers/basic.lua deleted file mode 100644 index 37369c9e837..00000000000 --- a/kong/plugins/log-serializers/basic.lua +++ /dev/null @@ -1,24 +0,0 @@ -local _M = {} - - -local kong = kong - - -local WARNING_SHOWN = false - --- stream log serializer is new, so no one should be depending on this proxy... -if ngx.config.subsystem == "http" then - function _M.serialize(ongx, okong) - if not WARNING_SHOWN then - kong.log.warn("basic log serializer has been deprecated, please modify " .. - "your plugin to use the kong.log.serialize PDK function " .. - "instead") - WARNING_SHOWN = true - end - - return kong.log.serialize({ ngx = ongx, kong = okong, }) - end -end - - -return _M diff --git a/kong/plugins/oauth2/access.lua b/kong/plugins/oauth2/access.lua index d7f9aa082a8..806733251f0 100644 --- a/kong/plugins/oauth2/access.lua +++ b/kong/plugins/oauth2/access.lua @@ -923,8 +923,6 @@ local function set_consumer(consumer, credential, token) clear_header(constants.HEADERS.CREDENTIAL_IDENTIFIER) end - clear_header(constants.HEADERS.CREDENTIAL_USERNAME) - if credential then clear_header(constants.HEADERS.ANONYMOUS) else diff --git a/spec/01-unit/10-log_serializer_spec.lua b/spec/01-unit/10-log_serializer_spec.lua index faf233c3d8e..def0e91eb3e 100644 --- a/spec/01-unit/10-log_serializer_spec.lua +++ b/spec/01-unit/10-log_serializer_spec.lua @@ -1,7 +1,9 @@ require("spec.helpers") -local basic = require("kong.plugins.log-serializers.basic") + + local LOG_PHASE = require("kong.pdk.private.phases").phases.log + describe("kong.log.serialize", function() describe("#http", function() before_each(function() @@ -168,30 +170,6 @@ describe("kong.log.serialize", function() assert.is_nil(res.tries) end) - - it("basic serializer proxy works with a deprecation warning", function() - local warned = false - local orig_warn = kong.log.warn - - kong.log.warn = function(msg) - assert.is_false(warned, "duplicate warning") - - warned = true - - return orig_warn(msg) - end - - local res = basic.serialize(ngx, kong) - assert.is_table(res) - - assert.equals("1.1.1.1", res.client_ip) - - -- 2nd time - res = basic.serialize(ngx, kong) - assert.is_table(res) - - kong.log.warn = orig_warn - end) end) end) diff --git a/spec/02-integration/03-db/03-plugins_spec.lua b/spec/02-integration/03-db/03-plugins_spec.lua index 7bc914f8e3f..6501f0d0eb5 100644 --- a/spec/02-integration/03-db/03-plugins_spec.lua +++ b/spec/02-integration/03-db/03-plugins_spec.lua @@ -206,56 +206,6 @@ for _, strategy in helpers.each_strategy() do assert.falsy(ok) assert.match("missing plugin is enabled but not installed", err, 1, true) end) - - it("reports failure with bad plugins #4392", function() - local ok, err = db.plugins:load_plugin_schemas({ - ["legacy-plugin-bad"] = true, - }) - assert.falsy(ok) - assert.match("failed converting legacy schema for legacy-plugin-bad", err, 1, true) - end) - - it("succeeds with good plugins", function() - local ok, err = db.plugins:load_plugin_schemas({ - ["legacy-plugin-good"] = true, - }) - assert.truthy(ok) - assert.is_nil(err) - - local foo = { - required = false, - type = "map", - keys = { type = "string" }, - values = { type = "string" }, - default = { - foo = "boo", - bar = "bla", - } - } - local config = { - type = "record", - required = true, - fields = { - { foo = foo }, - foo = foo, - } - } - local consumer = { - type = "foreign", - reference = "consumers", - eq = ngx.null, - schema = db.consumers.schema, - } - assert.same({ - name = "legacy-plugin-good", - fields = { - { config = config }, - { consumer = consumer }, - config = config, - consumer = consumer, - } - }, db.plugins.schema.subschemas["legacy-plugin-good"]) - end) end) end) -- kong.db [strategy] end diff --git a/spec/03-plugins/09-key-auth/02-access_spec.lua b/spec/03-plugins/09-key-auth/02-access_spec.lua index 930e667a704..1a365dd5457 100644 --- a/spec/03-plugins/09-key-auth/02-access_spec.lua +++ b/spec/03-plugins/09-key-auth/02-access_spec.lua @@ -531,7 +531,6 @@ for _, strategy in helpers.each_strategy() do assert.is_string(json.headers["x-consumer-id"]) assert.equal("bob", json.headers["x-consumer-username"]) assert.equal(kong_cred.id, json.headers["x-credential-identifier"]) - assert.equal(nil, json.headers["x-credential-username"]) assert.is_nil(json.headers["x-anonymous-consumer"]) end) end) @@ -659,7 +658,6 @@ for _, strategy in helpers.each_strategy() do local body = cjson.decode(assert.res_status(200, res)) assert.equal('bob', body.headers["x-consumer-username"]) assert.equal(kong_cred.id, body.headers["x-credential-identifier"]) - assert.equal(nil, body.headers["x-credential-username"]) assert.is_nil(body.headers["x-anonymous-consumer"]) end) it("works with wrong credentials and anonymous", function() @@ -673,7 +671,6 @@ for _, strategy in helpers.each_strategy() do local body = cjson.decode(assert.res_status(200, res)) assert.equal('true', body.headers["x-anonymous-consumer"]) assert.equal(nil, body.headers["x-credential-identifier"]) - assert.equal(nil, body.headers["x-credential-username"]) assert.equal('no-body', body.headers["x-consumer-username"]) end) it("works with wrong credentials and username as anonymous", function() diff --git a/spec/03-plugins/10-basic-auth/03-access_spec.lua b/spec/03-plugins/10-basic-auth/03-access_spec.lua index 987d46a3ded..171c01d8ad4 100644 --- a/spec/03-plugins/10-basic-auth/03-access_spec.lua +++ b/spec/03-plugins/10-basic-auth/03-access_spec.lua @@ -262,7 +262,6 @@ for _, strategy in helpers.each_strategy() do local body = cjson.decode(assert.res_status(200, res)) assert.equal('bob', body.headers["x-consumer-username"]) assert.equal('user123', body.headers["x-credential-identifier"]) - assert.equal('user123', body.headers["x-credential-username"]) end) it("authenticates with a password containing ':'", function() @@ -277,7 +276,6 @@ for _, strategy in helpers.each_strategy() do local body = cjson.decode(assert.res_status(200, res)) assert.equal("bob", body.headers["x-consumer-username"]) assert.equal("user321", body.headers["x-credential-identifier"]) - assert.equal('user321', body.headers["x-credential-username"]) end) it("returns 401 for valid Base64 encoding", function() @@ -324,7 +322,6 @@ for _, strategy in helpers.each_strategy() do assert.is_string(json.headers["x-consumer-id"]) assert.equal("bob", json.headers["x-consumer-username"]) assert.equal("bob", json.headers["x-credential-identifier"]) - assert.equal('bob', json.headers["x-credential-username"]) end) end) @@ -376,7 +373,6 @@ for _, strategy in helpers.each_strategy() do local body = cjson.decode(assert.res_status(200, res)) assert.equal('bob', body.headers["x-consumer-username"]) assert.equal('user123', body.headers["x-credential-identifier"]) - assert.equal('user123', body.headers["x-credential-username"]) assert.is_nil(body.headers["x-anonymous-consumer"]) end) @@ -392,7 +388,6 @@ for _, strategy in helpers.each_strategy() do assert.equal('true', body.headers["x-anonymous-consumer"]) assert.equal('no-body', body.headers["x-consumer-username"]) assert.equal(nil, body.headers["x-credential-identifier"]) - assert.equal(nil, body.headers["x-credential-username"]) end) it("works with wrong credentials and username in anonymous", function() diff --git a/spec/03-plugins/10-basic-auth/05-declarative_spec.lua b/spec/03-plugins/10-basic-auth/05-declarative_spec.lua index 747b68ccc94..a1c1495b48c 100644 --- a/spec/03-plugins/10-basic-auth/05-declarative_spec.lua +++ b/spec/03-plugins/10-basic-auth/05-declarative_spec.lua @@ -199,7 +199,6 @@ for _, strategy in helpers.each_strategy() do assert.equal(consumer_def.username, json.headers["x-consumer-username"]) assert.equal(consumer_def.custom_id, json.headers["x-consumer-custom-id"]) assert.equal(basicauth_credential_def.username, json.headers["x-credential-identifier"]) - assert.equal(basicauth_credential_def.username, json.headers["x-credential-username"]) end) it("Accepts valid credentials (introduced with a hashed password)", function() @@ -219,7 +218,6 @@ for _, strategy in helpers.each_strategy() do assert.equal(consumer_def.username, json.headers["x-consumer-username"]) assert.equal(consumer_def.custom_id, json.headers["x-consumer-custom-id"]) assert.equal(basicauth_hashed_credential_def.username, json.headers["x-credential-identifier"]) - assert.equal(basicauth_hashed_credential_def.username, json.headers["x-credential-username"]) end) end) end) diff --git a/spec/03-plugins/16-jwt/03-access_spec.lua b/spec/03-plugins/16-jwt/03-access_spec.lua index 7317cb9caf2..076401cebe8 100644 --- a/spec/03-plugins/16-jwt/03-access_spec.lua +++ b/spec/03-plugins/16-jwt/03-access_spec.lua @@ -413,7 +413,6 @@ for _, strategy in helpers.each_strategy() do assert.equal(authorization, body.headers.authorization) assert.equal("jwt_tests_consumer", body.headers["x-consumer-username"]) assert.equal(jwt_secret.key, body.headers["x-credential-identifier"]) - assert.equal(nil, body.headers["x-credential-username"]) assert.is_nil(body.headers["x-anonymous-consumer"]) end) @@ -461,7 +460,6 @@ for _, strategy in helpers.each_strategy() do assert.equal(authorization, body.headers.authorization) assert.equal("jwt_tests_consumer", body.headers["x-consumer-username"]) assert.equal(jwt_secret.key, body.headers["x-credential-identifier"]) - assert.equal(nil, body.headers["x-credential-username"]) end) it("proxies the request if secret is base64", function() PAYLOAD.iss = base64_jwt_secret.key @@ -493,7 +491,6 @@ for _, strategy in helpers.each_strategy() do assert.equal(authorization, body.headers.authorization) assert.equal("jwt_tests_base64_consumer", body.headers["x-consumer-username"]) assert.equal(base64_jwt_secret.key, body.headers["x-credential-identifier"]) - assert.equal(nil, body.headers["x-credential-username"]) end) it("returns 200 the JWT is found in the cookie crumble", function() PAYLOAD.iss = jwt_secret.key @@ -642,7 +639,6 @@ for _, strategy in helpers.each_strategy() do assert.equal(authorization, body.headers.authorization) assert.equal("jwt_tests_rsa_consumer_1", body.headers["x-consumer-username"]) assert.equal(rsa_jwt_secret_1.key, body.headers["x-credential-identifier"]) - assert.equal(nil, body.headers["x-credential-username"]) end) it("identifies Consumer", function() PAYLOAD.iss = rsa_jwt_secret_2.key @@ -660,7 +656,6 @@ for _, strategy in helpers.each_strategy() do assert.equal(authorization, body.headers.authorization) assert.equal("jwt_tests_rsa_consumer_2", body.headers["x-consumer-username"]) assert.equal(rsa_jwt_secret_2.key, body.headers["x-credential-identifier"]) - assert.equal(nil, body.headers["x-credential-username"]) end) end) @@ -681,7 +676,6 @@ for _, strategy in helpers.each_strategy() do assert.equal(authorization, body.headers.authorization) assert.equal("jwt_tests_rsa_consumer_5", body.headers["x-consumer-username"]) assert.equal(rsa_jwt_secret_3.key, body.headers["x-credential-identifier"]) - assert.equal(nil, body.headers["x-credential-username"]) end) it("identifies Consumer", function() PAYLOAD.iss = rsa_jwt_secret_3.key @@ -699,7 +693,6 @@ for _, strategy in helpers.each_strategy() do assert.equal(authorization, body.headers.authorization) assert.equal("jwt_tests_rsa_consumer_5", body.headers["x-consumer-username"]) assert.equal(rsa_jwt_secret_3.key, body.headers["x-credential-identifier"]) - assert.equal(nil, body.headers["x-credential-username"]) end) end) @@ -720,7 +713,6 @@ for _, strategy in helpers.each_strategy() do assert.equal(authorization, body.headers.authorization) assert.equal("jwt_tests_rsa_consumer_9", body.headers["x-consumer-username"]) assert.equal(rsa_jwt_secret_4.key, body.headers["x-credential-identifier"]) - assert.equal(nil, body.headers["x-credential-username"]) end) it("identifies Consumer", function() PAYLOAD.iss = rsa_jwt_secret_4.key @@ -738,7 +730,6 @@ for _, strategy in helpers.each_strategy() do assert.equal(authorization, body.headers.authorization) assert.equal("jwt_tests_rsa_consumer_9", body.headers["x-consumer-username"]) assert.equal(rsa_jwt_secret_4.key, body.headers["x-credential-identifier"]) - assert.equal(nil, body.headers["x-credential-username"]) end) end) @@ -760,7 +751,6 @@ for _, strategy in helpers.each_strategy() do assert.equal(authorization, body.headers.authorization) assert.equal("jwt_tests_rsa_consumer_10", body.headers["x-consumer-username"]) assert.equal(rsa_jwt_secret_5.key, body.headers["x-credential-identifier"]) - assert.equal(nil, body.headers["x-credential-username"]) end) it("identifies Consumer", function() PAYLOAD.iss = rsa_jwt_secret_5.key @@ -778,7 +768,6 @@ for _, strategy in helpers.each_strategy() do assert.equal(authorization, body.headers.authorization) assert.equal("jwt_tests_rsa_consumer_10", body.headers["x-consumer-username"]) assert.equal(rsa_jwt_secret_5.key, body.headers["x-credential-identifier"]) - assert.equal(nil, body.headers["x-credential-username"]) end) end) @@ -800,7 +789,6 @@ for _, strategy in helpers.each_strategy() do assert.equal("jwt_tests_hs_consumer_7", body.headers["x-consumer-username"]) assert.equal(hs_jwt_secret_1.key, body.headers["x-credential-identifier"]) assert.is_nil(body.headers["x-anonymous-consumer"]) - assert.equal(nil, body.headers["x-credential-username"]) end) end) @@ -821,7 +809,6 @@ for _, strategy in helpers.each_strategy() do assert.equal(authorization, body.headers.authorization) assert.equal("jwt_tests_hs_consumer_8", body.headers["x-consumer-username"]) assert.equal(hs_jwt_secret_2.key, body.headers["x-credential-identifier"]) - assert.equal(nil, body.headers["x-credential-username"]) assert.is_nil(body.headers["x-anonymous-consumer"]) end) end) @@ -913,7 +900,6 @@ for _, strategy in helpers.each_strategy() do local body = cjson.decode(assert.res_status(200, res)) assert.equal('jwt_tests_consumer', body.headers["x-consumer-username"]) assert.equal(jwt_secret.key, body.headers["x-credential-identifier"]) - assert.equal(nil, body.headers["x-credential-username"]) assert.is_nil(body.headers["x-anonymous-consumer"]) end) it("works with wrong credentials and anonymous", function() @@ -928,7 +914,6 @@ for _, strategy in helpers.each_strategy() do assert.equal('true', body.headers["x-anonymous-consumer"]) assert.equal('no-body', body.headers["x-consumer-username"]) assert.equal(nil, body.headers["x-credential-identifier"]) - assert.equal(nil, body.headers["x-credential-username"]) end) it("works with wrong credentials and username in anonymous", function() local res = assert(proxy_client:send { @@ -1076,7 +1061,6 @@ for _, strategy in helpers.each_strategy() do assert.request(res).has.no.header("x-anonymous-consumer") local id = assert.request(res).has.header("x-consumer-id") local key = assert.request(res).has.header("x-credential-identifier") - assert.request(res).has.no.header("x-credential-username") assert.not_equal(id, anonymous.id) assert(id == user1.id or id == user2.id) assert.equal(key_auth.id, key) @@ -1135,7 +1119,6 @@ for _, strategy in helpers.each_strategy() do assert.request(res).has.no.header("x-anonymous-consumer") local id = assert.request(res).has.header("x-consumer-id") local key = assert.request(res).has.header("x-credential-identifier") - assert.request(res).has.no.header("x-credential-username") assert.not_equal(id, anonymous.id) assert(id == user1.id or id == user2.id) assert.equal(PAYLOAD.iss, key) @@ -1156,7 +1139,6 @@ for _, strategy in helpers.each_strategy() do assert.not_equal(id, anonymous.id) assert.equal(user1.id, id) assert.not_equal(PAYLOAD.iss, res.headers["x-credential-identifier"]) - assert.equal(nil, res.headers["x-credential-username"]) end) it("passes with only the second credential provided", function() @@ -1172,7 +1154,6 @@ for _, strategy in helpers.each_strategy() do assert.request(res).has.no.header("x-anonymous-consumer") local id = assert.request(res).has.header("x-consumer-id") local key = assert.request(res).has.header("x-credential-identifier") - assert.request(res).has.no.header("x-credential-username") assert.not_equal(id, anonymous.id) assert.equal(user2.id, id) assert.equal(PAYLOAD.iss, key) @@ -1190,7 +1171,6 @@ for _, strategy in helpers.each_strategy() do assert.request(res).has.header("x-anonymous-consumer") local id = assert.request(res).has.header("x-consumer-id") assert.not_equal(PAYLOAD.iss, res.headers["x-credential-identifier"]) - assert.request(res).has.no.header("x-credential-username") assert.equal(id, anonymous.id) end) end) diff --git a/spec/03-plugins/19-hmac-auth/03-access_spec.lua b/spec/03-plugins/19-hmac-auth/03-access_spec.lua index fc30d1b09f9..dd34001d0b4 100644 --- a/spec/03-plugins/19-hmac-auth/03-access_spec.lua +++ b/spec/03-plugins/19-hmac-auth/03-access_spec.lua @@ -859,7 +859,6 @@ for _, strategy in helpers.each_strategy() do assert.equal(consumer.id, parsed_body.headers["x-consumer-id"]) assert.equal(consumer.username, parsed_body.headers["x-consumer-username"]) assert.equal(credential.username, parsed_body.headers["x-credential-identifier"]) - assert.equal(credential.username, parsed_body.headers["x-credential-username"]) assert.is_nil(parsed_body.headers["x-anonymous-consumer"]) end) @@ -1046,7 +1045,6 @@ for _, strategy in helpers.each_strategy() do assert.equal(hmacAuth, body.headers["authorization"]) assert.equal("bob", body.headers["x-consumer-username"]) assert.equal(credential.username, body.headers["x-credential-identifier"]) - assert.equal(credential.username, body.headers["x-credential-username"]) assert.is_nil(body.headers["x-anonymous-consumer"]) end) @@ -1131,8 +1129,6 @@ for _, strategy in helpers.each_strategy() do assert.equal("true", body.headers["x-anonymous-consumer"]) assert.equal('no-body', body.headers["x-consumer-username"]) assert.equal(nil, body.headers["x-credential-identifier"]) - assert.equal(nil, body.headers["x-credential-username"]) - end) it("should pass with invalid credentials and username in anonymous", function() diff --git a/spec/03-plugins/20-ldap-auth/01-access_spec.lua b/spec/03-plugins/20-ldap-auth/01-access_spec.lua index f01a2ff5fd9..24b1438553c 100644 --- a/spec/03-plugins/20-ldap-auth/01-access_spec.lua +++ b/spec/03-plugins/20-ldap-auth/01-access_spec.lua @@ -338,8 +338,6 @@ for _, ldap_strategy in pairs(ldap_strategies) do assert.response(res).has.status(200) local value = assert.request(res).has.header("x-credential-identifier") assert.are.equal("einstein", value) - local value = assert.request(res).has.header("x-credential-username") - assert.are.equal("einstein", value) assert.request(res).has_not.header("x-anonymous-username") end) it("authorization fails if credential does has no password encoded in get request", function() @@ -464,8 +462,6 @@ for _, ldap_strategy in pairs(ldap_strategies) do assert.response(res).has.status(200) local value = assert.request(res).has.header("x-credential-identifier") assert.are.equal("einstein", value) - local value = assert.request(res).has.header("x-credential-username") - assert.are.equal("einstein", value) assert.request(res).has_not.header("x-anonymous-username") end) it("caches LDAP Auth Credential", function() @@ -510,8 +506,6 @@ for _, ldap_strategy in pairs(ldap_strategies) do local value = assert.request(res).has.header("x-credential-identifier") assert.are.equal("einstein", value) - local value = assert.request(res).has.header("x-credential-username") - assert.are.equal("einstein", value) assert.request(res).has_not.header("x-anonymous-username") end) it("works with wrong credentials and anonymous", function() @@ -528,7 +522,6 @@ for _, ldap_strategy in pairs(ldap_strategies) do value = assert.request(res).has.header("x-consumer-username") assert.equal('no-body', value) assert.request(res).has.no.header("x-credential-identifier") - assert.request(res).has.no.header("x-credential-username") end) it("works with wrong credentials and username in anonymous", function() local res = assert(proxy_client:send { @@ -730,7 +723,6 @@ for _, ldap_strategy in pairs(ldap_strategies) do assert(id == user.id) local value = assert.request(res).has.header("x-credential-identifier") assert.equal(keyauth.id, value) - assert.request(res).has.no.header("x-credential-username") end) it("passes with only the first credential provided", function() @@ -749,7 +741,6 @@ for _, ldap_strategy in pairs(ldap_strategies) do assert.equal(user.id, id) local value = assert.request(res).has.header("x-credential-identifier") assert.equal(keyauth.id, value) - assert.request(res).has.no.header("x-credential-username") end) it("passes with only the second credential provided", function() @@ -765,8 +756,6 @@ for _, ldap_strategy in pairs(ldap_strategies) do assert.request(res).has.no.header("x-anonymous-consumer") local id = assert.request(res).has.header("x-credential-identifier") assert.equal("einstein", id) - local id = assert.request(res).has.header("x-credential-username") - assert.equal("einstein", id) end) it("passes with no credential provided", function() @@ -782,7 +771,6 @@ for _, ldap_strategy in pairs(ldap_strategies) do local id = assert.request(res).has.header("x-consumer-id") assert.equal(id, anonymous.id) assert.request(res).has.no.header("x-credential-identifier") - assert.request(res).has.no.header("x-credential-username") end) end) end) diff --git a/spec/03-plugins/25-oauth2/03-access_spec.lua b/spec/03-plugins/25-oauth2/03-access_spec.lua index 1252080b1b5..15c7b07909b 100644 --- a/spec/03-plugins/25-oauth2/03-access_spec.lua +++ b/spec/03-plugins/25-oauth2/03-access_spec.lua @@ -1287,7 +1287,6 @@ describe("Plugin: oauth2 [#" .. strategy .. "]", function() assert.are.equal("email profile", body.headers["x-authenticated-scope"]) assert.are.equal("userid123", body.headers["x-authenticated-userid"]) assert.are.equal("clientid123", body.headers["x-credential-identifier"]) - assert.are.equal(nil, body.headers["x-credential-username"]) end) end) @@ -1651,7 +1650,6 @@ describe("Plugin: oauth2 [#" .. strategy .. "]", function() assert.are.equal("email", body.headers["x-authenticated-scope"]) assert.are.equal("hello", body.headers["x-authenticated-userid"]) assert.are.equal("clientid123", body.headers["x-credential-identifier"]) - assert.are.equal(nil, body.headers["x-credential-username"]) end) it("works in a multipart request", function() local res = assert(proxy_ssl_client:send { @@ -1899,7 +1897,6 @@ describe("Plugin: oauth2 [#" .. strategy .. "]", function() assert.are.equal("email", body.headers["x-authenticated-scope"]) assert.are.equal("id123", body.headers["x-authenticated-userid"]) assert.are.equal("clientid123", body.headers["x-credential-identifier"]) - assert.are.equal(nil, body.headers["x-credential-username"]) end) end) end) @@ -2109,7 +2106,6 @@ describe("Plugin: oauth2 [#" .. strategy .. "]", function() assert.are.equal("email", body.headers["x-authenticated-scope"]) assert.are.equal("userid123", body.headers["x-authenticated-userid"]) assert.are.equal("clientid123", body.headers["x-credential-identifier"]) - assert.are.equal(nil, body.headers["x-credential-username"]) end) it("fails when an authorization code is used more than once", function() local code = provision_code() @@ -2949,7 +2945,6 @@ describe("Plugin: oauth2 [#" .. strategy .. "]", function() assert.are.equal("userid123", body.headers["x-authenticated-userid"]) assert.are.equal("email", body.headers["x-authenticated-scope"]) assert.are.equal("clientid123", body.headers["x-credential-identifier"]) - assert.are.equal(nil, body.headers["x-credential-username"]) assert.is_nil(body.headers["x-anonymous-consumer"]) end) @@ -3018,7 +3013,6 @@ describe("Plugin: oauth2 [#" .. strategy .. "]", function() assert.are.equal("userid123", body.headers["x-authenticated-userid"]) assert.are.equal("email", body.headers["x-authenticated-scope"]) assert.are.equal("clientid123", body.headers["x-credential-identifier"]) - assert.are.equal(nil, body.headers["x-credential-username"]) assert.is_nil(body.headers["x-anonymous-consumer"]) end) it("works with wrong credentials and anonymous", function() @@ -3033,7 +3027,6 @@ describe("Plugin: oauth2 [#" .. strategy .. "]", function() assert.are.equal("true", body.headers["x-anonymous-consumer"]) assert.equal('no-body', body.headers["x-consumer-username"]) assert.are.equal(nil, body.headers["x-credential-identifier"]) - assert.are.equal(nil, body.headers["x-credential-username"]) end) it("works with wrong credentials and username in anonymous", function() @@ -3768,7 +3761,6 @@ describe("Plugin: oauth2 [#" .. strategy .. "]", function() local client_id = assert.request(res).has.header("x-credential-identifier") assert.equal(keyauth.id, client_id) - assert.request(res).has.no.header("x-credential-username") end) it("fails 401, with only the first credential provided", function() @@ -3833,7 +3825,6 @@ describe("Plugin: oauth2 [#" .. strategy .. "]", function() assert(id == user1.id or id == user2.id) local client_id = assert.request(res).has.header("x-credential-identifier") assert.equal("clientid4567", client_id) - assert.request(res).has.no.header("x-credential-username") end) it("passes with only the first credential provided (higher priority)", function() @@ -3855,7 +3846,6 @@ describe("Plugin: oauth2 [#" .. strategy .. "]", function() assert.equal(user1.id, id) local client_id = assert.request(res).has.header("x-credential-identifier") assert.equal(keyauth.id, client_id) - assert.request(res).has.no.header("x-credential-username") assert.request(res).has.no.header("x-authenticated-scope") assert.request(res).has.no.header("x-authenticated-userid") end) @@ -3882,7 +3872,6 @@ describe("Plugin: oauth2 [#" .. strategy .. "]", function() assert.equal(user1.id, id) local client_id = assert.request(res).has.header("x-credential-identifier") assert.equal(jwt_secret.key, client_id) - assert.request(res).has.no.header("x-credential-username") assert.request(res).has.no.header("x-authenticated-scope") assert.request(res).has.no.header("x-authenticated-userid") end) @@ -3905,7 +3894,6 @@ describe("Plugin: oauth2 [#" .. strategy .. "]", function() assert.equal(user2.id, id) local client_id = assert.request(res).has.header("x-credential-identifier") assert.equal("clientid4567", client_id) - assert.request(res).has.no.header("x-credential-username") end) it("passes with no credential provided", function() @@ -3921,7 +3909,6 @@ describe("Plugin: oauth2 [#" .. strategy .. "]", function() local id = assert.request(res).has.header("x-consumer-id") assert.equal(id, anonymous.id) assert.request(res).has.no.header("x-credential-identifier") - assert.request(res).has.no.header("x-credential-username") end) end) end) diff --git a/spec/fixtures/custom_plugins/kong/plugins/admin-api-method/schema.lua b/spec/fixtures/custom_plugins/kong/plugins/admin-api-method/schema.lua index f070b3add55..67f4be179ad 100644 --- a/spec/fixtures/custom_plugins/kong/plugins/admin-api-method/schema.lua +++ b/spec/fixtures/custom_plugins/kong/plugins/admin-api-method/schema.lua @@ -1,5 +1,13 @@ return { + name = "admin-api-method", fields = { - foo = { type = "string" } - } + { + config = { + type = "record", + fields = { + { foo = { type = "string" } }, + }, + }, + }, + }, } diff --git a/spec/fixtures/custom_plugins/kong/plugins/cache/schema.lua b/spec/fixtures/custom_plugins/kong/plugins/cache/schema.lua index 14894bc17d9..2c6b6d9d13f 100644 --- a/spec/fixtures/custom_plugins/kong/plugins/cache/schema.lua +++ b/spec/fixtures/custom_plugins/kong/plugins/cache/schema.lua @@ -1,10 +1,12 @@ return { name = "cache", fields = { - { config = { + { + config = { type = "record", - fields = { }, - } - } - } + fields = { + }, + }, + }, + }, } diff --git a/spec/fixtures/custom_plugins/kong/plugins/ctx-checker-last/schema.lua b/spec/fixtures/custom_plugins/kong/plugins/ctx-checker-last/schema.lua index 778cc0dc773..bffc2c215ce 100644 --- a/spec/fixtures/custom_plugins/kong/plugins/ctx-checker-last/schema.lua +++ b/spec/fixtures/custom_plugins/kong/plugins/ctx-checker-last/schema.lua @@ -1,2 +1,20 @@ --- same as regular ctx-checker -return require "spec.fixtures.custom_plugins.kong.plugins.ctx-checker.schema" +return { + name = "ctx-checker-last", + fields = { + { + config = { + type = "record", + fields = { + { ctx_set_field = { type = "string" } }, + { ctx_set_value = { type = "string", default = "set_by_ctx_checker" } }, + { ctx_set_array = { type = "array", elements = { type = "string" } } }, + { ctx_check_field = { type = "string" } }, + { ctx_check_value = { type = "string" } }, + { ctx_check_array = { type = "array", elements = { type = "string" } } }, + { ctx_kind = { type = "string", default = "ngx.ctx" } }, + { ctx_throw_error = { type = "boolean", default = false } }, + }, + }, + }, + }, +} diff --git a/spec/fixtures/custom_plugins/kong/plugins/ctx-checker/schema.lua b/spec/fixtures/custom_plugins/kong/plugins/ctx-checker/schema.lua index 7bde6aeb0a5..6fbb3687a49 100644 --- a/spec/fixtures/custom_plugins/kong/plugins/ctx-checker/schema.lua +++ b/spec/fixtures/custom_plugins/kong/plugins/ctx-checker/schema.lua @@ -1,12 +1,20 @@ return { + name = "ctx-checker", fields = { - ctx_set_field = { type = "string" }, - ctx_set_value = { type = "string", default = "set_by_ctx_checker" }, - ctx_set_array = { type = "array" }, - ctx_check_field = { type = "string" }, - ctx_check_value = { type = "string" }, - ctx_check_array = { type = "array" }, - ctx_kind = { type = "string", default = "ngx.ctx" }, - ctx_throw_error = { type = "boolean", default = false }, - } + { + config = { + type = "record", + fields = { + { ctx_set_field = { type = "string" } }, + { ctx_set_value = { type = "string", default = "set_by_ctx_checker" } }, + { ctx_set_array = { type = "array", elements = { type = "string" } } }, + { ctx_check_field = { type = "string" } }, + { ctx_check_value = { type = "string" } }, + { ctx_check_array = { type = "array", elements = { type = "string" } } }, + { ctx_kind = { type = "string", default = "ngx.ctx" } }, + { ctx_throw_error = { type = "boolean", default = false } }, + }, + }, + }, + }, } diff --git a/spec/fixtures/custom_plugins/kong/plugins/ctx-tests-response/schema.lua b/spec/fixtures/custom_plugins/kong/plugins/ctx-tests-response/schema.lua index c3df808117a..50462494aff 100644 --- a/spec/fixtures/custom_plugins/kong/plugins/ctx-tests-response/schema.lua +++ b/spec/fixtures/custom_plugins/kong/plugins/ctx-tests-response/schema.lua @@ -1,10 +1,11 @@ local typedefs = require "kong.db.schema.typedefs" + -- TODO: At the moment this tests the happy case. Perhaps it could be extended to work -- even with unhappy cases, e.g. together with error-generator plugin. Or the plugin -- could be made to error by itself. return { - name = "ctx-tests", + name = "ctx-tests-response", fields = { { protocols = typedefs.protocols { default = { "http", "https", "tcp", "tls", "grpc", "grpcs" } }, @@ -18,7 +19,7 @@ return { type = "boolean", default = false, }, - } + }, }, }, }, diff --git a/spec/fixtures/custom_plugins/kong/plugins/ctx-tests/schema.lua b/spec/fixtures/custom_plugins/kong/plugins/ctx-tests/schema.lua index c3df808117a..344818ff48e 100644 --- a/spec/fixtures/custom_plugins/kong/plugins/ctx-tests/schema.lua +++ b/spec/fixtures/custom_plugins/kong/plugins/ctx-tests/schema.lua @@ -1,5 +1,6 @@ local typedefs = require "kong.db.schema.typedefs" + -- TODO: At the moment this tests the happy case. Perhaps it could be extended to work -- even with unhappy cases, e.g. together with error-generator plugin. Or the plugin -- could be made to error by itself. @@ -18,7 +19,7 @@ return { type = "boolean", default = false, }, - } + }, }, }, }, diff --git a/spec/fixtures/custom_plugins/kong/plugins/dummy/schema.lua b/spec/fixtures/custom_plugins/kong/plugins/dummy/schema.lua index 8ae095ffa46..5c6f5124341 100644 --- a/spec/fixtures/custom_plugins/kong/plugins/dummy/schema.lua +++ b/spec/fixtures/custom_plugins/kong/plugins/dummy/schema.lua @@ -1,12 +1,15 @@ return { name = "dummy", fields = { - { config = { + { + config = { type = "record", fields = { - { resp_header_value = { type = "string", default = "1" }, }, - { append_body = { type = "string" }, }, - { resp_code = { type = "number" }, }, - }, }, }, + { resp_header_value = { type = "string", default = "1" } }, + { append_body = { type = "string" } }, + { resp_code = { type = "number" } }, + }, + }, + }, }, } diff --git a/spec/fixtures/custom_plugins/kong/plugins/enable-buffering-response/schema.lua b/spec/fixtures/custom_plugins/kong/plugins/enable-buffering-response/schema.lua index ad34532190e..9bef0c546e9 100644 --- a/spec/fixtures/custom_plugins/kong/plugins/enable-buffering-response/schema.lua +++ b/spec/fixtures/custom_plugins/kong/plugins/enable-buffering-response/schema.lua @@ -1,5 +1,5 @@ return { - name = "enable-buffering", + name = "enable-buffering-response", fields = { { config = { diff --git a/spec/fixtures/custom_plugins/kong/plugins/error-generator-last/schema.lua b/spec/fixtures/custom_plugins/kong/plugins/error-generator-last/schema.lua index 3fb5eb3162f..ab65e58de36 100644 --- a/spec/fixtures/custom_plugins/kong/plugins/error-generator-last/schema.lua +++ b/spec/fixtures/custom_plugins/kong/plugins/error-generator-last/schema.lua @@ -4,15 +4,15 @@ return { { config = { type = "record", fields = { - { certificate = { type = "boolean", required = false, default = false }, }, - { rewrite = { type = "boolean", required = false, default = false }, }, - { preread = { type = "boolean", required = false, default = false }, }, - { access = { type = "boolean", required = false, default = false }, }, - { header_filter = { type = "boolean", required = false, default = false }, }, - { body_filter = { type = "boolean", required = false, default = false }, }, - { log = { type = "boolean", required = false, default = false }, }, + { certificate = { type = "boolean", required = false, default = false } }, + { rewrite = { type = "boolean", required = false, default = false } }, + { preread = { type = "boolean", required = false, default = false } }, + { access = { type = "boolean", required = false, default = false } }, + { header_filter = { type = "boolean", required = false, default = false } }, + { body_filter = { type = "boolean", required = false, default = false } }, + { log = { type = "boolean", required = false, default = false } }, }, - } - } - } + }, + }, + }, } diff --git a/spec/fixtures/custom_plugins/kong/plugins/error-generator/schema.lua b/spec/fixtures/custom_plugins/kong/plugins/error-generator/schema.lua index 51379d2d60e..6bb6765d182 100644 --- a/spec/fixtures/custom_plugins/kong/plugins/error-generator/schema.lua +++ b/spec/fixtures/custom_plugins/kong/plugins/error-generator/schema.lua @@ -9,15 +9,15 @@ return { { config = { type = "record", fields = { - { certificate = { type = "boolean", required = false, default = false }, }, - { rewrite = { type = "boolean", required = false, default = false }, }, - { preread = { type = "boolean", required = false, default = false }, }, - { access = { type = "boolean", required = false, default = false }, }, - { header_filter = { type = "boolean", required = false, default = false }, }, - { body_filter = { type = "boolean", required = false, default = false }, }, - { log = { type = "boolean", required = false, default = false }, }, + { certificate = { type = "boolean", required = false, default = false } }, + { rewrite = { type = "boolean", required = false, default = false } }, + { preread = { type = "boolean", required = false, default = false } }, + { access = { type = "boolean", required = false, default = false } }, + { header_filter = { type = "boolean", required = false, default = false } }, + { body_filter = { type = "boolean", required = false, default = false } }, + { log = { type = "boolean", required = false, default = false } }, }, - } - } - } + }, + }, + }, } diff --git a/spec/fixtures/custom_plugins/kong/plugins/error-handler-log/schema.lua b/spec/fixtures/custom_plugins/kong/plugins/error-handler-log/schema.lua index 349237f09f7..51de6b61045 100644 --- a/spec/fixtures/custom_plugins/kong/plugins/error-handler-log/schema.lua +++ b/spec/fixtures/custom_plugins/kong/plugins/error-handler-log/schema.lua @@ -1,10 +1,12 @@ return { name = "error-handler-log", fields = { - { config = { + { + config = { type = "record", - fields = { }, - } - } - } + fields = { + }, + }, + }, + }, } diff --git a/spec/fixtures/custom_plugins/kong/plugins/fail-once-auth/schema.lua b/spec/fixtures/custom_plugins/kong/plugins/fail-once-auth/schema.lua index f08868b83df..291592ecccd 100644 --- a/spec/fixtures/custom_plugins/kong/plugins/fail-once-auth/schema.lua +++ b/spec/fixtures/custom_plugins/kong/plugins/fail-once-auth/schema.lua @@ -1,11 +1,13 @@ return { name = "fail-once-auth", fields = { - { config = { + { + config = { type = "record", fields = { - { message = { type = "string", default = "try again!" }, }, + { message = { type = "string", default = "try again!" } }, }, - }, }, - } + }, + }, + }, } diff --git a/spec/fixtures/custom_plugins/kong/plugins/foreign-entity/daos.lua b/spec/fixtures/custom_plugins/kong/plugins/foreign-entity/daos.lua index 53262fe4ecf..a5285ef9fd7 100644 --- a/spec/fixtures/custom_plugins/kong/plugins/foreign-entity/daos.lua +++ b/spec/fixtures/custom_plugins/kong/plugins/foreign-entity/daos.lua @@ -2,7 +2,7 @@ local typedefs = require "kong.db.schema.typedefs" return { - foreign_entities = { + { name = "foreign_entities", primary_key = { "id" }, endpoint_key = "name", @@ -13,7 +13,7 @@ return { { same = typedefs.uuid }, }, }, - foreign_references = { + { name = "foreign_references", primary_key = { "id" }, endpoint_key = "name", diff --git a/spec/fixtures/custom_plugins/kong/plugins/init-worker-lua-error/schema.lua b/spec/fixtures/custom_plugins/kong/plugins/init-worker-lua-error/schema.lua index e34d22fbbe6..fa796cc74ac 100644 --- a/spec/fixtures/custom_plugins/kong/plugins/init-worker-lua-error/schema.lua +++ b/spec/fixtures/custom_plugins/kong/plugins/init-worker-lua-error/schema.lua @@ -1,10 +1,12 @@ return { name = "init-worker-lua-error", fields = { - { config = { + { + config = { type = "record", - fields = { }, - } - } - } + fields = { + }, + }, + }, + }, } diff --git a/spec/fixtures/custom_plugins/kong/plugins/invalid-schema/schema.lua b/spec/fixtures/custom_plugins/kong/plugins/invalid-schema/schema.lua index 831cd0b2cb0..639480c2a77 100644 --- a/spec/fixtures/custom_plugins/kong/plugins/invalid-schema/schema.lua +++ b/spec/fixtures/custom_plugins/kong/plugins/invalid-schema/schema.lua @@ -1,10 +1,13 @@ return { - name = "dummy", + name = "invalid-schema", fields = { - { config = { + { + config = { type = "record", fields = { - { foo = { type = "bar" }, }, - }, }, }, + { foo = { type = "bar" } }, + }, + }, + }, }, } diff --git a/spec/fixtures/custom_plugins/kong/plugins/legacy-plugin-bad/handler.lua b/spec/fixtures/custom_plugins/kong/plugins/legacy-plugin-bad/handler.lua deleted file mode 100644 index 05ede734ce1..00000000000 --- a/spec/fixtures/custom_plugins/kong/plugins/legacy-plugin-bad/handler.lua +++ /dev/null @@ -1,2 +0,0 @@ -return function() end - diff --git a/spec/fixtures/custom_plugins/kong/plugins/legacy-plugin-bad/schema.lua b/spec/fixtures/custom_plugins/kong/plugins/legacy-plugin-bad/schema.lua deleted file mode 100644 index a5eaf59e50c..00000000000 --- a/spec/fixtures/custom_plugins/kong/plugins/legacy-plugin-bad/schema.lua +++ /dev/null @@ -1,21 +0,0 @@ --- regression test from #4392 - -return { - no_consumer = true, - fields = { - foo = { - -- an underspecified table with no 'schema' will default - -- to a map of string to string - type = "table", - required = false, - -- this default will not match that default - default = { - foo = 123, - bar = "bla", - } - } - }, - self_check = function() - return true - end -} diff --git a/spec/fixtures/custom_plugins/kong/plugins/legacy-plugin-good/handler.lua b/spec/fixtures/custom_plugins/kong/plugins/legacy-plugin-good/handler.lua deleted file mode 100644 index ba6e40663fe..00000000000 --- a/spec/fixtures/custom_plugins/kong/plugins/legacy-plugin-good/handler.lua +++ /dev/null @@ -1,7 +0,0 @@ -local LegacyPluginGoodHandler = { - VERSION = "0.1-t", - PRIORITY = 1000, -} - - -return LegacyPluginGoodHandler diff --git a/spec/fixtures/custom_plugins/kong/plugins/legacy-plugin-good/schema.lua b/spec/fixtures/custom_plugins/kong/plugins/legacy-plugin-good/schema.lua deleted file mode 100644 index 941f960d8e7..00000000000 --- a/spec/fixtures/custom_plugins/kong/plugins/legacy-plugin-good/schema.lua +++ /dev/null @@ -1,19 +0,0 @@ -return { - no_consumer = true, - fields = { - foo = { - -- an underspecified table with no 'schema' will default - -- to a map of string to string - type = "table", - required = false, - -- this default will match that - default = { - foo = "boo", - bar = "bla", - } - } - }, - self_check = function() - return true - end -} diff --git a/spec/fixtures/custom_plugins/kong/plugins/logger-last/schema.lua b/spec/fixtures/custom_plugins/kong/plugins/logger-last/schema.lua index 7a075343555..7c778697fd1 100644 --- a/spec/fixtures/custom_plugins/kong/plugins/logger-last/schema.lua +++ b/spec/fixtures/custom_plugins/kong/plugins/logger-last/schema.lua @@ -1 +1,18 @@ -return require "spec.fixtures.custom_plugins.kong.plugins.logger.schema" +local typedefs = require "kong.db.schema.typedefs" + + +return { + name = "logger-last", + fields = { + { + protocols = typedefs.protocols { default = { "http", "https", "tcp", "tls", "grpc", "grpcs" } }, + }, + { + config = { + type = "record", + fields = { + }, + }, + }, + }, +} diff --git a/spec/fixtures/custom_plugins/kong/plugins/logger/schema.lua b/spec/fixtures/custom_plugins/kong/plugins/logger/schema.lua index 3a4104a555c..8acb87e39fe 100644 --- a/spec/fixtures/custom_plugins/kong/plugins/logger/schema.lua +++ b/spec/fixtures/custom_plugins/kong/plugins/logger/schema.lua @@ -1,7 +1,8 @@ local typedefs = require "kong.db.schema.typedefs" + return { - name = "ctx-tests", + name = "logger", fields = { { protocols = typedefs.protocols { default = { "http", "https", "tcp", "tls", "grpc", "grpcs" } }, diff --git a/spec/fixtures/custom_plugins/kong/plugins/plugin-with-custom-dao/daos.lua b/spec/fixtures/custom_plugins/kong/plugins/plugin-with-custom-dao/daos.lua index 9887e90f64c..011f703b5a6 100644 --- a/spec/fixtures/custom_plugins/kong/plugins/plugin-with-custom-dao/daos.lua +++ b/spec/fixtures/custom_plugins/kong/plugins/plugin-with-custom-dao/daos.lua @@ -1,7 +1,8 @@ local typedefs = require "kong.db.schema.typedefs" + return { - custom_dao = { + { dao = "kong.plugins.plugin-with-custom-dao.custom_dao", name = "custom_dao", primary_key = { "id" }, diff --git a/spec/fixtures/custom_plugins/kong/plugins/plugin-with-custom-dao/schema.lua b/spec/fixtures/custom_plugins/kong/plugins/plugin-with-custom-dao/schema.lua index 02af697f680..02da5f3f46a 100644 --- a/spec/fixtures/custom_plugins/kong/plugins/plugin-with-custom-dao/schema.lua +++ b/spec/fixtures/custom_plugins/kong/plugins/plugin-with-custom-dao/schema.lua @@ -1,9 +1,12 @@ return { name = "plugin-with-custom-dao", fields = { - { config = { + { + config = { type = "record", - fields = {} - } } - } + fields = { + }, + }, + }, + }, } diff --git a/spec/fixtures/custom_plugins/kong/plugins/reports-api/schema.lua b/spec/fixtures/custom_plugins/kong/plugins/reports-api/schema.lua index 5145be2ca34..cd45c13530e 100644 --- a/spec/fixtures/custom_plugins/kong/plugins/reports-api/schema.lua +++ b/spec/fixtures/custom_plugins/kong/plugins/reports-api/schema.lua @@ -5,8 +5,8 @@ return { config = { type = "record", fields = { - } - } - } - } + }, + }, + }, + }, } diff --git a/spec/fixtures/custom_plugins/kong/plugins/rewriter/schema.lua b/spec/fixtures/custom_plugins/kong/plugins/rewriter/schema.lua index c59bc0a4b2b..3d2b540de2e 100644 --- a/spec/fixtures/custom_plugins/kong/plugins/rewriter/schema.lua +++ b/spec/fixtures/custom_plugins/kong/plugins/rewriter/schema.lua @@ -1,12 +1,14 @@ return { name = "rewriter", fields = { - { config = { + { + config = { type = "record", fields = { - { value = { type = "string" }, }, - { extra = { type = "string", default = "extra" }, }, + { value = { type = "string" } }, + { extra = { type = "string", default = "extra" } }, }, - }, }, - } + }, + }, + }, } diff --git a/spec/fixtures/custom_plugins/kong/plugins/short-circuit/schema.lua b/spec/fixtures/custom_plugins/kong/plugins/short-circuit/schema.lua index 9ddf4c8026a..3318d288f08 100644 --- a/spec/fixtures/custom_plugins/kong/plugins/short-circuit/schema.lua +++ b/spec/fixtures/custom_plugins/kong/plugins/short-circuit/schema.lua @@ -5,14 +5,14 @@ return { name = "short-circuit", fields = { { - protocols = typedefs.protocols { default = {"http", "https", "tcp", "tls"} } + protocols = typedefs.protocols { default = { "http", "https", "tcp", "tls" } }, }, { config = { type = "record", fields = { - { status = { type = "integer", default = 503 }, }, - { message = { type = "string", default = "short-circuited" }, }, + { status = { type = "integer", default = 503 } }, + { message = { type = "string", default = "short-circuited" } }, }, }, }, diff --git a/spec/fixtures/custom_plugins/kong/plugins/slow-query/schema.lua b/spec/fixtures/custom_plugins/kong/plugins/slow-query/schema.lua index 7c0b9045294..b83c832018d 100644 --- a/spec/fixtures/custom_plugins/kong/plugins/slow-query/schema.lua +++ b/spec/fixtures/custom_plugins/kong/plugins/slow-query/schema.lua @@ -1,5 +1,12 @@ return { + name = "slow-query", fields = { - something = { type = "string" } - } + { + config = { + type = "record", + fields = { + }, + }, + }, + }, } diff --git a/spec/fixtures/custom_plugins/kong/plugins/stream-api-echo/schema.lua b/spec/fixtures/custom_plugins/kong/plugins/stream-api-echo/schema.lua index 1b4f1109784..e2d31432442 100644 --- a/spec/fixtures/custom_plugins/kong/plugins/stream-api-echo/schema.lua +++ b/spec/fixtures/custom_plugins/kong/plugins/stream-api-echo/schema.lua @@ -1,4 +1,12 @@ - return { - fields = {} + name = "stream-api-echo", + fields = { + { + config = { + type = "record", + fields = { + }, + }, + }, + }, } diff --git a/spec/fixtures/custom_plugins/kong/plugins/unique-foreign/schema.lua b/spec/fixtures/custom_plugins/kong/plugins/unique-foreign/schema.lua index 4702242d678..1a943ac3cc6 100644 --- a/spec/fixtures/custom_plugins/kong/plugins/unique-foreign/schema.lua +++ b/spec/fixtures/custom_plugins/kong/plugins/unique-foreign/schema.lua @@ -5,8 +5,8 @@ return { config = { type = "record", fields = { - } - } - } - } + }, + }, + }, + }, } diff --git a/spec/fixtures/custom_plugins/kong/plugins/with-migrations/daos.lua b/spec/fixtures/custom_plugins/kong/plugins/with-migrations/daos.lua index 55ffc4d24fb..4925446375e 100644 --- a/spec/fixtures/custom_plugins/kong/plugins/with-migrations/daos.lua +++ b/spec/fixtures/custom_plugins/kong/plugins/with-migrations/daos.lua @@ -1,10 +1,10 @@ return { - foos = { + { name = "foos", primary_key = { "color" }, fields = { - { color = "string" }, - { shape = "string" }, + { color = { type = "string" } }, + { shape = { type = "string" } }, }, }, } diff --git a/spec/fixtures/custom_plugins/kong/plugins/with-migrations/schema.lua b/spec/fixtures/custom_plugins/kong/plugins/with-migrations/schema.lua index 7c0b9045294..498f6dd7ecf 100644 --- a/spec/fixtures/custom_plugins/kong/plugins/with-migrations/schema.lua +++ b/spec/fixtures/custom_plugins/kong/plugins/with-migrations/schema.lua @@ -1,5 +1,12 @@ return { + name = "with-migrations", fields = { - something = { type = "string" } - } + { + config = { + type = "record", + fields = { + }, + }, + }, + }, } diff --git a/spec/fixtures/custom_plugins/kong/plugins/worker-events/schema.lua b/spec/fixtures/custom_plugins/kong/plugins/worker-events/schema.lua index 969a8caa1df..a0ace2de0e6 100644 --- a/spec/fixtures/custom_plugins/kong/plugins/worker-events/schema.lua +++ b/spec/fixtures/custom_plugins/kong/plugins/worker-events/schema.lua @@ -1,5 +1,6 @@ local typedefs = require "kong.db.schema.typedefs" + return { name = "worker-events", fields = {