Skip to content

Commit

Permalink
tests(wasm): escape the prefix in case it contains special characters (
Browse files Browse the repository at this point in the history
  • Loading branch information
catbro666 authored Jul 28, 2023
1 parent fe77af4 commit 6a03fae
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions spec/01-unit/04-prefix_handler_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,14 @@ ffi.cdef([[
]])


-- the pattern expands to: "([%%%^%$%(%)%.%[%]%*%+%-%?])"
local escape_pattern = '(['..("%^$().[]*+-?"):gsub("(.)", "%%%1")..'])'
-- escape all the special characters %^$().[]*+-? in the string
-- e.g. "%^$().[]*+-?" ---> "%%%^%$%(%)%.%[%]%*%+%-%?"
local function escape_special_chars(str)
return str:gsub(escape_pattern, "%%%1")
end

local function kong_user_group_exists()
if C.getpwnam("kong") == nil or C.getgrnam("kong") == nil then
return false
Expand Down Expand Up @@ -901,6 +909,7 @@ describe("NGINX conf compiler", function()
end)
describe("lua_ssl_trusted_certificate", function()
local cwd = currentdir()
cwd = escape_special_chars(cwd) -- escape the possible special characters in the prefix
it("with one cert", function()
assert.matches(
string.format("wasm {.+tls_trusted_certificate %s/spec/fixtures/kong_clustering_ca.crt;.+}", cwd),
Expand Down

1 comment on commit 6a03fae

@khcp-gha-bot
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bazel Build

Docker image available kong/kong:6a03fae381c084187084c1c314bac189404a5919
Artifacts available https://github.com/Kong/kong/actions/runs/5694602586

Please sign in to comment.