Skip to content

Commit

Permalink
Add test for load kube client with disable ssl
Browse files Browse the repository at this point in the history
  • Loading branch information
wselfjes committed Jul 22, 2022
1 parent cb3510b commit e27e44d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
5 changes: 4 additions & 1 deletion airflow/kubernetes/kube_client.py
Expand Up @@ -30,7 +30,10 @@
has_kubernetes = True

def _disable_verify_ssl() -> None:
configuration = Configuration.get_default_copy()
if hasattr(Configuration, 'get_default_copy'):
configuration = Configuration.get_default_copy()
else:
configuration = Configuration()
configuration.verify_ssl = False
Configuration.set_default(configuration)

Expand Down
13 changes: 13 additions & 0 deletions tests/kubernetes/test_client.py
Expand Up @@ -38,6 +38,19 @@ def test_load_file_config(self, config):
assert config.load_incluster_config.not_called
assert config.load_kube_config.called

@mock.patch('airflow.kubernetes.kube_client.config')
@mock.patch('airflow.kubernetes.kube_client.conf')
def test_load_config_disable_ssl(self, conf, config):
conf.getboolean.return_value = False
get_kube_client(in_cluster=False)
conf.getboolean.assert_called_with('kubernetes', 'verify_ssl')
# Support wide range of kube client libraries
if hasattr(Configuration, 'get_default_copy'):
configuration = Configuration.get_default_copy()
else:
configuration = Configuration()
self.assertFalse(configuration.verify_ssl)

def test_enable_tcp_keepalive(self):
socket_options = [
(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1),
Expand Down

0 comments on commit e27e44d

Please sign in to comment.