summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorBrian Rosmaita <rosmaita.fossdev@gmail.com>2017-12-15 14:35:49 -0500
committerBrian Rosmaita <rosmaita.fossdev@gmail.com>2017-12-15 15:10:43 -0500
commita5985508817e5de73092a339f15ce7f9f701a20f (patch)
tree7a7b7f90e3375d1cee1553c7f254320314844366 /tools
parentc0e63d977fc077be55a02106403840165b89a349 (diff)
downloadpython-glanceclient-a5985508817e5de73092a339f15ce7f9f701a20f.tar.gz
Restore functional testing under ssl
Closes-bug: #1738033 Change-Id: Ia3e2e210eea09ac07311f25ffa99ad0f4ced418d
Diffstat (limited to 'tools')
-rwxr-xr-xtools/fix_ca_bundle.sh37
1 files changed, 37 insertions, 0 deletions
diff --git a/tools/fix_ca_bundle.sh b/tools/fix_ca_bundle.sh
new file mode 100755
index 0000000..8e3dba2
--- /dev/null
+++ b/tools/fix_ca_bundle.sh
@@ -0,0 +1,37 @@
+# When the functional tests are run in a devstack environment, we
+# need to make sure that the python-requests module installed by
+# tox in the test environment can find the distro-specific CA store
+# where the devstack certs have been installed.
+#
+# assumptions:
+# - devstack is running
+# - the devstack tls-proxy service is running
+#
+# This code based on a function in devstack lib/tls
+function set_ca_bundle {
+ local python_cmd='.tox/functional/bin/python'
+ local capath=$($python_cmd -c $'try:\n from requests import certs\n print (certs.where())\nexcept ImportError: pass')
+ # of course, each distro keeps the CA store in a different location
+ local fedora_CA='/etc/pki/tls/certs/ca-bundle.crt'
+ local ubuntu_CA='/etc/ssl/certs/ca-certificates.crt'
+ local suse_CA='/etc/ssl/ca-bundle.pem'
+
+ # the distro CA is rooted in /etc, so if ours isn't, we need to
+ # change it
+ if [[ ! $capath == "" && ! $capath =~ ^/etc/.* && ! -L $capath ]]; then
+ if [[ -e $fedora_CA ]]; then
+ rm -f $capath
+ ln -s $fedora_CA $capath
+ elif [[ -e $ubuntu_CA ]]; then
+ rm -f $capath
+ ln -s $ubuntu_CA $capath
+ elif [[ -e $suse_CA ]]; then
+ rm -f $capath
+ ln -s $suse_CA $capath
+ else
+ echo "can't set CA bundle, expect tests to fail"
+ fi
+ fi
+}
+
+set_ca_bundle