mirror of
https://github.com/micromdm/micromdm/
synced 2026-08-13 14:05:42 +08:00
Add regression test for bundle with size that is too large for int field.
Change applications table migration to use bigint field for `bundle_size`
This commit is contained in:
@@ -191,7 +191,6 @@ func (svc service) ackInstalledApplicationList(req mdm.Response) error {
|
||||
// TODO: This is a pretty horrible algorithm and I should re-design it at some point. m.
|
||||
removedouter:
|
||||
for _, deviceApp := range deviceApps {
|
||||
fmt.Printf("Is app removed? %s\n", deviceApp.Name)
|
||||
for _, app := range requestApps {
|
||||
if deviceApp.Version == app.Version && deviceApp.Name == app.Name {
|
||||
deviceNotRemoved = append(deviceNotRemoved, deviceApp)
|
||||
@@ -204,7 +203,7 @@ removedouter:
|
||||
|
||||
// Any installed applications that are already represented in the `applications` table AND
|
||||
// allocated to the device in `devices_applications` should be skipped.
|
||||
var updated []apps.Application = make([]apps.Application, len(req.InstalledApplicationList))
|
||||
var updated []apps.Application = []apps.Application{}
|
||||
skip:
|
||||
for _, ackApp := range requestApps {
|
||||
for _, app := range deviceNotRemoved {
|
||||
@@ -218,9 +217,7 @@ skip:
|
||||
|
||||
for _, insertApp := range updated {
|
||||
if err := svc.apps.SaveApplicationByDeviceUUID(device.UUID, &insertApp); err != nil {
|
||||
fmt.Println(err)
|
||||
fmt.Printf("could not save application, no valid uuid: %s, %s\n", insertApp.Name, insertApp.UUID)
|
||||
// return errors.Wrap(err, "saving installed application for a device")
|
||||
return errors.Wrap(err, "saving installed application for a device")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -115,6 +115,10 @@ func TestAckInstalledApplicationList(t *testing.T) {
|
||||
Version: "9.0",
|
||||
BundleSize: 14166172,
|
||||
},
|
||||
{
|
||||
Name: "Bundle Size Regression",
|
||||
BundleSize: 2463209237,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
@@ -126,6 +130,8 @@ func TestAckInstalledApplicationList(t *testing.T) {
|
||||
mock.ExpectQuery("INSERT INTO applications").WithArgs("Wireless Network Utility", nil, nil, nil, 2416111, 0, nil).WillReturnRows(wifiAppUuidRow)
|
||||
kcAppUuidRow := sqlmock.NewRows([]string{"application_uuid"}).AddRow("A0000000-1111-2222-3333-444455556666")
|
||||
mock.ExpectQuery("INSERT INTO applications").WithArgs("Keychain Access", "com.apple.keychainaccess", "9.0", "9.0", 14166172, 0, nil).WillReturnRows(kcAppUuidRow)
|
||||
sizeAppUuidRow := sqlmock.NewRows([]string{"application_uuid"}).AddRow("B0000000-1111-2222-3333-444455556666")
|
||||
mock.ExpectQuery("INSERT INTO applications").WithArgs("Bundle Size Regression", nil, nil, nil, 2463209237, 0, nil).WillReturnRows(sizeAppUuidRow)
|
||||
|
||||
// Expect query for device installed apps
|
||||
deviceAppsRow := sqlmock.NewRows([]string{"application_uuid", "name"}).AddRow("APP00000-1111-2222-3333-444455556666", "Mock Application")
|
||||
@@ -133,6 +139,7 @@ func TestAckInstalledApplicationList(t *testing.T) {
|
||||
|
||||
mock.ExpectExec("INSERT INTO devices_applications").WithArgs("00000000-1111-2222-3333-444455556666", "90000000-1111-2222-3333-444455556666").WillReturnResult(sqlmock.NewResult(1, 1))
|
||||
mock.ExpectExec("INSERT INTO devices_applications").WithArgs("00000000-1111-2222-3333-444455556666", "A0000000-1111-2222-3333-444455556666").WillReturnResult(sqlmock.NewResult(1, 1))
|
||||
mock.ExpectExec("INSERT INTO devices_applications").WithArgs("00000000-1111-2222-3333-444455556666", "B0000000-1111-2222-3333-444455556666").WillReturnResult(sqlmock.NewResult(1, 1))
|
||||
|
||||
svc := NewService(mockDevices, appDs, mockCmd)
|
||||
svc.Acknowledge(ctx, response)
|
||||
|
||||
@@ -8,8 +8,8 @@ CREATE TABLE IF NOT EXISTS applications (
|
||||
identifier text,
|
||||
short_version text,
|
||||
version text,
|
||||
bundle_size integer,
|
||||
dynamic_size integer,
|
||||
bundle_size bigint,
|
||||
dynamic_size bigint,
|
||||
is_validated bool,
|
||||
|
||||
install_count integer DEFAULT 1,
|
||||
|
||||
Reference in New Issue
Block a user