mirror of
https://github.com/fleetdm/fleet
synced 2026-05-22 08:28:52 +00:00
<!-- Add the related story/sub-task/bug number, like Resolves #123, or remove if NA --> **Related issue:** Resolves #34389 # Checklist for submitter If some of the following don't apply, delete the relevant line. - [x] Input data is properly validated, `SELECT *` is avoided, SQL injection is prevented (using placeholders for values in statements) ## Testing - [x] Added/updated automated tests - [x] Where appropriate, [automated tests simulate multiple hosts and test for host isolation](https://github.com/fleetdm/fleet/blob/main/docs/Contributing/reference/patterns-backend.md#unit-testing) (updates to one hosts's records do not affect another) - [x] QA'd all new/changed functionality manually ## Database migrations - [x] Checked schema for all modified table for columns that will auto-update timestamps during migration. - [x] Ensured the correct collation is explicitly set for character columns (`COLLATE utf8mb4_unicode_ci`).
64 lines
1.8 KiB
Go
64 lines
1.8 KiB
Go
package android
|
|
|
|
import (
|
|
"os"
|
|
"testing"
|
|
|
|
"github.com/fleetdm/fleet/v4/server/fleet"
|
|
android_mock "github.com/fleetdm/fleet/v4/server/mdm/android/mock"
|
|
android_service "github.com/fleetdm/fleet/v4/server/mdm/android/service"
|
|
"github.com/fleetdm/fleet/v4/server/service"
|
|
"github.com/fleetdm/fleet/v4/server/service/integrationtest"
|
|
"github.com/fleetdm/fleet/v4/server/service/middleware/endpoint_utils"
|
|
"github.com/fleetdm/fleet/v4/server/service/modules/activities"
|
|
"github.com/go-kit/log"
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
type Suite struct {
|
|
integrationtest.BaseSuite
|
|
AndroidProxy *android_mock.Client
|
|
}
|
|
|
|
func SetUpSuite(t *testing.T, uniqueTestName string) *Suite {
|
|
ds, redisPool, fleetCfg, fleetSvc, ctx := integrationtest.SetUpMySQLAndRedisAndService(t, uniqueTestName)
|
|
logger := log.NewLogfmtLogger(os.Stdout)
|
|
proxy := android_mock.Client{}
|
|
proxy.InitCommonMocks()
|
|
activityModule := activities.NewActivityModule(ds, logger)
|
|
androidSvc, err := android_service.NewServiceWithClient(
|
|
logger,
|
|
ds,
|
|
&proxy,
|
|
"test-private-key",
|
|
ds,
|
|
activityModule,
|
|
)
|
|
require.NoError(t, err)
|
|
androidSvc.(*android_service.Service).AllowLocalhostServerURL = true
|
|
users, server := service.RunServerForTestsWithServiceWithDS(t, ctx, ds, fleetSvc, &service.TestServerOpts{
|
|
License: &fleet.LicenseInfo{
|
|
Tier: fleet.TierFree,
|
|
},
|
|
FleetConfig: &fleetCfg,
|
|
Pool: redisPool,
|
|
Logger: logger,
|
|
FeatureRoutes: []endpoint_utils.HandlerRoutesFunc{android_service.GetRoutes(fleetSvc, androidSvc)},
|
|
})
|
|
|
|
s := &Suite{
|
|
BaseSuite: integrationtest.BaseSuite{
|
|
Logger: logger,
|
|
DS: ds,
|
|
FleetCfg: fleetCfg,
|
|
Users: users,
|
|
Server: server,
|
|
},
|
|
AndroidProxy: &proxy,
|
|
}
|
|
|
|
integrationtest.SetUpServerURL(t, ds, server)
|
|
|
|
s.Token = s.GetTestAdminToken(t)
|
|
return s
|
|
}
|