<s> import os <EOL> from dcos import constants <EOL> import pytest <EOL> from . common import config_set , exec_command , update_config <EOL> @ pytest . fixture <EOL> def env ( ) : <EOL> r = os . environ . copy ( ) <EOL> r . update ( { <EOL> constants . PATH_ENV : os . environ [ constants . PATH_ENV ] , <EOL> constants . DCOS_CONFIG_ENV : os . path . join ( "<STR_LIT>" , "<STR_LIT:data>" , "<STR_LIT>" ) , <EOL> } ) <EOL> return r <EOL> @ pytest . yield_fixture ( autouse = True ) <EOL> def setup_env ( env ) : <EOL> config_set ( "<STR_LIT>" , "<STR_LIT>" , env ) <EOL> try : <EOL> yield <EOL> finally : <EOL> config_set ( "<STR_LIT>" , "<STR_LIT>" , env ) <EOL> def test_dont_verify_ssl_with_env_var ( env ) : <EOL> env [ constants . DCOS_SSL_VERIFY_ENV ] = '<STR_LIT:false>' <EOL> returncode , stdout , stderr = exec_command ( <EOL> [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT:list>' ] , env ) <EOL> assert returncode == <NUM_LIT:0> <EOL> assert stderr == b'<STR_LIT>' <EOL> env . pop ( constants . DCOS_SSL_VERIFY_ENV ) <EOL> def test_dont_verify_ssl_with_config ( env ) : <EOL> with update_config ( '<STR_LIT>' , '<STR_LIT:false>' , env ) : <EOL> returncode , stdout , stderr = exec_command ( <EOL> [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT:list>' ] , env ) <EOL> assert returncode == <NUM_LIT:0> <EOL> assert stderr == b'<STR_LIT>' <EOL> def test_verify_ssl_without_cert_env_var ( env ) : <EOL> env [ constants . DCOS_SSL_VERIFY_ENV ] = '<STR_LIT:true>' <EOL> with update_config ( '<STR_LIT>' , None , env ) : <EOL> returncode , stdout , stderr = exec_command ( <EOL> [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT:list>' ] , env ) <EOL> assert returncode == <NUM_LIT:1> <EOL> assert "<STR_LIT>" in stderr . decode ( '<STR_LIT:utf-8>' ) <EOL> env . pop ( constants . DCOS_SSL_VERIFY_ENV ) <EOL> def test_verify_ssl_without_cert_config ( env ) : <EOL> with update_config ( '<STR_LIT>' , '<STR_LIT:true>' , env ) : <EOL> returncode , stdout , stderr = exec_command ( <EOL> [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT:list>' ] , env ) <EOL> assert returncode == <NUM_LIT:1> <EOL> assert "<STR_LIT>" in stderr . decode ( '<STR_LIT:utf-8>' ) <EOL> def test_verify_ssl_with_bad_cert_env_var ( env ) : <EOL> env [ constants . DCOS_SSL_VERIFY_ENV ] = '<STR_LIT>' <EOL> with update_config ( '<STR_LIT>' , None , env ) : <EOL> returncode , stdout , stderr = exec_command ( <EOL> [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT:list>' ] , env ) <EOL> assert returncode == <NUM_LIT:1> <EOL> assert "<STR_LIT>" in stderr . decode ( '<STR_LIT:utf-8>' ) <EOL> env . pop ( constants . DCOS_SSL_VERIFY_ENV ) <EOL> def test_verify_ssl_with_bad_cert_config ( env ) : <EOL> with update_config ( '<STR_LIT>' , '<STR_LIT>' , env ) : <EOL> returncode , stdout , stderr = exec_command ( <EOL> [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT:list>' ] , env ) <EOL> assert returncode == <NUM_LIT:1> <EOL> assert "<STR_LIT>" in stderr . decode ( '<STR_LIT:utf-8>' ) <EOL> def test_verify_ssl_with_good_cert_env_var ( env ) : <EOL> env [ constants . DCOS_SSL_VERIFY_ENV ] = '<STR_LIT>' <EOL> with update_config ( '<STR_LIT>' , None , env ) : <EOL> returncode , stdout , stderr = exec_command ( <EOL> [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT:list>' ] , env ) <EOL> assert returncode == <NUM_LIT:0> <EOL> assert stderr == b'<STR_LIT>' <EOL> env . pop ( constants . DCOS_SSL_VERIFY_ENV ) <EOL> def test_verify_ssl_with_good_cert_config ( env ) : <EOL> with update_config ( <EOL> '<STR_LIT>' , '<STR_LIT>' , env ) : <EOL> returncode , stdout , stderr = exec_command ( <EOL> [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT:list>' ] , env ) <EOL> assert returncode == <NUM_LIT:0> <EOL> assert stderr == b'<STR_LIT>' </s>
