diff --git a/ee/localserver/request-id.go b/ee/localserver/request-id.go index 8d1beb77e..24cdb6d19 100644 --- a/ee/localserver/request-id.go +++ b/ee/localserver/request-id.go @@ -12,18 +12,25 @@ import ( "github.com/kolide/launcher/pkg/traces" ) -type identifiers struct { - UUID string - InstanceId string - HardwareSerial string -} +type ( + identifiers struct { + UUID string + InstanceId string + HardwareSerial string + } -type requestIdsResponse struct { - RequestId string - identifiers - Nonce string - Timestamp time.Time -} + requestIdsResponse struct { + RequestId string + identifiers + Nonce string + Timestamp time.Time + Status status + } + + status struct { + EnrollmentStatus string + } +) const ( idSQL = "select instance_id, osquery_info.uuid, hardware_serial from osquery_info, system_info" @@ -66,9 +73,14 @@ func (ls *localServer) requestIdHandlerFunc(w http.ResponseWriter, r *http.Reque r, span := traces.StartHttpRequestSpan(r, "path", r.URL.Path) defer span.End() + enrollmentStatus, _ := ls.knapsack.CurrentEnrollmentStatus() + response := requestIdsResponse{ Nonce: ulid.New(), Timestamp: time.Now(), + Status: status{ + EnrollmentStatus: string(enrollmentStatus), + }, } response.identifiers = ls.identifiers diff --git a/ee/localserver/request-id_test.go b/ee/localserver/request-id_test.go index fe5c9fecc..f917571ca 100644 --- a/ee/localserver/request-id_test.go +++ b/ee/localserver/request-id_test.go @@ -26,6 +26,7 @@ func Test_localServer_requestIdHandler(t *testing.T) { mockKnapsack := typesMocks.NewKnapsack(t) mockKnapsack.On("ConfigStore").Return(storageci.NewStore(t, multislogger.NewNopLogger(), storage.ConfigStore.String())) mockKnapsack.On("KolideServerURL").Return("localhost") + mockKnapsack.On("CurrentEnrollmentStatus").Return(types.Enrolled, nil) var logBytes bytes.Buffer slogger := slog.New(slog.NewJSONHandler(&logBytes, &slog.HandlerOptions{ @@ -53,6 +54,8 @@ func Test_localServer_requestIdHandler(t *testing.T) { // convert the response to a struct var response requestIdsResponse require.NoError(t, json.Unmarshal(rr.Body.Bytes(), &response)) + + mockKnapsack.AssertExpectations(t) } func testServer(t *testing.T, k types.Knapsack) *localServer {