Diff options
Diffstat (limited to 'tests/extensions/test-auth.lua')
| -rw-r--r-- | tests/extensions/test-auth.lua | 14 |
1 file changed, 9 insertions, 5 deletions
diff --git a/tests/extensions/test-auth.lua b/tests/extensions/test-auth.lua index 17cb805..bd1f01c 100644 --- a/tests/extensions/test-auth.lua +++ b/tests/extensions/test-auth.lua @@ -247,12 +247,16 @@ h.equals("spaces around a pair are ignored", get_cookie(" foo=1 ; cgitauth=abc h.equals("a cookie value keeps its own equals signs", get_cookie("cgitauth=a=b", "cgitauth"), "a=b") -- The Cookie header is the visitor's to write, so a run of spaces in it --- must not cost the square of its length. +-- must not cost the square of its length. At this length a linear trim +-- takes about a millisecond and the square about fifteen seconds. +local spaces = string.rep(" ", 100000) local started = os.clock() -get_cookie("a=" .. string.rep(" ", 20000) .. "b", "cgitauth") -h.equals("a long run of spaces is read quickly", - get_cookie(string.rep(" ", 20000) .. "cgitauth=abc", "cgitauth"), "abc") -h.check("and in linear time", os.clock() - started < 0.5) +get_cookie("a=" .. spaces .. "b", "cgitauth") +h.check("a long run of spaces inside a cookie is read within half a second", os.clock() - started < 0.5) +started = os.clock() +local found = get_cookie(spaces .. "cgitauth=abc", "cgitauth") +h.check("and one ahead of it as well", os.clock() - started < 0.5) +h.equals("without losing the cookie behind it", found, "abc") h.check("equal strings compare equal", constant_equals("abc", "abc")) h.check("differing strings do not", not constant_equals("abc", "abd")) |
