Commit Graph

18 Commits

Author SHA1 Message Date
mosen
8c42e2d7e1 Response testing 1 (#42)
* Create skeleton test suite for connect transport

* Remove service test because sqlmock never made it into the master branch.
Add transport test for connect loosely based on groobs management transport tests.

* Added mock command service.
Add single test for InstalledApplicationList
Add some modified real world responses as test data.

* Create fake device fixture for connect tests

* Add some more macOS responses.
Fix nullstring error in transport test.
proper teardown of httptest server.

* Even more responses from live system to use as test fixtures.

* Cleanup commented code.
Simple test for inserted applications with InstalledApplicationList response.

* Cleanup unused imports.

* Add tests for DeviceInformation and CertificateList.
Try to construct the command request in setup(), dirty hack.

* Use rollback instead of inline statements to destroy fixtures.
Fix incorrect plist in deviceinformation test.
Minor cleanups

* Add checkin authenticate test.
Fix some "down" migrations which didnt actually work.

* Basic coverage of checkin tests.
Fix invalid fixture base64 data.

* Tidy up mock management service and imports.

* Revert back to setup()/teardown() style per discussion with groob.

* Clean up imports
2016-11-06 21:15:46 +11:00
mosen
e4ab7e0b17 Hotfix/last check in (#34)
* Convert all time.Time pointers to value types.
Use UTC time when updating `last_checkin`.
Update `last_checkin` correctly on Authenticate, TokenUpdate, and query response.
Set database defaults to golangs zero value for time.Time which is `0001-01-01`.

* Add down migration for time defaults.
2016-10-12 16:20:48 +11:00
mosen
b3e97c53b2 installed_certificates #14 plus conflict resolution (#21)
* Stub new method for application datastore
Handle command failures more gracefully than continuously retrying. Failures are not logged
Add table for certificates.

(cherry picked from commit 9f580a6)

* Remove methods with signature NewDatastore() from datastores and injection of the logger instance into each datastore because groob is a doodoo head :)
Move NewDatastore methods into unit tests
Reinstate NewDB test
Create certificates package including a Certificate type and a datastore.
Began working on a method ackCertificateList in the connect service.
Boilerplate for management service test.
Renamed some tables in certificates migration, hopefully nobody notices.
Applications response handler should be omitted from this branch.

(cherry picked from commit 8bc2fc7)

* Add device uuid to certificate, as there will never be a normalised form of the certificate data.
Change statments to reflect table change from certificates to devices_certificates
Add the CertificateList request type to the connect service's Acknowledge method
Add certificates datastore to the management service, and add endpoints and request/responses for retrieving certificates by device uuid to the management endpoujnt.
Kludge. commits regarding app service will be amended.
(cherry picked from commit c723c80)

* Don't forget the endpoint definition for certificates!

(cherry picked from commit 4e5fc1f)

* Use byte field for certificate data.

(cherry picked from commit 66d5036)

* Fix empty import in certificates

(cherry picked from commit b6d4dca)

* Add table for certificates.

(cherry picked from commit 06bc231)

* Renamed some tables in certificates migration, hopefully nobody notices.
Rebase develop onto master

(cherry picked from commit 775484d)

* Certificate list responses are saved via replacing the entire certificate list on a per device basis. This is because neither the common name nor the data could be used as a unique constraint in the certificates table.
Few small changes to imports/style.

(cherry picked from commit e0a63e1)

* Properly rollback if certificate insert fails for any certificate in a response.

(cherry picked from commit 99e1ea1)

* Fix several incorrect statements and struct tags which were preventing the certificates management endpoint from listing certs.
Certificate listing is working without a base64 encoded representation of each certificate.

(cherry picked from commit 685dfef)

* Add commands index to command datastore.
Add simple test for commands index
Add commands index endpoint

(cherry picked from commit 4e2a2a2)

* Add handler for GET /mdm/commands

(cherry picked from commit ae71b8f)

* Added Find() method to commands datastore so that the request that matches a response can be retrieved by the connect service.
Added Find() method to command service

(cherry picked from commit ebceb28)

* Fix globally scoped vars in command datastore test suite

* groob prefers inline definition of struct members.

* Uppercase CommandUuid
2016-10-07 11:34:50 +11:00
mosen
397087a800 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.
2016-10-07 10:55:12 +11:00
mosen
8b526c6aaa Add column unlock_token (#19)
Store unlock_token on TokenUpdate message.

(cherry picked from commit bcb16fc)
2016-10-07 10:00:00 +11:00
Mosen
ee6107b52f Use sql.NullString where possible to allow us to put unique constraints on both UDID and SerialNumber
Remove default of empty string '' from udid column.
2016-06-29 19:01:26 +10:00
Mosen
b35d697ad9 Add a few more statements to the up and down migrations for the new unique constraints so that the data will fit the constraints if up or downgraded.
Use sql.NullString for UDID and SerialNumber.
2016-06-28 20:08:49 +10:00
Mosen
2c388edc11 Go back to unique indexes on serial number and udid. Will use NullString on those struct columns. 2016-06-28 19:59:35 +10:00
Mosen
0c7a80b720 Omit last_query_response from changes. 2016-06-24 15:31:49 +10:00
Mosen
7388e1c9be Add update statements so existing devices dont break the not null constraints. 2016-06-24 15:02:34 +10:00
Mosen
85ba80a03f Add default values for several new fields added to devices. 2016-06-24 14:59:18 +10:00
Mosen
bc3cded620 Add device name to result in devices list.
Fix default and not null constraints on device_name field.
2016-06-22 20:09:52 +10:00
Mosen
3d08a855e8 Add migrations for fields last_checkin and device_name. 2016-06-22 20:01:42 +10:00
Mosen
621f5faf02 connect service Acknowledge updates information in devices table for QueryResponses
devices datastore updates QueryResponses into json column `last_query_response`, and some other main attributes into the devices table.
add migration to support column `last_query_response`.
2016-06-22 18:46:16 +10:00
Mosen
fca17af118 Drop index on serial_number, create unique constraint on both serial_number and udid to cover both DEP and OTA enrollment scenarios. 2016-06-22 17:12:39 +10:00
Mosen
2af4e101a9 Add unique constraint to devices.udid 2016-06-21 23:58:36 +10:00
Mosen
5896d8ca90 Provide down migrations. 2016-06-17 23:30:48 +10:00
Mosen
678ef99ce2 Add dependency gomigrate.
Extract create statements into individual migrations.
2016-06-17 23:09:54 +10:00