Exemplo n.º 1
0
 def test_override_context_wrapper_config(self):
     instance = {'tls_verify': True}
     overrides = {'tls_verify': False}
     tls = TlsContextWrapper(instance, overrides=overrides)
     assert tls.config['tls_verify'] is False
     assert instance[
         'tls_verify'] is True  # Overrides should not affect the original instance
Exemplo n.º 2
0
 def test_verify_remapper_to_higher_priority(self):
     instance = {'disable_tls_validation': True, 'tls_verify': True}
     remapper = {
         'disable_tls_validation': {
             'name': '_tls_context_tls_verify',
             'invert': True
         }
     }
     tls = TlsContextWrapper(instance, remapper)
     assert tls.config['tls_verify'] is False
Exemplo n.º 3
0
 def test_invert_without_explicit_default(self):
     instance = {}
     remapper = {
         'disable_tls_validation': {
             'name': 'tls_verify',
             'invert': True
         }
     }
     tls = TlsContextWrapper(instance, remapper)
     assert tls.config['tls_verify'] is True
Exemplo n.º 4
0
    def test_invert(self):
        instance = {'disable_tls_validation': True}
        remapper = {
            'disable_tls_validation': {
                'name': 'tls_verify',
                'default': True,
                'invert': True
            }
        }
        tls = TlsContextWrapper(instance, remapper)

        assert tls.config['tls_verify'] is False
Exemplo n.º 5
0
 def test_verify_no_remapper(self):
     instance = {'tls_verify': False, '_tls_context_tls_verify': True}
     tls = TlsContextWrapper(instance)
     assert tls.config['tls_verify'] is True
Exemplo n.º 6
0
 def test_default(self):
     remapper = {'verify': {'name': 'tls_verify', 'default': False}}
     tls = TlsContextWrapper({}, remapper)
     assert tls.config['tls_verify'] is False
Exemplo n.º 7
0
 def test_no_default(self):
     remapper = {'verify': {'name': 'tls_verify'}}
     tls = TlsContextWrapper({}, remapper)
     assert tls.config['tls_verify'] is True
Exemplo n.º 8
0
def test_attributes(param):
    config = {param: 'foo'}
    with patch('ssl.SSLContext'):
        tls = TlsContextWrapper(config)
    assert tls.config[param] == 'foo'
Exemplo n.º 9
0
 def test_config_overwrite(self, param):
     config = {'tls_verify': False, param: 'foo'}
     with patch('ssl.SSLContext'):
         tls = TlsContextWrapper(config)
     assert tls.config['tls_verify'] is True
Exemplo n.º 10
0
 def test_config(self):
     tls = TlsContextWrapper({'tls_verify': False})
     assert tls.config['tls_verify'] is False
Exemplo n.º 11
0
 def test_default(self):
     tls = TlsContextWrapper({})
     assert tls.config['tls_verify'] is True
Exemplo n.º 12
0
 def test_override_non_exist_instance_config(self):
     instance = {'tls_verify': True}
     overrides = {'fake_config': 'foo'}
     tls = TlsContextWrapper(instance, overrides=overrides)
     assert instance.get('fake_config') is None
     assert tls.config['tls_verify'] is True
Exemplo n.º 13
0
 def test_override_context_wrapper_config_empty(self):
     instance = {'tls_verify': True}
     overrides = {}
     tls = TlsContextWrapper(instance, overrides=overrides)
     assert tls.config['tls_verify'] is True
Exemplo n.º 14
0
 def test_remap_validate_cert(self):
     instance = {'validate_cert': False}
     remapper = {'validate_cert': {'name': 'tls_verify', 'default': True}}
     tls = TlsContextWrapper(instance, remapper)
     assert tls.config['tls_verify'] is False