Merge branch 'defect/30941' into develop
[tor-bridgedb.git] / scripts / setup-tests
blob1de3c71c8fb2a4e8774b99e1fac69d4047e13607
1 #!/usr/bin/env bash
3 set -x --
5 THIS_SCRIPT="$(realpath $0)"
6 HERE="$THIS_SCRIPT"
8 while [ "${HERE##*/}" != "bridgedb" ] ; do HERE="${HERE%/*}" ; done
10 THERE="$HERE"
11 echo "Found top-level repo directory: $THERE"
12 cd $THERE
14 mkdir -p run/from-authority
15 mkdir -p run/from-bifroest
16 cp -R -t run bridgedb.conf captchas .gnupg
17 # Add '127.0.0.1' to EMAIL_DOMAINS in bridgedb.conf. This should ONLY be
18 # done on testing servers, never on production servers.
19 sed -r -i -e "s/(EMAIL_DOMAINS)(.*)(])/\1\2\, '127.0.0.1']/" run/bridgedb.conf
20 # Change EMAIL_SMTP_PORT to 2525:
21 sed -r -i -e "s/(EMAIL_SMTP_PORT = )([1-9]{2,5})/\12525/" run/bridgedb.conf
22 # Enable plaintext HTTP distribution, otherwise the mechanize-based tests in
23 # test_https.py will fail with CERTIFICATE_VERIFY_FAILED because urllib2
24 # won't recognize our self-signed certificate:
25 sed -r -i -e "s/(HTTP_UNENCRYPTED_BIND_IP = )(None)/\1'127.0.0.1'/" run/bridgedb.conf
26 sed -r -i -e "s/(HTTP_UNENCRYPTED_PORT = )(None)/\16788/" run/bridgedb.conf
27 sed -r -i -e "s/(SERVER_PUBLIC_FQDN = )(.*)/\1'127.0.0.1:6788'/" run/bridgedb.conf
28 # Enable plaintext HTTP distribution for the moat server as well
29 sed -r -i -e "s/(MOAT_HTTP_IP = )(None)/\1'127.0.0.1'/" run/bridgedb.conf
30 sed -r -i -e "s/(MOAT_HTTP_PORT = )(None)/\16790/" run/bridgedb.conf
31 # Create descriptors
32 ./scripts/create_descriptors 200 --num-resistant-descs 100
33 cp -t run/from-authority networkstatus-bridges cached-extrainfo* bridge-descriptors
34 cp -t run/from-bifroest networkstatus-bridges cached-extrainfo* bridge-descriptors
35 # Create TLS certificates
36 ./scripts/make-ssl-cert
37 cp -t run privkey.pem cert
38 cp privkey.pem run/moat-tls.pem
39 cp cert run/moat-tls.crt