Update DEP enrollment flow to apply minimum macOS version check when specified (#40720)

This commit is contained in:
Sarah Gillespie
2026-03-12 16:54:46 -05:00
committed by GitHub
parent d2332c5b2e
commit 85af52667d
19 changed files with 720 additions and 230 deletions
+29
View File
@@ -5,7 +5,16 @@ import (
"crypto/x509/pkix"
"encoding/asn1"
"math/big"
"net/http"
"net/http/httptest"
"os"
"path/filepath"
"runtime"
"testing"
"time"
"github.com/fleetdm/fleet/v4/server/dev_mode"
"github.com/stretchr/testify/require"
)
func NewTestMDMAppleCertTemplate() *x509.Certificate {
@@ -27,3 +36,23 @@ func NewTestMDMAppleCertTemplate() *x509.Certificate {
BasicConstraintsValid: true,
}
}
// StartNewAppleGDMFTestServer creates a new test server that serves the GDMF data from the testdata
// file. It also sets the necessary dev mode overrides to point to the test server and disable
// caching. It closes the server and clears the underlying overrides when the test finishes.
func StartNewAppleGDMFTestServer(t *testing.T) {
_, thisFile, _, _ := runtime.Caller(0)
gdmfTestDataPath := filepath.Join(filepath.Dir(thisFile), "../apple/gdmf/testdata/gdmf.json")
appleGDMFSrv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(http.StatusOK)
// load the test data from the file
b, err := os.ReadFile(gdmfTestDataPath)
require.NoError(t, err)
_, err = w.Write(b)
require.NoError(t, err)
}))
t.Cleanup(appleGDMFSrv.Close)
dev_mode.SetOverride("FLEET_DEV_GDMF_URL", appleGDMFSrv.URL, t)
}