summaryrefslogtreecommitdiffstats
path: root/httpd/httpd_basic_auth.sh
blob: 4e0090f6b526d6bae323a2d7b95a848d77fef057 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#!/bin/sh
# A small Apache HTTPd test suite
# Author: Athmane Madjoudj <athmane@fedoraproject.org>

echo "Running $0 - httpd basic authentication test."

cat > /etc/httpd/conf.d/dir-test-basic-auth.conf <<EOF
Alias /basic_auth_test /var/www/html/basic_auth_test
<Directory "/var/www/html/basic_auth_test">
  AuthType Basic
  AuthName "Test"
  AuthUserFile /etc/httpd/htpasswd
  require user test
</Directory>
EOF

htpasswd -c -b /etc/httpd/htpasswd test test
mkdir -p /var/www/html/basic_auth_test
echo "Basic authentication Test Page" > /var/www/html/basic_auth_test/index.html
service httpd reload
curl -s -u test:test http://localhost/basic_auth_test/ | grep 'Basic authentication Test Page' > /dev/null 2>&1