Upload Modules
This commit is contained in:
22
ngx_fancyindex/t/00-build-artifacts.test
Normal file
22
ngx_fancyindex/t/00-build-artifacts.test
Normal file
@@ -0,0 +1,22 @@
|
||||
#! /bin/bash
|
||||
cat <<---
|
||||
This test checks that the built Nginx either has the dynamic fancyindex
|
||||
module available, or that it's not there (for static builds).
|
||||
--
|
||||
|
||||
readonly nginx_path="${PREFIX}/sbin/nginx"
|
||||
readonly so_path="${PREFIX}/modules/ngx_http_fancyindex_module.so"
|
||||
|
||||
if [[ ! -x ${nginx_path} ]] ; then
|
||||
fail "executable binary not found at '%s'\n" "${nginx_path}"
|
||||
fi
|
||||
|
||||
if ${DYNAMIC} ; then
|
||||
if [[ ! -r ${so_path} ]] ; then
|
||||
fail "module not found at '%s'\n" "${so_path}"
|
||||
fi
|
||||
else
|
||||
if [[ -r ${so_path} ]] ; then
|
||||
fail "module should not exist at '%s'\n" "${so_path}"
|
||||
fi
|
||||
fi
|
||||
7
ngx_fancyindex/t/01-smoke-hasindex.test
Normal file
7
ngx_fancyindex/t/01-smoke-hasindex.test
Normal file
@@ -0,0 +1,7 @@
|
||||
#! /bin/bash
|
||||
cat <<---
|
||||
This test fetches the root directory served by Nginx, which has no index file,
|
||||
and checks that the output contains something that resembles a directory index.
|
||||
--
|
||||
nginx_start
|
||||
grep 'Index of' <( fetch )
|
||||
11
ngx_fancyindex/t/02-smoke-indexisfancy.test
Normal file
11
ngx_fancyindex/t/02-smoke-indexisfancy.test
Normal file
@@ -0,0 +1,11 @@
|
||||
#! /bin/bash
|
||||
cat <<---
|
||||
This test fetches the root directory served by Nginx, which has no index file,
|
||||
and checks that the output contains something that resembles the output from
|
||||
the fancyindex module.
|
||||
--
|
||||
nginx_start
|
||||
content=$(fetch --with-headers)
|
||||
grep 'Index of /' <<< "${content}" # It is an index
|
||||
grep '<table\>' <<< "${content}" # It contains a table
|
||||
grep '^ Content-Type:[[:space:]]*text/html' <<< "${content}"
|
||||
9
ngx_fancyindex/t/03-exact_size_off.test
Normal file
9
ngx_fancyindex/t/03-exact_size_off.test
Normal file
@@ -0,0 +1,9 @@
|
||||
#! /bin/bash
|
||||
cat <<---
|
||||
This test checks if the output from using "fancyindex_exact_size off"
|
||||
looks sane.
|
||||
--
|
||||
nginx_start 'fancyindex_exact_size off;'
|
||||
content=$(fetch)
|
||||
grep -e '[1-9]\.[0-9] KiB' <<< "${content}"
|
||||
grep -E '[0-9]+ B' <<< "${content}"
|
||||
24
ngx_fancyindex/t/04-hasindex-html.test
Normal file
24
ngx_fancyindex/t/04-hasindex-html.test
Normal file
@@ -0,0 +1,24 @@
|
||||
#! /bin/bash
|
||||
cat <<---
|
||||
This test fetches the root directory served by Nginx, which has no index
|
||||
file, and checks that the output contains a few HTML elements known to
|
||||
exist in a directory index.
|
||||
--
|
||||
use pup
|
||||
nginx_start
|
||||
|
||||
content=$( fetch )
|
||||
|
||||
# Check page title
|
||||
[[ $(pup -p title text{} <<< "${content}") = 'Index of /' ]]
|
||||
|
||||
# Check table headers
|
||||
[[ $(pup -n body table thead th a:first-child <<< "${content}") -eq 3 ]]
|
||||
{
|
||||
read -r name_label
|
||||
read -r size_label
|
||||
read -r date_label
|
||||
} < <( pup -p body table thead th a:first-child text{} <<< "${content}" )
|
||||
[[ ${name_label} = File\ Name ]]
|
||||
[[ ${size_label} = File\ Size ]]
|
||||
[[ ${date_label} = Date ]]
|
||||
36
ngx_fancyindex/t/05-sort-by-size.test
Normal file
36
ngx_fancyindex/t/05-sort-by-size.test
Normal file
@@ -0,0 +1,36 @@
|
||||
#! /bin/bash
|
||||
cat <<---
|
||||
This test validates that the sorting by file size works.
|
||||
--
|
||||
use pup
|
||||
nginx_start
|
||||
|
||||
# Ascending sort.
|
||||
previous=''
|
||||
while read -r size ; do
|
||||
if [[ ${size} = - ]] ; then
|
||||
continue
|
||||
fi
|
||||
if [[ -z ${previous} ]] ; then
|
||||
previous=${size}
|
||||
continue
|
||||
fi
|
||||
[[ ${previous} -le ${size} ]] || fail \
|
||||
'Size %d should be smaller than %d\n' "${previous}" "${size}"
|
||||
done < <( fetch '/?C=S&O=A' \
|
||||
| pup -p body table tbody 'td:nth-child(2)' text{} )
|
||||
|
||||
# Descending sort.
|
||||
previous=''
|
||||
while read -r size ; do
|
||||
if [[ ${size} = - ]] ; then
|
||||
continue
|
||||
fi
|
||||
if [[ -z ${previous} ]] ; then
|
||||
previous=${size}
|
||||
continue
|
||||
fi
|
||||
[[ ${previous} -ge ${size} ]] || fail \
|
||||
'Size %d should be greater than %d\n' "${previous}" "${size}"
|
||||
done < <( fetch '/?C=S&O=D' \
|
||||
| pup -p body table tbody 'td:nth-child(2)' text{} )
|
||||
23
ngx_fancyindex/t/06-hide_parent.test
Normal file
23
ngx_fancyindex/t/06-hide_parent.test
Normal file
@@ -0,0 +1,23 @@
|
||||
#! /bin/bash
|
||||
cat <<---
|
||||
This test checks the output using "fancyindex_hide_parent_dir on".
|
||||
--
|
||||
use pup
|
||||
nginx_start 'fancyindex_hide_parent_dir on;'
|
||||
|
||||
content=$( fetch /child-directory/ )
|
||||
|
||||
# Check page title
|
||||
[[ $(pup -p title text{} <<< "${content}") = "Index of /child-directory/" ]]
|
||||
|
||||
# Check table headers
|
||||
[[ $(pup -n body table tbody tr:first-child td <<< "${content}") -eq 3 ]]
|
||||
{
|
||||
read -r name_label
|
||||
read -r size_label
|
||||
read -r date_label
|
||||
} < <( pup -p body table tbody tr:first-child td text{} <<< "${content}" )
|
||||
[[ ${name_label} != Parent\ Directory/ ]]
|
||||
[[ ${name_label} = empty-file.txt ]]
|
||||
[[ ${size_label} != - ]]
|
||||
[[ ${date_label} != - ]]
|
||||
50
ngx_fancyindex/t/07-directory-first.test
Normal file
50
ngx_fancyindex/t/07-directory-first.test
Normal file
@@ -0,0 +1,50 @@
|
||||
#! /bin/bash
|
||||
cat <<---
|
||||
This test checks the output using "fancyindex_directories_first on".
|
||||
--
|
||||
use pup
|
||||
|
||||
for d in "008d" "000d" "004d" ; do
|
||||
mkdir -p "${TESTDIR}/dir_first/${d}"
|
||||
done
|
||||
for f in "005f" "001f" "003f"; do
|
||||
touch "${TESTDIR}/dir_first/${f}"
|
||||
done
|
||||
for d in "006d" "002d" ; do
|
||||
mkdir -p "${TESTDIR}/dir_first/${d}"
|
||||
done
|
||||
|
||||
nginx_start 'fancyindex_directories_first on;'
|
||||
previous=''
|
||||
cur_type=''
|
||||
while read -r name ; do
|
||||
case "$name" in
|
||||
*Parent*)
|
||||
;;
|
||||
*d*)
|
||||
echo "dir $name"
|
||||
[[ "$cur_type" = f ]] && fail 'Directories should come before files'
|
||||
cur_type=d
|
||||
if [[ -z ${previous} ]] ; then
|
||||
previous=${name}
|
||||
else
|
||||
[[ ${previous} < ${name} ]] || fail \
|
||||
'Name %s should come before %s\n' "${previous}" "${name}"
|
||||
fi
|
||||
;;
|
||||
*f*)
|
||||
echo "file $name"
|
||||
[[ -z "$cur_type" ]] && fail 'Directories should come before files'
|
||||
if [[ "$cur_type" = d ]] ; then
|
||||
cur_type=f
|
||||
previous=${name}
|
||||
else
|
||||
[[ ${previous} < ${name} ]] || fail \
|
||||
'Name %s should come before %s\n' "${previous}" "${name}"
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
done < <( fetch '/dir_first/' \
|
||||
| pup -p body table tbody 'td:nth-child(1)' text{} )
|
||||
|
||||
nginx_is_running || fail "Nginx died"
|
||||
21
ngx_fancyindex/t/07-show_dotfiles.test
Normal file
21
ngx_fancyindex/t/07-show_dotfiles.test
Normal file
@@ -0,0 +1,21 @@
|
||||
#! /bin/bash
|
||||
cat <<---
|
||||
This test checks the option to show dotfiles.
|
||||
--
|
||||
# Turn it on.
|
||||
nginx_start 'fancyindex_show_dotfiles on;'
|
||||
on_content=$(fetch /show_dotfiles/)
|
||||
nginx_stop
|
||||
if [ $(grep '.okay' <<< "${on_content}") -ne 0 ] ; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Turn it off.
|
||||
nginx_start
|
||||
off_content=$(fetch /show_dotfiles/)
|
||||
nginx_stop
|
||||
if [ $(grep '.okay' <<< "${on_content}") -eq 0] ; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
exit 0
|
||||
17
ngx_fancyindex/t/08-local-footer.test
Normal file
17
ngx_fancyindex/t/08-local-footer.test
Normal file
@@ -0,0 +1,17 @@
|
||||
#! /bin/bash
|
||||
cat <<---
|
||||
This test checks that a local footer can be included with
|
||||
"fancyindex_header ... local".
|
||||
--
|
||||
use pup
|
||||
|
||||
cat > "${TESTDIR}/footer" <<EOF
|
||||
<div id="customfooter">yes</div>
|
||||
EOF
|
||||
|
||||
nginx_start "fancyindex_footer \"${TESTDIR}/footer\" local;"
|
||||
|
||||
T=$(fetch / | pup -p body 'div#customfooter' text{})
|
||||
[[ $T == yes ]] || fail 'Custom header missing'
|
||||
|
||||
nginx_is_running || fail 'Nginx died'
|
||||
17
ngx_fancyindex/t/09-local-header.test
Normal file
17
ngx_fancyindex/t/09-local-header.test
Normal file
@@ -0,0 +1,17 @@
|
||||
#! /bin/bash
|
||||
cat <<---
|
||||
This test checks that a local header can be included with
|
||||
"fancyindex_header ... local".
|
||||
--
|
||||
use pup
|
||||
|
||||
cat > "${TESTDIR}/header" <<EOF
|
||||
<div id="customheader">yes</div>
|
||||
EOF
|
||||
|
||||
nginx_start "fancyindex_header \"${TESTDIR}/header\" local;"
|
||||
|
||||
T=$(fetch / | pup -p body 'div#customheader' text{})
|
||||
[[ $T == yes ]] || fail 'Custom header missing'
|
||||
|
||||
nginx_is_running || fail 'Nginx died'
|
||||
26
ngx_fancyindex/t/10-local-headerfooter.test
Normal file
26
ngx_fancyindex/t/10-local-headerfooter.test
Normal file
@@ -0,0 +1,26 @@
|
||||
#! /bin/bash
|
||||
cat <<---
|
||||
This test checks that both a local header and footer can be included with
|
||||
"fancyindex_{header,footer} ... local".
|
||||
--
|
||||
use pup
|
||||
|
||||
cat > "${TESTDIR}/header" <<EOF
|
||||
<div id="customheader">yes</div>
|
||||
EOF
|
||||
cat > "${TESTDIR}/footer" <<EOF
|
||||
<div id="customfooter">yes</div>
|
||||
EOF
|
||||
|
||||
nginx_start "fancyindex_header \"${TESTDIR}/header\" local;
|
||||
fancyindex_footer \"${TESTDIR}/footer\" local;"
|
||||
|
||||
P=$(fetch /)
|
||||
|
||||
H=$(pup -p body 'div#customheader' text{} <<< "$P")
|
||||
[[ $H == yes ]] || fail 'Custom header missing'
|
||||
|
||||
F=$(pup -p body 'div#customfooter' text{} <<< "$P")
|
||||
[[ $F == yes ]] || fail 'Custom footer missing'
|
||||
|
||||
nginx_is_running || fail 'Nginx died'
|
||||
31
ngx_fancyindex/t/11-local-footer-nested.test
Normal file
31
ngx_fancyindex/t/11-local-footer-nested.test
Normal file
@@ -0,0 +1,31 @@
|
||||
#! /bin/bash
|
||||
cat <<---
|
||||
This test checks that local footers are correctly included in the presence of
|
||||
directives in nested locations:
|
||||
|
||||
fancyindex_footer <one> local;
|
||||
location /sub {
|
||||
fancyindex_footer <another> local;
|
||||
}
|
||||
|
||||
--
|
||||
use pup
|
||||
|
||||
echo '<div id="topfooter">yes</div>' > "${TESTDIR}/top-footer"
|
||||
echo '<div id="subfooter">yes</div>' > "${TESTDIR}/sub-footer"
|
||||
|
||||
nginx_start "fancyindex_footer \"${TESTDIR}/top-footer\" local;
|
||||
location /child-directory {
|
||||
fancyindex_footer \"${TESTDIR}/sub-footer\" local;
|
||||
}"
|
||||
|
||||
T=$(fetch /)
|
||||
echo "$T" > "$TESTDIR/top.html"
|
||||
[[ $(pup -p body 'div#topfooter' text{} <<< "$T") = yes ]] || fail 'Custom header missing at /'
|
||||
[[ -z $(pup -p body 'div#subfooter' text{} <<< "$T") ]] || fail 'Wrong header at /'
|
||||
|
||||
T=$(fetch /child-directory/)
|
||||
[[ $(pup -p body 'div#subfooter' text{} <<< "$T") = yes ]] || fail 'Custom header missing at /sub/'
|
||||
[[ -z $(pup -p body 'div#topfooter' text{} <<< "$T") ]] || fail 'Wrong header at /sub/'
|
||||
|
||||
nginx_is_running || fail 'Nginx died'
|
||||
11
ngx_fancyindex/t/12-local-footer-nested.test
Normal file
11
ngx_fancyindex/t/12-local-footer-nested.test
Normal file
@@ -0,0 +1,11 @@
|
||||
#! /bin/bash
|
||||
cat <<---
|
||||
This test checks that the configuration file is properly parsed if there
|
||||
is only one parameter passed to the fancyindex_header and fancyindex_footer
|
||||
configuration directives.
|
||||
--
|
||||
|
||||
nginx_start 'fancyindex_header "/header";
|
||||
fancyindex_footer "/footer";'
|
||||
|
||||
nginx_is_running || fail 'Nginx died'
|
||||
9
ngx_fancyindex/t/bug107-filesystem-root-404.test
Normal file
9
ngx_fancyindex/t/bug107-filesystem-root-404.test
Normal file
@@ -0,0 +1,9 @@
|
||||
#! /bin/bash
|
||||
cat <<---
|
||||
Bug #107: 404 is returned when indexing filesystem root
|
||||
https://github.com/aperezdc/ngx-fancyindex/issues/107
|
||||
--
|
||||
nginx_start 'root /;'
|
||||
content=$(fetch)
|
||||
grep 'Index of /' <<< "${content}" # It is an index
|
||||
grep '<table\>' <<< "${content}" # It contains a table
|
||||
27
ngx_fancyindex/t/bug157-saturday-in-long-weekdays.test
Normal file
27
ngx_fancyindex/t/bug157-saturday-in-long-weekdays.test
Normal file
@@ -0,0 +1,27 @@
|
||||
#! /bin/bash
|
||||
cat <<---
|
||||
Check whether the Saturday long day name is available.
|
||||
https://github.com/aperezdc/ngx-fancyindex/issues/157
|
||||
--
|
||||
use pup
|
||||
nginx_start 'fancyindex_time_format "%A"; fancyindex_default_sort date;'
|
||||
|
||||
mkdir -p "${TESTDIR}/weekdays"
|
||||
for (( i=2 ; i <= 8 ; i++ )) ; do
|
||||
TZ=UTC touch -d "2023-01-0${i}T06:00:00" "${TESTDIR}/weekdays/day$i.txt"
|
||||
done
|
||||
ls "${TESTDIR}/weekdays"
|
||||
content=$(fetch /weekdays/)
|
||||
|
||||
# We need row+1 because the first one is the table header.
|
||||
dayname=$(pup -p body table tbody \
|
||||
'tr:nth-child(7)' 'td:nth-child(3)' 'text{}' \
|
||||
<<< "$content")
|
||||
[[ $dayname = Saturday ]] || fail 'Sixth day is not Saturday'
|
||||
|
||||
dayname=$(pup -p body table tbody \
|
||||
'tr:nth-child(8)' 'td:nth-child(3)' 'text{}' \
|
||||
<<< "$content")
|
||||
[[ $dayname = Sunday ]] || fail 'Seventh day is not Sunday'
|
||||
|
||||
nginx_is_running || fail 'Nginx died'
|
||||
16
ngx_fancyindex/t/bug61-empty-file-segfault.test
Normal file
16
ngx_fancyindex/t/bug61-empty-file-segfault.test
Normal file
@@ -0,0 +1,16 @@
|
||||
#! /bin/bash
|
||||
cat <<---
|
||||
Bug #61: Listing a directory with an empty file crashes Nginx
|
||||
https://github.com/aperezdc/ngx-fancyindex/issues/61
|
||||
--
|
||||
|
||||
# Prepare an empty directory with an empty file
|
||||
mkdir -p "${TESTDIR}/bug61"
|
||||
touch "${TESTDIR}/bug61/bug61.txt"
|
||||
|
||||
nginx_start 'fancyindex_exact_size off;'
|
||||
content=$(fetch /bug61/)
|
||||
test -n "${content}" || fail "Empty response"
|
||||
echo "Response:"
|
||||
echo "${content}"
|
||||
nginx_is_running || fail "Nginx died"
|
||||
8
ngx_fancyindex/t/bug78-case-insensitive.test
Normal file
8
ngx_fancyindex/t/bug78-case-insensitive.test
Normal file
@@ -0,0 +1,8 @@
|
||||
#! /bin/bash
|
||||
cat <<---
|
||||
This test checks that case-insensitive sorting works.
|
||||
--
|
||||
|
||||
nginx_start 'fancyindex_case_sensitive off;'
|
||||
content=$(fetch /case-sensitivity/)
|
||||
grep -A 999 '\<alice\>' <<< "${content}" | grep '\<Bob\>' # Bob is after alice
|
||||
8
ngx_fancyindex/t/bug78-case-sensitive.test
Normal file
8
ngx_fancyindex/t/bug78-case-sensitive.test
Normal file
@@ -0,0 +1,8 @@
|
||||
#! /bin/bash
|
||||
cat <<---
|
||||
This test checks that case-sensitive sorting works.
|
||||
--
|
||||
|
||||
nginx_start 'fancyindex_case_sensitive on;'
|
||||
content=$(fetch /case-sensitivity/)
|
||||
grep -A 999 '\<Bob\>' <<< "${content}" | grep '\<alice\>' # alice is after Bob
|
||||
19
ngx_fancyindex/t/bug95-square-brackets.test
Normal file
19
ngx_fancyindex/t/bug95-square-brackets.test
Normal file
@@ -0,0 +1,19 @@
|
||||
#! /bin/bash
|
||||
cat <<---
|
||||
Bug #95: FancyIndex does not encode square brackets
|
||||
https://github.com/aperezdc/ngx-fancyindex/issues/95
|
||||
--
|
||||
use pup
|
||||
|
||||
# Prepare a directory with a file that contains square brackets in the name.
|
||||
mkdir -p "${TESTDIR}/bug95"
|
||||
touch "${TESTDIR}"/bug95/'bug[95].txt'
|
||||
|
||||
nginx_start
|
||||
content=$(fetch /bug95/)
|
||||
test -n "${content}" || fail 'Empty response'
|
||||
|
||||
expected_href='bug%5B95%5D.txt'
|
||||
obtained_href=$(pup -p body tbody 'tr:nth-child(2)' a 'attr{href}' <<< "${content}")
|
||||
test "${expected_href}" = "${obtained_href}" || \
|
||||
fail 'Expected: %s - Obtained: %s' "${expected_href}" "${obtained_href}"
|
||||
36
ngx_fancyindex/t/build-and-run
Normal file
36
ngx_fancyindex/t/build-and-run
Normal file
@@ -0,0 +1,36 @@
|
||||
#! /bin/bash
|
||||
set -e
|
||||
|
||||
if [[ $# -lt 1 || $# -gt 2 ]] ; then
|
||||
echo "Usage: $0 <nginx-version> [1]" 1>&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
readonly NGINX=$1
|
||||
|
||||
if [[ $2 -eq 1 ]] ; then
|
||||
readonly DYNAMIC=$2
|
||||
fi
|
||||
|
||||
case $(uname -s) in
|
||||
Darwin)
|
||||
JOBS=$(sysctl -n hw.activecpu)
|
||||
;;
|
||||
*)
|
||||
JOBS=1
|
||||
;;
|
||||
esac
|
||||
|
||||
cd "$(dirname "$0")/.."
|
||||
wget -O - http://nginx.org/download/nginx-${NGINX}.tar.gz | tar -xzf -
|
||||
rm -rf prefix/
|
||||
cd nginx-${NGINX}
|
||||
./configure \
|
||||
--add-${DYNAMIC:+dynamic-}module=.. \
|
||||
--with-http_addition_module \
|
||||
--without-http_rewrite_module \
|
||||
--prefix="$(pwd)/../prefix"
|
||||
make -j"$JOBS"
|
||||
make install
|
||||
cd ..
|
||||
exec ./t/run prefix ${DYNAMIC}
|
||||
0
ngx_fancyindex/t/case-sensitivity/Bob
Normal file
0
ngx_fancyindex/t/case-sensitivity/Bob
Normal file
0
ngx_fancyindex/t/case-sensitivity/alice
Normal file
0
ngx_fancyindex/t/case-sensitivity/alice
Normal file
0
ngx_fancyindex/t/child-directory/empty-file.txt
Normal file
0
ngx_fancyindex/t/child-directory/empty-file.txt
Normal file
105
ngx_fancyindex/t/get-pup
Normal file
105
ngx_fancyindex/t/get-pup
Normal file
@@ -0,0 +1,105 @@
|
||||
#! /bin/bash
|
||||
set -e
|
||||
|
||||
declare -r SHASUMS='\
|
||||
ec9522193516ad49c78d40a8163f1d92e98866892a11aadb7be584a975026a8a pup_69c02e189c2aaed331061ee436c39e72b830ef32_darwin_amd64.xz
|
||||
75c27caa0008a9cc639beb7506077ad9f32facbffcc4e815e999eaf9588a527e pup_v0.4.0_darwin_386.zip
|
||||
c539a697efee2f8e56614a54cb3b215338e00de1f6a7c2fa93144ab6e1db8ebe pup_v0.4.0_darwin_amd64.zip
|
||||
259eee82c7d7d766f1b8f93a382be21dcfefebc855a9ce8124fd78717f9df439 pup_v0.4.0_dragonfly_amd64.zip
|
||||
ba0fe5e87a24cab818e5d2efdd7540714ddfb1b7246600135915c666fdf1a601 pup_v0.4.0_freebsd_386.zip
|
||||
1838ef84ec1f961e8009d19a4d1e6a23b926ee315da3d60c08878f3d69af5692 pup_v0.4.0_freebsd_amd64.zip
|
||||
6886a9c60a912a810d012610bc3f784f0417999ff7d7df833a0695b9af60395b pup_v0.4.0_freebsd_arm.zip
|
||||
e486b32ca07552cd3aa713cbf2f9d1b6e210ddb51d34b3090c7643f465828057 pup_v0.4.0_linux_386.zip
|
||||
ec3d29e9fb375b87ac492c8b546ad6be84b0c0b49dab7ff4c6b582eac71ba01c pup_v0.4.0_linux_amd64.zip
|
||||
c09b669fa8240f4f869dee7d34ee3c7ea620a0280cee1ea7d559593bcdd062c9 pup_v0.4.0_linux_arm64.zip
|
||||
ebf70b3c76c02e0202c94af7ef06dcb3ecc866d1b9b84453d43fe01fa5dd5870 pup_v0.4.0_linux_arm.zip
|
||||
a98a4d1f3c3a103e8ebe1a7aba9cb9d3cb045003208ca6f5f3d54889a225f267 pup_v0.4.0_linux_mips64le.zip
|
||||
8e471cf6cfa118b2497bb3f42a7a48c52d0096107f748f37216855c8ab94f8e5 pup_v0.4.0_linux_mips64.zip
|
||||
cfda9375eba65f710e052b1b59893c228c3fc92b0510756bb3f02c25938eee30 pup_v0.4.0_linux_ppc64le.zip
|
||||
91a1e07ffb2c373d6053252e4de732f5db78c8eace49c6e1a0ef52402ecdf56c pup_v0.4.0_linux_ppc64.zip
|
||||
fdc9b28a3daac5ad096023e1647292a7eccea6d9b1686f871307dae9f3bd064f pup_v0.4.0_nacl_386.zip
|
||||
c8d3c9b56783bd5a55446f4580e1835606b2b945da2d1417ed509c5927a5f8bc pup_v0.4.0_nacl_amd64p32.zip
|
||||
48c068c4353672528c8c3447a536208b0719f1e6d0f8fab8416b38b63ad0c1d9 pup_v0.4.0_nacl_arm.zip
|
||||
7a27497b2f0be95c51bb2cbc25da12efba682c4f766bc5abc5742e9fc8d1eeb0 pup_v0.4.0_netbsd_386.zip
|
||||
71a1808eb1b6442aa45d1de9e1c4fca543b2754c1aff5ba3d62b3456f9519691 pup_v0.4.0_netbsd_amd64.zip
|
||||
928e6691b11c68ae3f28826848a13dc5c1c9673848fe7cf7f80dd76c9fb6e8a6 pup_v0.4.0_netbsd_arm.zip
|
||||
5aca20a9b3264d2fde5a8d32f213c434edf9570ee6fae18953b8fff09d2976e2 pup_v0.4.0_openbsd_386.zip
|
||||
e965c6f04b897240d84c60e2c18226deb231a657c5583680f58a61051ff5a100 pup_v0.4.0_openbsd_amd64.zip
|
||||
30bc88a1e06606f4f3449af9fbf586f97c2e958677460a72bb1a168f67c4911c pup_v0.4.0_openbsd_arm.zip
|
||||
9d50decf4572292f187cfec84660648d648336bc6109e1f032b1699ba1d28549 pup_v0.4.0_plan9_386.zip
|
||||
1b2a6bd2388ddd691ca429497d88b2b047ec8dfb7bce9436925cb2f30632bf8e pup_v0.4.0_plan9_amd64.zip
|
||||
0835de9c10a9e2b3b958b82d148da49eaafc695fe4a018cbaf7bb861b455583f pup_v0.4.0_solaris_amd64.zip
|
||||
01acae220b69fb1ba8477d0e7f4d7669ef5de147966dc819cf75a845af74c5f3 pup_v0.4.0_windows_386.zip
|
||||
6755cbd43e94eaf173689e93e914c7056a2249c2977e5b90024fb397f9b45ba4 pup_v0.4.0_windows_amd64.zip
|
||||
'
|
||||
|
||||
declare -r TDIR=$(dirname "$0")
|
||||
|
||||
case $(uname -m) in
|
||||
x86_64 | amd64 ) ARCH=amd64 ;;
|
||||
i[3456]86 ) ARCH=386 ;;
|
||||
* ) ARCH= ;;
|
||||
esac
|
||||
|
||||
OS=$(uname -s | tr 'A-Z' 'a-z')
|
||||
case ${OS} in
|
||||
linux | freebsd | openbsd | netbsd | darwin ) ;;
|
||||
* ) OS= ;;
|
||||
esac
|
||||
|
||||
# The binary of pup 0.4.0 for macOS provided by the original project
|
||||
# crashes immediately on macOS 10.13 (Darwin 17) and up so use a fork:
|
||||
# https://github.com/ericchiang/pup/issues/85
|
||||
if [[ ${OS} = darwin && $(uname -r | cut -d. -f1) -ge 17 ]] ; then
|
||||
USE_FORK=1
|
||||
else
|
||||
USE_FORK=0
|
||||
fi
|
||||
|
||||
if (( USE_FORK )) ; then
|
||||
declare -r VERSION=69c02e189c2aaed331061ee436c39e72b830ef32
|
||||
declare -r DISTFILE="pup_${VERSION}_${OS}_${ARCH}.xz"
|
||||
declare -r URL="https://github.com/frioux/pup/releases/download/untagged-${VERSION}/pup.mac.xz"
|
||||
if ! command -v xz >/dev/null ; then
|
||||
echo "xz not found" 1>&2
|
||||
exit 3
|
||||
fi
|
||||
else
|
||||
declare -r VERSION=0.4.0
|
||||
declare -r DISTFILE="pup_v${VERSION}_${OS}_${ARCH}.zip"
|
||||
declare -r URL="https://github.com/ericchiang/pup/releases/download/v${VERSION}/${DISTFILE}"
|
||||
fi
|
||||
|
||||
if [[ -z ${ARCH} || -z ${OS} ]] ; then
|
||||
echo "pup ${VERSION} is not available for $(uname -s) on $(uname -m)" 1>&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
EXPECT_SHA=
|
||||
while read sum fname ; do
|
||||
if [[ ${fname} = ${DISTFILE} ]] ; then
|
||||
EXPECT_SHA=${sum}
|
||||
break
|
||||
fi
|
||||
done <<< "${SHASUMS}"
|
||||
|
||||
wget -cO "${TDIR}/${DISTFILE}" "${URL}"
|
||||
|
||||
read -r _ GOT_SHA < <( openssl sha256 < "${TDIR}/${DISTFILE}" )
|
||||
if [[ ${EXPECT_SHA} = ${GOT_SHA} ]] ; then
|
||||
echo "Checksum for ${DISTFILE} verified :-)"
|
||||
else
|
||||
rm -f "${TDIR}/${DISTFILE}" "${TDIR}/pup"
|
||||
echo "Checksum for ${DISTFILE} does not match :-("
|
||||
echo " Expected: ${EXPECT_SHA}"
|
||||
echo " Got: ${GOT_SHA}"
|
||||
exit 2
|
||||
fi 1>&2
|
||||
|
||||
rm -f "${TDIR}/pup"
|
||||
|
||||
if (( USE_FORK )) ; then
|
||||
(cd "${TDIR}" && xz -dk "${DISTFILE}" && mv "${DISTFILE%.*}" pup && chmod a+x pup)
|
||||
else
|
||||
unzip "${TDIR}/${DISTFILE}" pup -d "${TDIR}"
|
||||
fi
|
||||
7
ngx_fancyindex/t/has-index.test
Normal file
7
ngx_fancyindex/t/has-index.test
Normal file
@@ -0,0 +1,7 @@
|
||||
#! /bin/bash
|
||||
cat <<---
|
||||
This test ensures that the "index.html" is returned instead of a directory
|
||||
listing when fetching a directory which contains an index file.
|
||||
--
|
||||
nginx_start
|
||||
diff -u "${TESTDIR}/has-index/index.html" <( fetch /has-index/ ) 1>&2
|
||||
10
ngx_fancyindex/t/has-index/index.html
Normal file
10
ngx_fancyindex/t/has-index/index.html
Normal file
@@ -0,0 +1,10 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<title>Index file test</title>
|
||||
</head>
|
||||
<body>
|
||||
This is <code>index.html</code>.
|
||||
</body>
|
||||
</html>
|
||||
25
ngx_fancyindex/t/nginx.conf
Normal file
25
ngx_fancyindex/t/nginx.conf
Normal file
@@ -0,0 +1,25 @@
|
||||
worker_processes 1;
|
||||
|
||||
|
||||
events {
|
||||
worker_connections 1024;
|
||||
}
|
||||
|
||||
http {
|
||||
include mime.types;
|
||||
default_type application/octet-stream;
|
||||
sendfile on;
|
||||
keepalive_timeout 65;
|
||||
server {
|
||||
listen 80;
|
||||
server_name localhost;
|
||||
location / {
|
||||
root html;
|
||||
index index.html index.htm;
|
||||
}
|
||||
error_page 500 502 503 504 /50x.html;
|
||||
location = /50x.html {
|
||||
root html;
|
||||
}
|
||||
}
|
||||
}
|
||||
124
ngx_fancyindex/t/preamble
Normal file
124
ngx_fancyindex/t/preamble
Normal file
@@ -0,0 +1,124 @@
|
||||
#! /bin/bash
|
||||
#
|
||||
# preamble
|
||||
# Copyright (C) 2016 Adrian Perez <aperez@igalia.com>
|
||||
#
|
||||
# SPDX-License-Identifier: BSD-2-Clause
|
||||
#
|
||||
|
||||
function nginx_conf_generate () {
|
||||
if ${DYNAMIC} ; then
|
||||
echo 'load_module modules/ngx_http_fancyindex_module.so;'
|
||||
fi
|
||||
cat <<-EOF
|
||||
worker_processes 1;
|
||||
events { worker_connections 1024; }
|
||||
http {
|
||||
include mime.types;
|
||||
default_type application/octet-stream;
|
||||
sendfile on;
|
||||
keepalive_timeout 65;
|
||||
server {
|
||||
server_name localhost;
|
||||
listen 127.0.0.1:${NGINX_PORT};
|
||||
root ${TESTDIR};
|
||||
error_page 500 502 503 504 /50x.html;
|
||||
location = /50x.html { root html; }
|
||||
location / {
|
||||
index index.html;
|
||||
fancyindex on;
|
||||
$*
|
||||
}
|
||||
}
|
||||
}
|
||||
EOF
|
||||
}
|
||||
|
||||
readonly NGINX_CONF="${PREFIX}/conf/nginx.conf"
|
||||
readonly NGINX_PID="${PREFIX}/logs/nginx.pid"
|
||||
|
||||
case $(uname -s) in
|
||||
Darwin)
|
||||
NGINX_PORT=$(netstat -a -n -finet -ptcp | awk '/LISTEN/ { sub(".+\\.", "", $4) ; seen[$4]=1 }
|
||||
END { p=1025 ; while (seen[p]) p++; print p}')
|
||||
;;
|
||||
*)
|
||||
NGINX_PORT=$(ss -4Htnl | awk '{ sub("[^:]+:", "", $4) ; seen[$4]=1 }
|
||||
END { p=1025 ; while (seen[p]) p++; print p}')
|
||||
;;
|
||||
esac
|
||||
readonly NGINX_PORT
|
||||
|
||||
rm -f "${NGINX_CONF}" "${NGINX_PID}"
|
||||
mkdir -p "${PREFIX}/logs"
|
||||
|
||||
function pup () {
|
||||
if [[ -x ${TESTDIR}/pup ]] ; then
|
||||
"${TESTDIR}/pup" "$@"
|
||||
else
|
||||
skip 'Test uses "pup", which is not available'
|
||||
fi
|
||||
}
|
||||
|
||||
function use () {
|
||||
case $1 in
|
||||
pup ) [[ -x ${TESTDIR}/pup ]] \
|
||||
|| skip 'Test uses "pup", which is unavailable\n' ;;
|
||||
* ) warn "Invalid 'use' flag: '%s'\n'" "$1" ;;
|
||||
esac
|
||||
}
|
||||
|
||||
function nginx () {
|
||||
env - PATH="${PATH}" "${PREFIX}/sbin/nginx" "$@"
|
||||
}
|
||||
|
||||
function nginx_conf () {
|
||||
nginx_conf_generate "$@" > "${NGINX_CONF}"
|
||||
}
|
||||
|
||||
function nginx_is_running () {
|
||||
[[ -r ${NGINX_PID} ]] && kill -0 $(< "${NGINX_PID}")
|
||||
}
|
||||
|
||||
function nginx_stop () {
|
||||
if nginx_is_running ; then nginx -s stop ; fi
|
||||
rm -f "${NGINX_PID}"
|
||||
}
|
||||
trap nginx_stop EXIT
|
||||
|
||||
function nginx_start () {
|
||||
if [[ $# -gt 0 || ! -r ${NGINX_CONF} ]] ; then nginx_conf "$@" ; fi
|
||||
nginx_stop # Ensure that it is not running.
|
||||
nginx
|
||||
local n=0
|
||||
while [[ ! -r ${NGINX_PID} && n -lt 20 ]] ; do
|
||||
sleep 0.1 # Wait until pid exists.
|
||||
n=$((n+1))
|
||||
done
|
||||
}
|
||||
|
||||
function fetch () {
|
||||
local -a opts=( -q )
|
||||
if [[ $1 = --with-headers ]] ; then
|
||||
opts+=( -S )
|
||||
shift
|
||||
fi
|
||||
wget "${opts[@]}" -O- "http://localhost:${NGINX_PORT}${1:-/}" 2>&1
|
||||
}
|
||||
|
||||
function skip () {
|
||||
printf '(--) '
|
||||
printf "$@"
|
||||
exit 111
|
||||
} 1>&2
|
||||
|
||||
function fail () {
|
||||
printf '(FF) '
|
||||
printf "$@"
|
||||
exit 1
|
||||
} 1>&2
|
||||
|
||||
function warn () {
|
||||
printf '(WW) '
|
||||
printf "$@"
|
||||
} 1>&2
|
||||
86
ngx_fancyindex/t/run
Normal file
86
ngx_fancyindex/t/run
Normal file
@@ -0,0 +1,86 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
if [[ $# -lt 1 || $# -gt 2 ]] ; then
|
||||
echo "Usage: $0 <prefix-path> [1]" 1>&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Obtain the absolute path to the tests directory
|
||||
pushd "$(dirname "$0")" &> /dev/null
|
||||
readonly T=$(pwd)
|
||||
popd &> /dev/null
|
||||
export T
|
||||
|
||||
# Same for the nginx prefix directory
|
||||
pushd "$1" &> /dev/null
|
||||
readonly prefix=$(pwd)
|
||||
popd &> /dev/null
|
||||
|
||||
dynamic=false
|
||||
if [[ $# -gt 1 && $2 -eq 1 ]] ; then
|
||||
dynamic=true
|
||||
fi
|
||||
readonly dynamic
|
||||
|
||||
declare -a t_pass=( )
|
||||
declare -a t_fail=( )
|
||||
declare -a t_skip=( )
|
||||
|
||||
for t in `ls "$T"/*.test | sort -R` ; do
|
||||
name="t/${t##*/}"
|
||||
name=${name%.test}
|
||||
printf "${name} ... "
|
||||
errfile="${name}.err"
|
||||
outfile="${name}.out"
|
||||
shfile="${name}.sh"
|
||||
cat > "${shfile}" <<-EOF
|
||||
readonly DYNAMIC=${dynamic}
|
||||
readonly TESTDIR='$T'
|
||||
readonly PREFIX='${prefix}'
|
||||
$(< "$T/preamble")
|
||||
$(< "$t")
|
||||
EOF
|
||||
if bash -e "${shfile}" > "${outfile}" 2> "${errfile}" ; then
|
||||
t_pass+=( "${name}" )
|
||||
printf '[1;32mpassed[0;0m\n'
|
||||
elif [[ $? -eq 111 ]] ; then
|
||||
t_skip+=( "${name}" )
|
||||
printf '[1;33mskipped[0;0m\n'
|
||||
else
|
||||
t_fail+=( "${name}" )
|
||||
printf '[1;31mfailed[0;0m\n'
|
||||
fi
|
||||
done
|
||||
|
||||
for name in "${t_fail[@]}" ; do
|
||||
echo
|
||||
printf '[1m===[0m %s.out\n' "${name}"
|
||||
cat "${name}.out"
|
||||
echo
|
||||
printf '[1m===[0m %s.err\n' "${name}"
|
||||
cat "${name}.err"
|
||||
echo
|
||||
done
|
||||
|
||||
if [[ ${#t_skip[@]} -gt 0 ]] ; then
|
||||
echo
|
||||
printf '[1;33mSkipped tests:\n[0;0m'
|
||||
for name in "${t_skip[@]}" ; do
|
||||
reason=$(grep '^(\-\-) ' "${name}.err" | head -1)
|
||||
if [[ -z ${reason} ]] ; then
|
||||
reason='No reason given'
|
||||
else
|
||||
reason=${reason:5}
|
||||
fi
|
||||
printf ' - %s: %s\n' "${name}" "${reason:-No reason given}"
|
||||
done
|
||||
echo
|
||||
fi
|
||||
|
||||
printf '[1m===[0m passed/skipped/failed/total: [1;32m%d[0;0m/[1;33m%d[0;0m/[1;31m%d[0;0m/[1m%d[0m\n' \
|
||||
${#t_pass[@]} ${#t_skip[@]} ${#t_fail[@]} $(( ${#t_pass[@]} + ${#t_fail[@]} ))
|
||||
|
||||
if [[ ${#t_fail[@]} -gt 0 ]] ; then
|
||||
exit 1
|
||||
fi
|
||||
0
ngx_fancyindex/t/show_dotfiles/.okay
Normal file
0
ngx_fancyindex/t/show_dotfiles/.okay
Normal file
Reference in New Issue
Block a user