def test_get_logical_disks(): # Create a network command = r"net use Q: /DELETE" try: subprocess.check_output(command, shell=True, timeout=4) except subprocess.CalledProcessError: pass command = r"net use Q: \\localhost\c$\windows\temp" print(command) output = subprocess.check_output(command, shell=True, timeout=4) print("Creating network drive: ", output) no_net = get_logical_disks(include_network_drives=False) net_result = get_logical_disks(include_network_drives=True) # Delete the network drive command = "net use Q: /DELETE" output = subprocess.check_output(command, shell=True, timeout=4) print("Deleting network drive: ", output) print("Found disks from meta function without network drives: ", no_net) print("Found disks from meta function including network drives: ", net_result) assert len(no_net) < len( net_result ), "List without network drives should be smaller than list with network drives" assert isinstance(no_net, list), "get_logical_disks() should return list of str" assert "C:" in no_net, "We should at least have systemdrive C:" assert isinstance(net_result, list), "get_logical_disks() should return list of str" assert "C:" in net_result, "We should at least have systemdrive C:"
def test_get_logical_disks(): # Create a network command = r'net use Q: /DELETE' try: subprocess.check_output(command, shell=True, timeout=4) except subprocess.CalledProcessError: pass command = r'net use Q: \\localhost\c$\windows\temp' print(command) output = subprocess.check_output(command, shell=True, timeout=4) print('Creating network drive: ', output) no_net = get_logical_disks() net_result = get_logical_disks(include_network_drives=True) # Delete the network drive command = 'net use Q: /DELETE' output = subprocess.check_output(command, shell=True, timeout=4) print('Deleting network drive: ', output) print('Found disks from meta function without network drives: ', no_net) print('Found disks from meta function including network drives: ', net_result) assert no_net != net_result, 'We should not have the same drive list between net and nonet results' assert isinstance(no_net, list), 'get_logical_disks() should return list of str' assert 'C:' in no_net, 'We should at least have systemdrive C:' assert isinstance(net_result, list), 'get_logical_disks() should return list of str' assert 'C:' in net_result, 'We should at least have systemdrive C:'
def get_bitlocker_keys() -> dict: """ Return bitlocker protection keys for all drives """ bitlocker_keys = {} for drive in get_logical_disks(include_non_ntfs_refs=False, include_network_drives=False): if get_bitlocker_drive_status(drive): bitlocker_keys[drive] = get_bitlocker_protection_key(drive) return bitlocker_keys
def get_bitlocker_status() -> dict: """ Return bitlocker status for all drives """ bitlocker_status = {} # Only NTFS / ReFS drives are allowed to have bitlocker for drive in get_logical_disks(include_non_ntfs_refs=False, include_network_drives=False): bitlocker_status[drive] = get_bitlocker_drive_status(drive) return bitlocker_status
def get_bitlocker_full_status() -> dict: """ Return full bitlocker status for all drives """ bitlocker_full_status = {} for drive in get_logical_disks(include_non_ntfs_refs=False, include_network_drives=False): bitlocker_full_status[drive] = { 'status': get_bitlocker_drive_status(drive), 'protectors': get_bitlocker_protection_key(drive) } return bitlocker_full_status
def get_bitlocker_keys() -> dict: """ Return bitlocker protection keys for all drives """ bitlocker_keys = {} for drive in get_logical_disks( include_fs=BITLOCKER_ELIGIBLE_FS, exclude_unknown_fs=False, include_network_drives=False, ): if get_bitlocker_drive_status(drive): bitlocker_keys[drive] = get_bitlocker_protection_key(drive) return bitlocker_keys
def get_bitlocker_full_status() -> dict: """ Return full bitlocker status for all drives """ bitlocker_full_status = {} for drive in get_logical_disks( include_fs=BITLOCKER_ELIGIBLE_FS, exclude_unknown_fs=False, include_network_drives=False, ): bitlocker_full_status[drive] = { "status": get_bitlocker_drive_status(drive), "protectors": get_bitlocker_protection_key(drive), } return bitlocker_full_status