Skip to content

Commit d17a65c

Browse files
committedNov 3, 2016
[tests] Chmod 0400 PKI certificates
1 parent c54d9d8 commit d17a65c

File tree

2 files changed

+20
-6
lines changed

2 files changed

+20
-6
lines changed
 

‎tests/src/python/test_authmanager_pki_ows.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import subprocess
2222
import tempfile
2323
import urllib
24+
import stat
2425

2526
__author__ = 'Alessandro Pasotti'
2627
__date__ = '25/10/2016'
@@ -68,13 +69,16 @@ def setUpAuth(cls):
6869
cls.sslrootcert_path = os.path.join(cls.certsdata_path, 'chains_subissuer-issuer-root_issuer2-root2.pem')
6970
cls.sslcert = os.path.join(cls.certsdata_path, 'gerardus_cert.pem')
7071
cls.sslkey = os.path.join(cls.certsdata_path, 'gerardus_key.pem')
72+
assert os.path.isfile(cls.sslcert)
73+
assert os.path.isfile(cls.sslkey)
74+
assert os.path.isfile(cls.sslrootcert_path)
75+
os.chmod(cls.sslcert, stat.S_IRUSR)
76+
os.chmod(cls.sslkey, stat.S_IRUSR)
77+
os.chmod(cls.sslrootcert_path, stat.S_IRUSR)
7178
cls.auth_config = QgsAuthMethodConfig("PKI-Paths")
7279
cls.auth_config.setConfig('certpath', cls.sslcert)
7380
cls.auth_config.setConfig('keypath', cls.sslkey)
7481
cls.auth_config.setName('test_pki_auth_config')
75-
assert os.path.isfile(cls.sslcert)
76-
assert os.path.isfile(cls.sslkey)
77-
assert os.path.isfile(cls.sslrootcert_path)
7882
cls.username = 'Gerardus'
7983
cls.sslrootcert = QSslCertificate.fromPath(cls.sslrootcert_path)
8084
assert cls.sslrootcert is not None
@@ -87,6 +91,9 @@ def setUpAuth(cls):
8791
cls.server_cert = os.path.join(cls.certsdata_path, 'localhost_ssl_cert.pem')
8892
cls.server_key = os.path.join(cls.certsdata_path, 'localhost_ssl_key.pem')
8993
cls.server_rootcert = cls.sslrootcert_path
94+
os.chmod(cls.server_cert, stat.S_IRUSR)
95+
os.chmod(cls.server_key, stat.S_IRUSR)
96+
os.chmod(cls.server_rootcert, stat.S_IRUSR)
9097

9198
os.environ['QGIS_SERVER_HOST'] = cls.hostname
9299
os.environ['QGIS_SERVER_PORT'] = str(cls.port)

‎tests/src/python/test_authmanager_pki_postgres.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import os
2323
import time
2424
import signal
25+
import stat
2526
import subprocess
2627
import tempfile
2728

@@ -97,13 +98,16 @@ def setUpAuth(cls):
9798
cls.sslrootcert_path = os.path.join(cls.certsdata_path, 'chains_subissuer-issuer-root_issuer2-root2.pem')
9899
cls.sslcert = os.path.join(cls.certsdata_path, 'gerardus_cert.pem')
99100
cls.sslkey = os.path.join(cls.certsdata_path, 'gerardus_key.pem')
101+
assert os.path.isfile(cls.sslcert)
102+
assert os.path.isfile(cls.sslkey)
103+
assert os.path.isfile(cls.sslrootcert_path)
104+
os.chmod(cls.sslcert, stat.S_IRUSR)
105+
os.chmod(cls.sslkey, stat.S_IRUSR)
106+
os.chmod(cls.sslrootcert_path, stat.S_IRUSR)
100107
cls.auth_config = QgsAuthMethodConfig("PKI-Paths")
101108
cls.auth_config.setConfig('certpath', cls.sslcert)
102109
cls.auth_config.setConfig('keypath', cls.sslkey)
103110
cls.auth_config.setName('test_pki_auth_config')
104-
assert os.path.isfile(cls.sslcert)
105-
assert os.path.isfile(cls.sslkey)
106-
assert os.path.isfile(cls.sslrootcert_path)
107111
cls.username = 'Gerardus'
108112
cls.sslrootcert = QSslCertificate.fromPath(cls.sslrootcert_path)
109113
assert cls.sslrootcert is not None
@@ -118,6 +122,9 @@ def setUpAuth(cls):
118122
cls.server_cert = os.path.join(cls.certsdata_path, 'localhost_ssl_cert.pem')
119123
cls.server_key = os.path.join(cls.certsdata_path, 'localhost_ssl_key.pem')
120124
cls.server_rootcert = cls.sslrootcert_path
125+
os.chmod(cls.server_cert, stat.S_IRUSR)
126+
os.chmod(cls.server_key, stat.S_IRUSR)
127+
os.chmod(cls.server_rootcert, stat.S_IRUSR)
121128

122129
# Place conf in the data folder
123130
with open(cls.pg_conf, 'w+') as f:

0 commit comments

Comments
 (0)
Please sign in to comment.