Installed application list (#18)

* Add table `applications` and `devices_applications` for tracking installed applications per device and total installed application count.

(cherry picked from commit fba935d)

* Define new datastore for retrieving installed applications by device uuid
Add InstalledApps method to management service
Add endpoint for installed applications at /management/v1/devices/uuid/applications

(cherry picked from commit 07b2deb)

* REMOVED: Flesh out implementation of acknowledging InstalledApplicationList response.
Additional tags on Application for database.
Applications datastore supports select with arbitrary where clauses
Changed the signatures of all the ack handlers in connect service.

(cherry picked from commit f16b776)

* Revert acknowledge handlers code.
Add stub for acknowledging installed applications list.

(cherry picked from commit 82f7e3a)

* Fix some error strings in application datastore which still referred to devices.
Add method SaveApplicationByDeviceUUID to add rows to `devices_applications` for the specified device uuid
Add method NewDatastore since NewDB was untestable using mocks.
Connect service now takes an applications datastore as one of its parameters.
ackInstalledApplicationList implemented but not tested for InstallApplicationList responses.

(cherry picked from commit 97a97d9)

* Further comments on applications datastore.
Attempt to make some where clause helper functions.
Expand test suites to cover many different type of installed applications.
All tests passing.

(cherry picked from commit be99fcd)

* Additional comments
Fix methods which returned a pointer to a slice which is pointless.
Moved statement building functions in applications package to statement.go.
Fixed acknowledge handler if device UDID does not match any enrolled device (happens a lot in test cases).
Preliminary re-implementation of ackInstalledApplicationList
Added tests for the connect service.

(cherry picked from commit 92f253c)

* Add basic test for ackInstalledApplicationList

(cherry picked from commit 66ec74c)

* Fix wrong positional parameters.
Add handler for InstalledApplicationList request type.
installed applications are inserted but their relationship to the current device is not yet recorded. work in progress.

(cherry picked from commit e90c78d)

* Fixed slices which used make() showing the wrong capacity.
Removed a bunch of debug print statements.
Further enhanced connect service test with sql mocking.

(cherry picked from commit 0913934)

* 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`

(cherry picked from commit 3038d17)

* Note about difference between iOS and macOS Responses in comments.
Handle iOS response to InstalledApplicationList
Empty test for duplicate applications regression
Update management service test to fit new signature for NewService()

(cherry picked from commit db7c431)

* Changed application response storage to devices_applications, similar to certificates. Every time the device reports a new list, the application list gets replaced.
Add PayloadScope to enroll endpoint because interactive enrollment always seems to try to use the User scope.

(cherry picked from commit 0b0a01d)

* Merge change that removes NewDatastore() from applications/datastore.

* Add setup and teardown to application datastore test.
Remove existing tests because they were using the old Datastore interface.

* Remove invalid imports whoops

* Removed commented code.
Imported name device clashed with variable name device, renamed.

* Fix applications datastore New method in connect service test suite.

* Pull all vars out of global scope in connect service test.
This commit is contained in:
mosen
2016-10-07 10:55:12 +11:00
committed by GitHub
parent 85fff70046
commit ca80a23a2a
2 changed files with 4 additions and 0 deletions

View File

@@ -13,6 +13,7 @@ type Payload struct {
PayloadDisplayName string `json:"displayname" db:"displayname"`
PayloadDescription string `json:"description,omitempty" db:"description"`
PayloadOrganization string `json:"organization,omitempty" db:"organization"`
PayloadScope string `json:"scope" db:"scope" plist:"omitempty"`
PayloadContent interface{} `json:"content,omitempty" plist:"PayloadContent,omitempty"`
}

View File

@@ -57,6 +57,7 @@ func (svc service) Enroll(ctx context.Context) (Profile, error) {
profile.PayloadOrganization = "MicroMDM"
profile.PayloadDisplayName = "Enrollment Profile"
profile.PayloadDescription = "The server may alter your settings"
profile.PayloadScope = "System"
scepContent := SCEPPayloadContent{
Challenge: svc.SCEPChallenge,
@@ -73,11 +74,13 @@ func (svc service) Enroll(ctx context.Context) (Profile, error) {
scepPayload.PayloadDisplayName = "SCEP"
scepPayload.PayloadIdentifier = "com.github.micromdm.scep"
scepPayload.PayloadContent = scepContent
scepPayload.PayloadScope = "System"
mdmPayload := NewPayload("com.apple.mdm")
mdmPayload.PayloadDescription = "Enrolls with the MDM server"
mdmPayload.PayloadOrganization = "MicroMDM"
mdmPayload.PayloadIdentifier = "com.github.micromdm.mdm"
mdmPayload.PayloadScope = "System"
mdmPayloadContent := MDMPayloadContent{
Payload: *mdmPayload,