fleet/orbit/pkg/osquery/flags_test.go
Zach Wasserman 8b77f0bd79
Enable gzip compression in osquery when run by Orbit (#38673)
If the osquery version is new enough (>= 5.21.0), Orbit will set the
configuration option.

**Related issue:** #38663 

# Checklist for submitter

If some of the following don't apply, delete the relevant line.

- [x] Changes file added for user-visible changes in `changes/`,
`orbit/changes/` or `ee/fleetd-chrome/changes`.
See [Changes
files](https://github.com/fleetdm/fleet/blob/main/docs/Contributing/guides/committing-changes.md#changes-files)
for more information.

## Testing

- [x] Added/updated automated tests
- [x] QA'd all new/changed functionality manually

## fleetd/orbit/Fleet Desktop

- [x] Verified compatibility with the latest released version of Fleet
(see [Must
rule](https://github.com/fleetdm/fleet/blob/main/docs/Contributing/workflows/fleetd-development-and-release-strategy.md))
- [x] Verified that fleetd runs on macOS, Linux and Windows (tested on
macOS but functionality is same on each platform)
2026-01-27 12:14:55 -08:00

40 lines
864 B
Go

package osquery
import (
"net/url"
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func TestFleetFlagsAcceptGzip(t *testing.T) {
u, err := url.Parse("https://fleet.example.com")
require.NoError(t, err)
tests := []struct {
version string
wantFlag bool
}{
{"5.20.0", false},
{"5.19.0-foobar", false},
{"5.21.0", true},
{"5.21.1", true},
{"5.21.0-24-g9e10d95ae", true},
{"5.22.0", true},
{"4.0.0", false},
{"invalid", false},
{"", false},
}
for _, tt := range tests {
t.Run(tt.version, func(t *testing.T) {
flags := FleetFlags(tt.version, u)
if tt.wantFlag {
assert.Contains(t, flags, "--tls_accept_gzip=true", "version %s missing flag", tt.version)
} else {
assert.NotContains(t, flags, "--tls_accept_gzip=true", "version %s unexpected flag", tt.version)
}
})
}
}