Skip to content

Commit

Permalink
Reschedule SetupFileVault cmds with NotNow status
Browse files Browse the repository at this point in the history
When FV is configured after a device has enrolled, and the device is
asleep, the command will fail with a NotNow status. It must be
rescheduled when the device wakes up.
  • Loading branch information
np5 committed Aug 9, 2024
1 parent 66ab5c3 commit 02b6221
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
24 changes: 23 additions & 1 deletion tests/mdm/test_setup_filevault_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from zentral.contrib.inventory.models import MetaBusinessUnit
from zentral.contrib.mdm.artifacts import Target
from zentral.contrib.mdm.commands import SetupFileVault
from zentral.contrib.mdm.commands.scheduling import _setup_filevault
from zentral.contrib.mdm.commands.scheduling import _get_next_queued_command, _setup_filevault
from zentral.contrib.mdm.models import Channel, Command, Platform, RequestStatus
from .utils import force_blueprint, force_dep_enrollment_session, force_filevault_config

Expand Down Expand Up @@ -374,3 +374,25 @@ def test_setup_filevault_change_ok(self):
RequestStatus.IDLE,
)
self.assertIsInstance(cmd, SetupFileVault)

def test_setup_filevault_reschedule_not_now(self):
self.enrolled_device.user_approved_enrollment = True
self.enrolled_device.user_enrollment = False
self.assertFalse(self.enrolled_device.awaiting_configuration)
filevault_config = force_filevault_config()
self.enrolled_device.blueprint = force_blueprint(filevault_config=filevault_config)
target = Target(self.enrolled_device)
cmd = SetupFileVault.create_for_target(target)
cmd.process_response(
{"UDID": self.enrolled_device.udid,
"Status": "NotNow",
"CommandUUID": str(cmd.uuid).upper()},
self.dep_enrollment_session,
self.mbu
)
cmd2 = _get_next_queued_command(
target,
self.dep_enrollment_session,
RequestStatus.IDLE,
)
self.assertEqual(cmd2, cmd)
1 change: 1 addition & 0 deletions zentral/contrib/mdm/commands/setup_filevault.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ def build_payload(enrolled_device):
class SetupFileVault(Command):
request_type = "InstallProfile"
db_name = "SetupFileVault"
reschedule_notnow = True

@staticmethod
def verify_channel_and_device(channel, enrolled_device):
Expand Down

0 comments on commit 02b6221

Please sign in to comment.