fix tests

This commit is contained in:
Roberto Dip 2024-03-29 14:18:26 -03:00
parent 4e11b3574c
commit e39d5d9341
2 changed files with 3 additions and 5 deletions

View File

@ -3342,7 +3342,7 @@ func (svc *MDMAppleDDMService) handleDeclarationsResponse(ctx context.Context, e
case "configuration":
return svc.handleConfigurationDeclaration(ctx, parts, hostUUID)
default:
return nil, nano_service.NewHTTPStatusError(http.StatusBadRequest, ctxerr.Errorf(ctx, "declaration type not supported: %s", parts[1]))
return nil, nano_service.NewHTTPStatusError(http.StatusNotFound, ctxerr.Errorf(ctx, "declaration type not supported: %s", parts[1]))
}
}

View File

@ -450,16 +450,14 @@ INSERT INTO host_mdm_apple_declarations (
// try getting a non-existent declaration, should fail 404
nonExistantDeclarationPath := fmt.Sprintf("declaration/%s/%s", "configuration", "nonexistent")
res, err := mdmDevice.DeclarativeManagement(nonExistantDeclarationPath)
_, err = mdmDevice.DeclarativeManagement(nonExistantDeclarationPath)
require.Error(t, err)
require.Equal(t, http.StatusNotFound, res.StatusCode)
require.ErrorContains(t, err, "404 Not Found")
// try getting an unsupported declaration, should fail 404
unsupportedDeclarationPath := fmt.Sprintf("declaration/%s/%s", "asset", "nonexistent")
res, err = mdmDevice.DeclarativeManagement(unsupportedDeclarationPath)
_, err = mdmDevice.DeclarativeManagement(unsupportedDeclarationPath)
require.Error(t, err)
require.Equal(t, http.StatusNotFound, res.StatusCode)
require.ErrorContains(t, err, "404 Not Found")
// typo should fail as bad request