Merge branch 'main' into feat-software-installers
This commit is contained in:
@@ -135,7 +135,7 @@ func NewTestMDMClientAppleDEP(serverURL string, depURLToken string, opts ...Test
|
||||
return &c
|
||||
}
|
||||
|
||||
// NewTestMDMClientDEP will create a simulated device that will not fetch the enrollment
|
||||
// NewTestMDMClientAppleDirect will create a simulated device that will not fetch the enrollment
|
||||
// profile from Fleet. The enrollment information is to be provided in the enrollInfo.
|
||||
func NewTestMDMClientAppleDirect(enrollInfo AppleEnrollInfo, opts ...TestMDMAppleClientOption) *TestAppleMDMClient {
|
||||
c := TestAppleMDMClient{
|
||||
@@ -151,6 +151,14 @@ func NewTestMDMClientAppleDirect(enrollInfo AppleEnrollInfo, opts ...TestMDMAppl
|
||||
return &c
|
||||
}
|
||||
|
||||
func (c *TestAppleMDMClient) SetDesktopToken(tok string) {
|
||||
c.desktopURLToken = tok
|
||||
}
|
||||
|
||||
func (c *TestAppleMDMClient) SetDEPToken(tok string) {
|
||||
c.depURLToken = tok
|
||||
}
|
||||
|
||||
// Enroll runs the MDM enroll protocol on the simulated device.
|
||||
func (c *TestAppleMDMClient) Enroll() error {
|
||||
switch {
|
||||
|
||||
+11
-11
@@ -22,8 +22,8 @@ import (
|
||||
type TestWindowsMDMClient struct {
|
||||
// DeviceID identifies a MDM enrollment, sent and managed by the device.
|
||||
DeviceID string
|
||||
// hardwareID identifies a device.
|
||||
hardwareID string
|
||||
// HardwareID identifies a device.
|
||||
HardwareID string
|
||||
// fleetServerURL is the URL of the Fleet server, used to ping the MDM endpoints.
|
||||
fleetServerURL string
|
||||
// debug enables debug logging of request/responses.
|
||||
@@ -31,8 +31,8 @@ type TestWindowsMDMClient struct {
|
||||
// enrollmentType is used to simulate different Windows enrollment
|
||||
// types (programatic, automatic.)
|
||||
enrollmentType fleet.WindowsMDMEnrollmentType
|
||||
// tokenIdentifier is used for authentication during the programmatic enrollment.
|
||||
tokenIdentifier string
|
||||
// TokenIdentifier is used for authentication during the programmatic enrollment.
|
||||
TokenIdentifier string
|
||||
// lastManagementResp tracks the last response we received from the server.
|
||||
lastManagementResp *fleet.SyncML
|
||||
// queuedCommandResponses tracks the commands that will be sent next
|
||||
@@ -57,8 +57,8 @@ func NewTestMDMClientWindowsProgramatic(serverURL string, orbitNodeKey string, o
|
||||
fleetServerURL: serverURL,
|
||||
DeviceID: uuid.NewString(),
|
||||
enrollmentType: fleet.WindowsMDMProgrammaticEnrollmentType,
|
||||
tokenIdentifier: orbitNodeKey,
|
||||
hardwareID: uuid.NewString(),
|
||||
TokenIdentifier: orbitNodeKey,
|
||||
HardwareID: uuid.NewString(),
|
||||
}
|
||||
for _, fn := range opts {
|
||||
fn(&c)
|
||||
@@ -71,8 +71,8 @@ func NewTestMDMClientWindowsAutomatic(serverURL string, email string, opts ...Te
|
||||
fleetServerURL: serverURL,
|
||||
DeviceID: uuid.NewString(),
|
||||
enrollmentType: fleet.WindowsMDMAutomaticEnrollmentType,
|
||||
tokenIdentifier: email,
|
||||
hardwareID: uuid.NewString(),
|
||||
TokenIdentifier: email,
|
||||
HardwareID: uuid.NewString(),
|
||||
}
|
||||
for _, fn := range opts {
|
||||
fn(&c)
|
||||
@@ -319,7 +319,7 @@ YioVozr1IWYySwWVzMf/SUwKZkKJCAJmSVcixE+4kxPkyPGyauIrN3wWC0zb+mjF
|
||||
<ac:Value>false</ac:Value>
|
||||
</ac:ContextItem>
|
||||
<ac:ContextItem Name="HWDevID">
|
||||
<ac:Value>` + c.hardwareID + `</ac:Value>
|
||||
<ac:Value>` + c.HardwareID + `</ac:Value>
|
||||
</ac:ContextItem>
|
||||
<ac:ContextItem Name="Locale">
|
||||
<ac:Value>en-US</ac:Value>
|
||||
@@ -487,7 +487,7 @@ func (c *TestWindowsMDMClient) getToken() (binarySecToken string, tokenValueType
|
||||
switch c.enrollmentType {
|
||||
case fleet.WindowsMDMAutomaticEnrollmentType:
|
||||
claims := &jwt.MapClaims{
|
||||
"upn": c.tokenIdentifier,
|
||||
"upn": c.TokenIdentifier,
|
||||
"tid": "tenant_id",
|
||||
"unique_name": "foo_bar",
|
||||
"scp": "mdm_delegation",
|
||||
@@ -504,7 +504,7 @@ func (c *TestWindowsMDMClient) getToken() (binarySecToken string, tokenValueType
|
||||
case fleet.WindowsMDMProgrammaticEnrollmentType:
|
||||
var err error
|
||||
tokenValueType = syncml.BinarySecurityDeviceEnroll
|
||||
binarySecToken, err = fleet.GetEncodedBinarySecurityToken(c.enrollmentType, c.tokenIdentifier)
|
||||
binarySecToken, err = fleet.GetEncodedBinarySecurityToken(c.enrollmentType, c.TokenIdentifier)
|
||||
if err != nil {
|
||||
return "", "", fmt.Errorf("generating encoded security token: %w", err)
|
||||
}
|
||||
|
||||
+13
-5
@@ -2,13 +2,14 @@ package spec
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/fleetdm/fleet/v4/server/fleet"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"slices"
|
||||
"testing"
|
||||
|
||||
"github.com/fleetdm/fleet/v4/server/fleet"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
var topLevelOptions = map[string]string{
|
||||
@@ -99,6 +100,7 @@ func TestValidGitOpsYaml(t *testing.T) {
|
||||
assert.Contains(t, gitops.OrgSettings, "webhook_settings")
|
||||
assert.Contains(t, gitops.OrgSettings, "fleet_desktop")
|
||||
assert.Contains(t, gitops.OrgSettings, "host_expiry_settings")
|
||||
assert.Contains(t, gitops.OrgSettings, "activity_expiry_settings")
|
||||
assert.Contains(t, gitops.OrgSettings, "features")
|
||||
assert.Contains(t, gitops.OrgSettings, "vulnerability_settings")
|
||||
assert.Contains(t, gitops.OrgSettings, "secrets")
|
||||
@@ -107,6 +109,14 @@ func TestValidGitOpsYaml(t *testing.T) {
|
||||
require.Len(t, secrets.([]*fleet.EnrollSecret), 2)
|
||||
assert.Equal(t, "SampleSecret123", secrets.([]*fleet.EnrollSecret)[0].Secret)
|
||||
assert.Equal(t, "ABC", secrets.([]*fleet.EnrollSecret)[1].Secret)
|
||||
activityExpirySettings, ok := gitops.OrgSettings["activity_expiry_settings"].(map[string]interface{})
|
||||
require.True(t, ok)
|
||||
activityExpiryEnabled, ok := activityExpirySettings["activity_expiry_enabled"].(bool)
|
||||
require.True(t, ok)
|
||||
require.True(t, activityExpiryEnabled)
|
||||
activityExpiryWindow, ok := activityExpirySettings["activity_expiry_window"].(float64)
|
||||
require.True(t, ok)
|
||||
require.Equal(t, 30, int(activityExpiryWindow))
|
||||
}
|
||||
|
||||
// Check controls
|
||||
@@ -144,7 +154,6 @@ func TestValidGitOpsYaml(t *testing.T) {
|
||||
assert.Equal(t, "No root logins (macOS, Linux)", gitops.Policies[2].Name)
|
||||
assert.Equal(t, "🔥 Failing policy", gitops.Policies[3].Name)
|
||||
assert.Equal(t, "😊😊 Failing policy", gitops.Policies[4].Name)
|
||||
|
||||
},
|
||||
)
|
||||
}
|
||||
@@ -239,7 +248,6 @@ func TestMixingGlobalAndTeamConfig(t *testing.T) {
|
||||
config += "team_settings:\n secrets: []\n"
|
||||
_, err = GitOpsFromBytes([]byte(config), "")
|
||||
assert.ErrorContains(t, err, "'org_settings' cannot be used with 'name' or 'team_settings'")
|
||||
|
||||
}
|
||||
|
||||
func TestInvalidGitOpsYaml(t *testing.T) {
|
||||
|
||||
@@ -171,6 +171,9 @@ org_settings:
|
||||
transparency_url: https://fleetdm.com/transparency
|
||||
host_expiry_settings: # Applies to all teams
|
||||
host_expiry_enabled: false
|
||||
activity_expiry_settings:
|
||||
activity_expiry_enabled: true
|
||||
activity_expiry_window: 30
|
||||
features: # Features added to all teams
|
||||
enable_host_users: true
|
||||
enable_software_inventory: true
|
||||
|
||||
Vendored
+3
@@ -74,6 +74,9 @@ fleet_desktop: # Applies to Fleet Premium only
|
||||
transparency_url: https://fleetdm.com/transparency
|
||||
host_expiry_settings: # Applies to all teams
|
||||
host_expiry_enabled: false
|
||||
activity_expiry_settings:
|
||||
activity_expiry_enabled: true
|
||||
activity_expiry_window: 30
|
||||
features: # Features added to all teams
|
||||
enable_host_users: true
|
||||
enable_software_inventory: true
|
||||
|
||||
Reference in New Issue
Block a user