mirror of
https://github.com/emikulic/darkhttpd.git
synced 2023-08-10 21:13:08 +03:00
Add test for --no-listing.
This commit is contained in:
parent
fc8e127bb7
commit
e9aeaba7fe
@ -1838,6 +1838,10 @@ static void process_get(struct connection *conn) {
|
|||||||
free(target);
|
free(target);
|
||||||
if (no_listing) {
|
if (no_listing) {
|
||||||
free(decoded_url);
|
free(decoded_url);
|
||||||
|
/* Return 404 instead of 403 to make --no-listing
|
||||||
|
* indistinguishable from the directory not existing.
|
||||||
|
* i.e.: Don't leak information.
|
||||||
|
*/
|
||||||
default_reply(conn, 404, "Not Found",
|
default_reply(conn, 404, "Not Found",
|
||||||
"The URL you requested (%s) was not found.", conn->url);
|
"The URL you requested (%s) was not found.", conn->url);
|
||||||
return;
|
return;
|
||||||
|
@ -84,6 +84,14 @@ python test_mimemap.py
|
|||||||
kill $PID
|
kill $PID
|
||||||
wait $PID
|
wait $PID
|
||||||
|
|
||||||
|
echo "===> run --no-listing tests"
|
||||||
|
./a.out $DIR --port $PORT --no-listing >/dev/null &
|
||||||
|
PID=$!
|
||||||
|
kill -0 $PID || exit 1
|
||||||
|
python test_no_listing.py
|
||||||
|
kill $PID
|
||||||
|
wait $PID
|
||||||
|
|
||||||
echo "===> generating darkhttpd.c.gcov report"
|
echo "===> generating darkhttpd.c.gcov report"
|
||||||
gcov darkhttpd
|
gcov darkhttpd
|
||||||
rm -rf $DIR
|
rm -rf $DIR
|
||||||
|
15
devel/test_no_listing.py
Executable file
15
devel/test_no_listing.py
Executable file
@ -0,0 +1,15 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
# This is run by the "cover" script.
|
||||||
|
import unittest
|
||||||
|
from test import TestHelper, Conn, parse
|
||||||
|
|
||||||
|
class TestNoListing(TestHelper):
|
||||||
|
def test_no_listing(self):
|
||||||
|
resp = self.get("/")
|
||||||
|
status, hdrs, body = parse(resp)
|
||||||
|
self.assertContains(status, "404 Not Found")
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
unittest.main()
|
||||||
|
|
||||||
|
# vim:set ts=4 sw=4 et:
|
Loading…
x
Reference in New Issue
Block a user