summaryrefslogtreecommitdiffstats
path: root/test/setup.sh
blob: 487a5f5a76c8447c76f158fe7a0e23e000781d62 (plain)
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
#!/bin/sh
currentpath=`pwd`
server_uid=$USER
server_gid=$USER
server_port=8000
server_name=`hostname`

DBPREFIX=$1

test_root=$currentpath/work/httpd
test_root_esc=`echo ${test_root} | sed -e 's/\\//\\\\\\//g'`

if [ -e $test_root ]; then
    if [ $# -gt 0 -a "$1X" = "forceX" ]; then
        rm -rf work
    else
        echo "Test directory already exists"
        exit 1
    fi
fi

./createinstance.sh ${test_root}

cp ../.libs/libmodnss.so ${test_root}/lib
cp ../nss_pcache ${test_root}/bin

echo "Generating a new certificate database..."
bash ../gencert ${DBPREFIX}${test_root}/alias > /dev/null 2>&1
echo internal:httptest > ${test_root}/conf/password.conf

# Export the CA cert
certutil -L -d ${DBPREFIX}${test_root}/alias -n cacert -a > ${test_root}/alias/ca.pem

# Export the client cert
cd ${test_root}
echo password > pw
echo httptest > dbpw
pk12util -o alpha.p12 -d ${DBPREFIX}${test_root}/alias -n alpha -w pw -k dbpw
openssl pkcs12  -in alpha.p12 -clcerts -nokeys -out alpha.crt -passin pass:`cat pw`
openssl pkcs12  -in alpha.p12 -nocerts -nodes -out alpha.key -passin pass:`cat pw`
pk12util -o beta.p12 -d ${DBPREFIX}${test_root}/alias -n beta -w pw -k dbpw
openssl pkcs12  -in beta.p12 -clcerts -nokeys -out beta.crt -passin pass:`cat pw`
openssl pkcs12  -in beta.p12 -nocerts -nodes -out beta.key -passin pass:`cat pw`
/bin/rm -f pw dbpw
cd -

if [ -f ${test_root}/sedfile ]
then
        rm ${test_root}/sedfile
fi

echo "s/::TEST_ROOT::/${test_root_esc}/g" >> ${test_root}/sedfile
echo "s/::SERVER_ROOT::/${test_root_esc}/g" >> ${test_root}/sedfile
echo "s/::SERVER_PORT::/${server_port}/g" >> ${test_root}/sedfile
echo "s/::SERVER_NAME::/${server_name}/g" >> ${test_root}/sedfile
echo "s/::SERVER_UID::/${server_uid}/g" >> ${test_root}/sedfile
echo "s/::SERVER_GID::/${server_gid}/g" >> ${test_root}/sedfile

cat httpd.conf.tmpl | sed  -f ${test_root}/sedfile > ${test_root}/conf/httpd.conf