|
6 | 6 |
|
7 | 7 | import json
|
8 | 8 | import logging
|
| 9 | +import os |
9 | 10 |
|
10 | 11 | import pytest
|
11 | 12 | from six.moves import mock
|
@@ -200,6 +201,39 @@ def test_ssl_context():
|
200 | 201 | assert not isinstance(s.get_adapter('https://'), SSLContextAdapter)
|
201 | 202 |
|
202 | 203 |
|
| 204 | +def test_verify_ssl(): |
| 205 | + |
| 206 | + with mock.patch('sasctl.core.Session.get_token', return_value='token'): |
| 207 | + # Should verify SSL by default |
| 208 | + s = Session('hostname', 'username', 'password') |
| 209 | + assert s.verify == True |
| 210 | + |
| 211 | + # Specify true with no issues |
| 212 | + s = Session('hostname', 'username', 'password', verify_ssl=True) |
| 213 | + assert s.verify == True |
| 214 | + |
| 215 | + # Explicitly disable SSL verification |
| 216 | + s = Session('hostname', 'username', 'password', verify_ssl=False) |
| 217 | + assert s.verify == False |
| 218 | + |
| 219 | + # Reuse SWAT env variable, if specified |
| 220 | + os.environ['SSLREQCERT'] = 'NO' |
| 221 | + s = Session('hostname', 'username', 'password') |
| 222 | + assert s.verify == False |
| 223 | + |
| 224 | + os.environ['SSLREQCERT'] = 'no' |
| 225 | + s = Session('hostname', 'username', 'password') |
| 226 | + assert s.verify == False |
| 227 | + |
| 228 | + os.environ['SSLREQCERT'] = 'false' |
| 229 | + s = Session('hostname', 'username', 'password') |
| 230 | + assert s.verify == False |
| 231 | + |
| 232 | + # Explicit should take precedence over environment variables |
| 233 | + s = Session('hostname', 'username', 'password', verify_ssl=True) |
| 234 | + assert s.verify == True |
| 235 | + |
| 236 | + |
203 | 237 | def test_kerberos():
|
204 | 238 | with mock.patch('sasctl.core.Session._get_token_with_kerberos',
|
205 | 239 | return_value='token'):
|
|
0 commit comments