ammendment to properly fix #17489 (#17499)

for #17489, found an edge case during extra testing.
This commit is contained in:
Roberto Dip 2024-03-08 13:15:04 -03:00 committed by GitHub
parent 37885d0932
commit a39932b013
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 13 additions and 1 deletions

View file

@ -1565,7 +1565,11 @@ func deduceMDMNameWindows(data map[string]string) string {
}
func directIngestMDMWindows(ctx context.Context, logger log.Logger, host *fleet.Host, ds fleet.Datastore, rows []map[string]string) error {
if len(rows) != 1 {
if len(rows) == 0 {
// no mdm information in the registry
return ds.SetOrUpdateMDMData(ctx, host.ID, false, false, "", false, "", "")
}
if len(rows) > 1 {
logger.Log("component", "service", "method", "directIngestMDMWindows", "warn",
fmt.Sprintf("mdm expected single result got %d", len(rows)))
// assume the extension is not there

View file

@ -715,6 +715,14 @@ func TestDirectIngestMDMWindows(t *testing.T) {
wantIsServer: false,
wantServerURL: "",
},
{
name: "off no rows",
data: []map[string]string{},
wantEnrolled: false,
wantInstalledFromDep: false,
wantIsServer: false,
wantServerURL: "",
},
{
name: "on automatic",
data: []map[string]string{