-
Notifications
You must be signed in to change notification settings - Fork 729
Install setup-experience VPP apps on manually-enrolled iOS/iPadOS devices #35906
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
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
1aabea6
enqueue setup experience items for manual enrolled ipad/ios
sgress454 080db5c
updates
sgress454 f3f97b3
install apps post manual enrollment
sgress454 0a97175
start tests
sgress454 f6ec542
finish tests
sgress454 4b98fc1
updates
sgress454 e71a275
changelog
sgress454 3da2be7
Merge branch 'main' into sgress454/34042
sgress454 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| - Support installation of setup-experience VPP apps on manual-enrolled iOS/iPadOS devices |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1437,7 +1437,7 @@ func TestMDMUnenrollment(t *testing.T) { | |
| } | ||
|
|
||
| func TestMDMTokenUpdate(t *testing.T) { | ||
| ctx := context.Background() | ||
| ctx := license.NewContext(context.Background(), &fleet.LicenseInfo{Tier: fleet.TierPremium}) | ||
| ds := new(mock.Store) | ||
| mdmStorage := &mdmmock.MDMAppleStore{} | ||
| pushFactory, _ := newMockAPNSPushProviderFactory() | ||
|
|
@@ -1600,6 +1600,164 @@ func TestMDMTokenUpdate(t *testing.T) { | |
| require.True(t, ds.SetHostMDMMigrationCompletedFuncInvoked) | ||
| } | ||
|
|
||
| func TestMDMTokenUpdateIOS(t *testing.T) { | ||
| ctx := context.Background() | ||
| ds := new(mock.Store) | ||
| mdmStorage := &mdmmock.MDMAppleStore{} | ||
| pushFactory, _ := newMockAPNSPushProviderFactory() | ||
| pusher := nanomdm_pushsvc.New( | ||
| mdmStorage, | ||
| mdmStorage, | ||
| pushFactory, | ||
| NewNanoMDMLogger(kitlog.NewJSONLogger(os.Stdout)), | ||
| ) | ||
| cmdr := apple_mdm.NewMDMAppleCommander(mdmStorage, pusher) | ||
| mdmLifecycle := mdmlifecycle.New(ds, kitlog.NewNopLogger(), newActivity) | ||
| svc := MDMAppleCheckinAndCommandService{ | ||
| ds: ds, | ||
| mdmLifecycle: mdmLifecycle, | ||
| commander: cmdr, | ||
| logger: kitlog.NewNopLogger(), | ||
| } | ||
| uuid, serial, model, wantTeamID := "ABC-DEF-GHI", "XYZABC", "MacBookPro 16,1", uint(12) | ||
|
|
||
| ds.GetMDMIdPAccountByHostUUIDFunc = func(ctx context.Context, hostUUID string) (*fleet.MDMIdPAccount, error) { | ||
| require.Equal(t, uuid, hostUUID) | ||
| return &fleet.MDMIdPAccount{ | ||
| UUID: "some-uuid", | ||
| Username: "some-user", | ||
| Email: "[email protected]", | ||
| Fullname: "Some User", | ||
| }, nil | ||
| } | ||
|
|
||
| ds.NewJobFunc = func(ctx context.Context, j *fleet.Job) (*fleet.Job, error) { | ||
| return j, nil | ||
| } | ||
|
|
||
| ds.GetHostMDMCheckinInfoFunc = func(ct context.Context, hostUUID string) (*fleet.HostMDMCheckinInfo, error) { | ||
| require.Equal(t, uuid, hostUUID) | ||
| return &fleet.HostMDMCheckinInfo{ | ||
| HostID: 1337, | ||
| HardwareSerial: serial, | ||
| DisplayName: model, | ||
| InstalledFromDEP: true, | ||
| TeamID: wantTeamID, | ||
| DEPAssignedToFleet: true, | ||
| Platform: "ios", | ||
| }, nil | ||
| } | ||
|
|
||
| ds.GetNanoMDMEnrollmentFunc = func(ctx context.Context, hostUUID string) (*fleet.NanoEnrollment, error) { | ||
| return &fleet.NanoEnrollment{Enabled: true, Type: "Device", TokenUpdateTally: 1}, nil | ||
| } | ||
|
|
||
| ds.EnqueueSetupExperienceItemsFunc = func(ctx context.Context, hostPlatformLike string, hostUUID string, teamID uint) (bool, error) { | ||
| require.Equal(t, "ios", hostPlatformLike) | ||
| require.Equal(t, uuid, hostUUID) | ||
| require.Equal(t, wantTeamID, teamID) | ||
| return true, nil | ||
| } | ||
|
|
||
| // DEP-installed without AwaitingConfiguration - should not enqueue SetupExperience items | ||
| err := svc.TokenUpdate( | ||
| &mdm.Request{ | ||
| Context: ctx, | ||
| EnrollID: &mdm.EnrollID{ID: uuid, Type: mdm.Device}, | ||
| Params: map[string]string{"enroll_reference": "abcd"}, | ||
| }, | ||
| &mdm.TokenUpdate{ | ||
| Enrollment: mdm.Enrollment{ | ||
| UDID: uuid, | ||
| }, | ||
| }, | ||
| ) | ||
| require.NoError(t, err) | ||
| require.False(t, ds.EnqueueSetupExperienceItemsFuncInvoked) | ||
|
|
||
| // Non-DEP-installed, non device-type enrollment should not enqueue SetupExperience items | ||
| err = svc.TokenUpdate( | ||
| &mdm.Request{ | ||
| Context: ctx, | ||
| EnrollID: &mdm.EnrollID{ID: uuid, Type: mdm.User}, | ||
| Params: map[string]string{"enroll_reference": "abcd"}, | ||
| }, | ||
| &mdm.TokenUpdate{ | ||
| Enrollment: mdm.Enrollment{ | ||
| UDID: uuid, | ||
| }, | ||
| }, | ||
| ) | ||
| require.NoError(t, err) | ||
| require.False(t, ds.EnqueueSetupExperienceItemsFuncInvoked) | ||
|
|
||
| // Non-DEP-installed without AwaitingConfiguration - should not enqueue SetupExperience items if token count is > 1 | ||
| ds.GetHostMDMCheckinInfoFunc = func(ct context.Context, hostUUID string) (*fleet.HostMDMCheckinInfo, error) { | ||
| require.Equal(t, uuid, hostUUID) | ||
| return &fleet.HostMDMCheckinInfo{ | ||
| HostID: 1337, | ||
| HardwareSerial: serial, | ||
| DisplayName: model, | ||
| InstalledFromDEP: false, | ||
| TeamID: wantTeamID, | ||
| DEPAssignedToFleet: true, | ||
| Platform: "ios", | ||
| }, nil | ||
| } | ||
|
|
||
| ds.GetNanoMDMEnrollmentFunc = func(ctx context.Context, hostUUID string) (*fleet.NanoEnrollment, error) { | ||
| return &fleet.NanoEnrollment{Enabled: true, Type: "Device", TokenUpdateTally: 2}, nil | ||
| } | ||
|
|
||
| err = svc.TokenUpdate( | ||
| &mdm.Request{ | ||
| Context: ctx, | ||
| EnrollID: &mdm.EnrollID{ID: uuid, Type: mdm.Device}, | ||
| Params: map[string]string{"enroll_reference": "abcd"}, | ||
| }, | ||
| &mdm.TokenUpdate{ | ||
| Enrollment: mdm.Enrollment{ | ||
| UDID: uuid, | ||
| }, | ||
| }, | ||
| ) | ||
| require.NoError(t, err) | ||
| require.False(t, ds.EnqueueSetupExperienceItemsFuncInvoked) | ||
|
|
||
| // Non-DEP-installed without AwaitingConfiguration - should enqueue SetupExperience items if token count is 1 | ||
| ds.GetHostMDMCheckinInfoFunc = func(ct context.Context, hostUUID string) (*fleet.HostMDMCheckinInfo, error) { | ||
| require.Equal(t, uuid, hostUUID) | ||
| return &fleet.HostMDMCheckinInfo{ | ||
| HostID: 1337, | ||
| HardwareSerial: serial, | ||
| DisplayName: model, | ||
| InstalledFromDEP: false, | ||
| TeamID: wantTeamID, | ||
| DEPAssignedToFleet: true, | ||
| Platform: "ios", | ||
| }, nil | ||
| } | ||
|
|
||
| ds.GetNanoMDMEnrollmentFunc = func(ctx context.Context, hostUUID string) (*fleet.NanoEnrollment, error) { | ||
| return &fleet.NanoEnrollment{Enabled: true, Type: "Device", TokenUpdateTally: 1}, nil | ||
| } | ||
|
|
||
| err = svc.TokenUpdate( | ||
| &mdm.Request{ | ||
| Context: ctx, | ||
| EnrollID: &mdm.EnrollID{ID: uuid, Type: mdm.Device}, | ||
| Params: map[string]string{"enroll_reference": "abcd"}, | ||
| }, | ||
| &mdm.TokenUpdate{ | ||
| Enrollment: mdm.Enrollment{ | ||
| UDID: uuid, | ||
| }, | ||
| }, | ||
| ) | ||
| require.NoError(t, err) | ||
| require.True(t, ds.EnqueueSetupExperienceItemsFuncInvoked) | ||
| } | ||
|
|
||
| func TestMDMCheckout(t *testing.T) { | ||
| ds := new(mock.Store) | ||
| mdmLifecycle := mdmlifecycle.New(ds, kitlog.NewNopLogger(), newActivity) | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Previously, the logic here was "only enqueue setup experience items if the device reports the
AwaitingConfigurationflag, AND it is an ios/ipad device OR it is any device that's not in the middle of a migration. After confirming that only macOS devices can be in theMigrationInProgressstate, I expanded and simplified this logic to:AwaitingConfigurationand notMigrationInProgress, enqueue setup experience items.TokenUpdateTally == 1), enqueue setup experience itemsThis ensures that enqueuing the items (which involves wiping out any existing items in the queue for the device) only happens once.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We probably also want to check the enrollment type here. I think we only want to do this if it is a Device enrollment - a User enrollment(Device)(it's a thing in nano) aka a personal or byod device both doesn't currently support VPP when enrolled in fleet and is probably not part of the spec for this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also you can check the type by checking r.Type before you fetch the enrollment if that makes things cleaner. It should be set for all requests
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a separate check from the
r.Type == mdm.Devicethat I'm doing? What other property should I look at?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I somehow totally missed that. My bad - your check is totally fine