code: def test_secure_write_win32():
      def fetch_win32_permissions(filename):
          """Extracts file permissions on windows using icacls"""
          role_permissions = {}
          proc = os.popen("icacls %s" % filename)
          lines = proc.read().splitlines()
          proc.close()
          for index, line in enumerate(lines):
              if index == 0:
                  line = (
                      line.split(filename)[-1].strip().lower()
                  )  # noqa: PLW2901
              match = re.match(r"\s*([^:]+):\(([^\)]*)\)", line)
              if match:
                  usergroup, permissions = match.groups()
                  usergroup = usergroup.lower().split("\\")[-1]
                  permissions = {
                      p.lower() for p in permissions.split(",")
                  }
                  role_permissions[usergroup] = permissions
              elif not line.strip():
                  break
          return role_permissions
  
      def check_user_only_permissions(fname):
          # Windows has it's own permissions ACL patterns
          username = os.environ["USERNAME"].lower()
          permissions = fetch_win32_permissions(fname)
          print(permissions)  # for easier debugging
          assert username in permissions
          assert permissions[username] == {"r", "w", "d"}
          assert "administrators" in permissions
          assert permissions["administrators"] == {"f"}
          assert "everyone" not in permissions
          assert len(permissions) == 2
  
      directory = tempfile.mkdtemp()
      fname = os.path.join(directory, "check_perms")
      try:
          with secure_write(fname) as f:
              f.write("test 1")
          check_user_only_permissions(fname)
          with open(fname, encoding="utf-8") as f:
              assert f.read() == "test 1"
      finally:
          shutil.rmtree(directory)
  
imports: from __future__ import annotations
  import os
  import re
  import shutil
  import site
  import stat
  import subprocess
  import sys
  import tempfile
  import warnings
  from unittest.mock import patch
  import pytest
  from platformdirs import __version_info__
  from jupyter_core import paths
  from jupyter_core.paths import UF_HIDDEN, _win32_restrict_file_to_user_ctypes, exists, is_file_hidden, is_hidden, issue_insecure_write_warning, jupyter_config_dir, jupyter_config_path, jupyter_data_dir, jupyter_path, jupyter_runtime_dir, prefer_environment_over_user, secure_write
label_desc: Use image node_id 43 for calling a global function with example usage: test_secure_write_win32() and returns: role_permissions