code: def test_listen_args():
      def basic_checks(ctx):
          assert ctx.verify_mode == ssl.CERT_REQUIRED
          assert ctx.check_hostname is False
          assert ctx.minimum_version is ssl.TLSVersion.TLSv1_2
          assert ctx.maximum_version is ssl.TLSVersion.TLSv1_3
  
      c = {
          "distributed.comm.tls.ca-file": ca_file,
          "distributed.comm.tls.scheduler.key": key1,
          "distributed.comm.tls.scheduler.cert": cert1,
          "distributed.comm.tls.worker.cert": keycert1,
          "distributed.comm.tls.min-version": None,
          "distributed.comm.tls.max-version": 1.3,
      }
      with dask.config.set(c):
          sec = Security()
  
      d = sec.get_listen_args("scheduler")
      assert not d["require_encryption"]
      ctx = d["ssl_context"]
      basic_checks(ctx)
      assert_many_ciphers(ctx)
  
      d = sec.get_listen_args("worker")
      ctx = d["ssl_context"]
      basic_checks(ctx)
      assert_many_ciphers(ctx)
  
      # No cert defined => no TLS
      d = sec.get_listen_args("client")
      assert d.get("ssl_context") is None
  
      # With more settings
      c["distributed.comm.tls.ciphers"] = FORCED_CIPHER
      c["distributed.comm.require-encryption"] = True
  
      with dask.config.set(c):
          sec = Security()
  
      d = sec.get_listen_args("scheduler")
      assert d["require_encryption"]
      ctx = d["ssl_context"]
      basic_checks(ctx)
  
      supported_ciphers = ctx.get_ciphers()
      tls_12_ciphers = [
          c for c in supported_ciphers if "TLSv1.2" in c["description"]
      ]
      assert len(tls_12_ciphers) == 1
      tls_13_ciphers = [
          c for c in supported_ciphers if "TLSv1.3" in c["description"]
      ]
      assert len(tls_13_ciphers) == 0 or len(tls_13_ciphers) >= 3
  
imports: from __future__ import annotations
  import ssl
  from contextlib import contextmanager
  import pytest
  import dask
  from distributed.comm import connect, listen
  from distributed.security import Security
  from distributed.utils_test import gen_test, get_cert, xfail_ssl_issue5601
label_desc: Use image node_id 16 for calling a global function with example usage: test_listen_args() without return types