Blame tests/p_mod_wsgi/10-test_mod_wsgi.sh

d7a223
#!/bin/bash
d7a223
d7a223
t_Log "Running $0 - Apache httpd mod_wsgi is functional"
d7a223
3b3229
if [[ $centos_ver -lt 6 || $centos_ver -gt 7 ]]; then
3b3229
    t_Log "mod_wsgi not available before CentOS 6 or after CentOS 7 -> SKIP"
d7a223
    exit 0
d7a223
fi
d7a223
d7a223
cat > /etc/httpd/conf.d/tfapp.conf << EOF
d7a223
WSGIScriptAlias /tfapp /var/www/html/tfapp.wsgi
d7a223
EOF
d7a223
d7a223
cat > /var/www/html/tfapp.wsgi << EOF
d7a223
def application(environ, start_response):
d7a223
    status = '200 OK'
d7a223
    output = 't_functional_mod_wsgi_test'.encode()
d7a223
    response_headers = [
d7a223
        ('Content-type', 'text/plain'),
d7a223
        ('Content-Length', str(len(output)))
d7a223
    ]
d7a223
    start_response(status, response_headers)
d7a223
    return [output]
d7a223
EOF
d7a223
d7a223
if [[ $centos_ver -ge 7 ]]; then
d7a223
    systemctl restart httpd
d7a223
else
d7a223
    service httpd restart
d7a223
fi
d7a223
d7a223
curl -s http://localhost/tfapp | grep -q 't_functional_mod_wsgi_test'
d7a223
t_CheckExitStatus $?
d7a223
d7a223
if [[ $centos_ver -ge 7 ]]; then
d7a223
    systemctl stop httpd
d7a223
else
d7a223
    service httpd stop
d7a223
fi
d7a223
d7a223
rm /etc/httpd/conf.d/tfapp.conf /var/www/html/tfapp.wsgi