diff options
Diffstat (limited to 'tests')
-rw-r--r--tests/extensions/test-email-avatar.lua13
-rwxr-xr-xtests/t0504-email-avatar.sh29
2 files changed, 33 insertions, 9 deletions
diff --git a/tests/extensions/test-email-avatar.lua b/tests/extensions/test-email-avatar.lua
index 4960ec3..bedcfe8 100644
--- a/tests/extensions/test-email-avatar.lua
+++ b/tests/extensions/test-email-avatar.lua
@@ -3,8 +3,8 @@
-- two scripts differ only in the service they point at, so the expected host
-- is picked from the script's name. The second argument chooses how the
-- openssl.digest dependency is met, stub swaps in the deterministic fake
--- from the harness, and real uses an installed luaossl and adds the one
--- check only a genuine MD5 can pass.
+-- from the harness, real uses an installed luaossl and adds the one check
+-- only a genuine MD5 can pass, and missing makes the module fail to load.
local test_directory = arg[0]:match("^(.*)/") or "."
local h = dofile(test_directory .. "/harness.lua")
@@ -21,6 +21,8 @@ end
if mode == "stub" then
h.stub_digest()
+elseif mode == "missing" then
+ h.preload_failure("openssl.digest")
end
h.load(script)
@@ -29,6 +31,13 @@ local function render(email, name)
return h.run({ email, "commit" }, { name })
end
+if mode == "missing" then
+ local out, ret = render("<author@example.com>", "A U Thor")
+ h.equals("without luaossl the name stands alone", out, "A U Thor")
+ h.equals("and close still answers zero", ret, 0)
+ h.finish()
+end
+
local function hash_of(output)
local prefix = base_url:gsub("([%^%$%(%)%%%.%[%]%*%+%-%?])", "%%%1")
return output:match("src='" .. prefix .. "(%x+)%?")
diff --git a/tests/t0504-email-avatar.sh b/tests/t0504-email-avatar.sh
index 91ddc20..0150c54 100755
--- a/tests/t0504-email-avatar.sh
+++ b/tests/t0504-email-avatar.sh
@@ -3,11 +3,11 @@
# Checks email-gravatar.lua and email-libravatar.lua, the shipped email
# filters, which differ only in the service the icon is fetched from. The
# unit checks run each under every suitable standalone Lua with a
-# deterministic digest standing in for luaossl, and once more against the
-# real module wherever it is installed, which adds the check that a known
-# address hashes to its published md5. The run through cgit itself needs
-# luaossl inside the binary's own Lua, so it is probed for rather than
-# assumed.
+# deterministic digest standing in for luaossl, with the module made to
+# fail to load, and once more against the real module wherever it is
+# installed, which adds the check that a known address hashes to its
+# published md5. Through cgit itself the answer depends on whether the
+# binary's own Lua has luaossl, so it is probed for rather than assumed.
test_description='Check the shipped email avatar extensions'
CGIT_TEST_NO_CREATE_REPOS=YesPlease
@@ -25,6 +25,9 @@ do
test_expect_success "$script checks under $lua" "
'$lua' '$EXT_TEST_DIRECTORY/test-email-avatar.lua' '$EXTENSIONS_DIRECTORY/$script.lua' stub
"
+ test_expect_success "$script checks without luaossl under $lua" "
+ '$lua' '$EXT_TEST_DIRECTORY/test-email-avatar.lua' '$EXTENSIONS_DIRECTORY/$script.lua' missing
+ "
if "$lua" -e "require([[openssl.digest]])" >/dev/null 2>&1
then
@@ -49,11 +52,16 @@ if test "$CGIT_HAS_LUA" -eq 1 &&
cgit_lua_probe "$PWD/repos/avatar/.git" openssl.digest
then
test_set_prereq CGIT_LUA_OSSL
+elif test "$CGIT_HAS_LUA" -eq 1
+then
+ test_set_prereq CGIT_LUA_NOOSSL
+ say 'cgit lua has no luaossl, expecting names without icons'
else
- say 'cgit lua has no luaossl, filter checks through cgit skipped'
+ say 'cgit built without lua, filter checks through cgit skipped'
fi
+test "$CGIT_HAS_LUA" -eq 1 && test_set_prereq CGIT_LUA
-test_expect_success CGIT_LUA_OSSL 'point cgit at it through the email filter' '
+test_expect_success CGIT_LUA 'point cgit at it through the email filter' '
cat >cgitrc <<-EOF
virtual-root=/
cache-size=0
@@ -71,4 +79,11 @@ test_expect_success CGIT_LUA_OSSL 'the commit page draws the author icon' '
grep "loading=.lazy." tmp
'
+test_expect_success CGIT_LUA_NOOSSL 'without luaossl the page keeps the name alone' '
+ cgit_url "avatar/commit/" >tmp &&
+ grep "A U Thor" tmp &&
+ ! grep "<img src=.https:" tmp &&
+ ! grep "Unable to complete the request" tmp
+'
+
test_done