Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Skip account creation with auto_advance_setup #765

Merged
merged 1 commit into from
Jul 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions tests/mdm/test_account_configuration_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,35 @@ def test_build_command_realm_user_password_hash_admin(self):
"passwordHash": serialize_password_hash_dict(password_hash)}]
)

def test_build_command_no_realm_user_hard_coded_admin_auto_advance_setup(self):
self.dep_enrollment_session.realm_user = None
self.dep_enrollment_session.save()
dep_enrollment = self.dep_enrollment_session.dep_enrollment
dep_enrollment.use_realm_user = False
dep_enrollment.auto_advance_setup = True
dep_enrollment.admin_full_name = "Admin Full Name"
dep_enrollment.admin_short_name = "admin_short_name"
dep_enrollment.admin_password_hash = {"SALTED-SHA512-PBKDF2": {"fake": True}}
dep_enrollment.save()
cmd = AccountConfiguration.create_for_device(
self.dep_enrollment_session.enrolled_device
)
response = cmd.build_http_response(self.dep_enrollment_session)
payload = plistlib.loads(response.content)["Command"]
self.assertEqual(
payload["AutoSetupAdminAccounts"],
[{"fullName": "Admin Full Name",
"shortName": "admin_short_name",
"hidden": True,
"passwordHash": serialize_password_hash_dict(dep_enrollment.admin_password_hash)}]
)
self.assertTrue(payload["DontAutoPopulatePrimaryAccountInfo"])
self.assertTrue(payload["SkipPrimarySetupAccountCreation"])
self.assertNotIn("LockPrimaryAccountInfo", payload)
self.assertNotIn("PrimaryAccountFullName", payload)
self.assertNotIn("PrimaryAccountUserName", payload)
self.assertNotIn("SetPrimarySetupAccountAsRegularUser", payload)

# _configure_dep_enrollment_accounts

def test_configure_dep_enrollment_accounts_not_now(self):
Expand Down
2 changes: 2 additions & 0 deletions zentral/contrib/mdm/commands/account_configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ def build_command(self):
"hidden": True, # TODO => DEP Profile
"passwordHash": serialize_password_hash_dict(dep_enrollment.admin_password_hash)
})
if not dep_enrollment.use_realm_user and dep_enrollment.auto_advance_setup:
command["SkipPrimarySetupAccountCreation"] = True

return command

Expand Down