1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
|
test_description='Check the shipped email avatar extensions'
CGIT_TEST_NO_CREATE_REPOS=YesPlease
. ./setup.sh
. "$TEST_OUTPUT_DIRECTORY/extensions/lib.sh"
for lua in ${interpreters:-lua}
do
lua_module_prereq "$lua" openssl.digest
for script in email-gravatar email-libravatar
do
test_expect_success STANDALONE_LUA "$script checks under $(lua_version "$lua")" '
"$lua" "$EXT_TEST_DIRECTORY/test-email-avatar.lua" "$EXTENSIONS_DIRECTORY/$script.lua" stub
'
test_expect_success STANDALONE_LUA "$script checks without luaossl under $(lua_version "$lua")" '
"$lua" "$EXT_TEST_DIRECTORY/test-email-avatar.lua" "$EXTENSIONS_DIRECTORY/$script.lua" missing
'
test_expect_success "STANDALONE_LUA,$lua_prereq" "$script checks with real luaossl under $(lua_version "$lua")" '
"$lua" "$EXT_TEST_DIRECTORY/test-email-avatar.lua" "$EXTENSIONS_DIRECTORY/$script.lua" real
'
done
done
test_expect_success 'create a repository with one commit' '
test_create_repo repos/avatar &&
(
cd repos/avatar &&
echo content >file &&
git add file &&
git commit -m "add file"
)
'
if cgit_lua_probe "$PWD/repos/avatar/.git" openssl.digest
then
test_set_prereq CGIT_LUA_OSSL
fi
test_expect_success 'point cgit at it through the email filter' '
cat >cgitrc <<-EOF
virtual-root=/
cache-size=0
repo.url=avatar
repo.path=$PWD/repos/avatar/.git
repo.email-filter=lua:$EXTENSIONS_DIRECTORY/email-gravatar.lua
repo.url=libravatar
repo.path=$PWD/repos/avatar/.git
repo.email-filter=lua:$EXTENSIONS_DIRECTORY/email-libravatar.lua
EOF
'
test_expect_success CGIT_LUA_OSSL 'the commit page draws the author icon' '
cgit_ok_url "avatar/commit/" >tmp &&
test_grep "gravatar.com/avatar/b0eda69977c26118feff17875d53376006568bcbcde5ca0c916d01f05c281436" tmp &&
test_grep "loading=.lazy." tmp &&
test_grep "referrerpolicy=.no-referrer." tmp
'
test_expect_success CGIT_LUA_OSSL 'the libravatar filter draws it from its own service' '
cgit_ok_url "libravatar/commit/" >tmp &&
test_grep "seccdn.libravatar.org/avatar/b0eda69977c26118feff17875d53376006568bcbcde5ca0c916d01f05c281436" tmp &&
test_grep "referrerpolicy=.no-referrer." tmp
'
test_expect_success CGIT_LUA 'without luaossl the page keeps the name alone' '
echo "[cgit] Unable to load openssl.digest, so no avatar icons are drawn" >expect &&
without_lua_modules cgit_url "avatar/commit/" >tmp 2>err &&
test_cmp expect err &&
test_grep "^Status: 200" tmp &&
test_grep "</html>" tmp &&
test_grep "A U Thor" tmp &&
test_grep ! "<img src=.https:" tmp
'
test_done
|