Files
fleet/orbit/pkg/packaging/linux_shared_test.go
Lucas Manuel Rodriguez 21c024313a Upgrade nfpm package in fleetctl (#48961)
Resolves #48954.

- [X] Changes file added for user-visible changes in `changes/`,
`orbit/changes/` or `ee/fleetd-chrome/changes`.

## Testing

- [X] QA'd all new/changed functionality manually
Tested a package generated with new `fleetctl` on Fedora 43, Ubuntu
25.04, and Omarchy.

## 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] If the change applies to only one platform, confirmed that
`runtime.GOOS` is used as needed to isolate changes
- [x] Verified that fleetd runs on macOS, Linux and Windows
- [x] Verified auto-update works from the released version of component
to the new version (see [tools/tuf/test](../tools/tuf/test/README.md))


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

## Summary of changes

* **Bug Fixes**
* Improved Linux RPM packaging consistency, including more reliable
output filename normalization and correct platform metadata.
* Ensured RPM metadata extraction stays aligned with the updated
packaging flow.
* **Tests**
  * Added coverage for RPM filename normalization edge cases.
* Updated a CPE rule validation test expectation to match the new
error-string format.
* **Chores**
  * Upgraded packaging tooling and refreshed Go dependencies.
* **Security**
* Removed a previously ignored CVE entry from vulnerability scan ignore
settings.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-07-09 15:29:48 -03:00

86 lines
2.1 KiB
Go

package packaging
import (
"testing"
"github.com/stretchr/testify/require"
)
func TestStripRPMRelease(t *testing.T) {
for _, tc := range []struct {
name string
in string
arch string
want string
}{
{
name: "amd64 conventional name",
in: "fleet-osquery-1.57.0-1.x86_64.rpm",
arch: "x86_64",
want: "fleet-osquery-1.57.0.x86_64.rpm",
},
{
name: "arm64 conventional name",
in: "fleet-osquery-1.57.0-1.aarch64.rpm",
arch: "aarch64",
want: "fleet-osquery-1.57.0.aarch64.rpm",
},
{
name: "version with build metadata (dots preserved, only release stripped)",
in: "fleet-osquery-1.57.0.20260708-1.x86_64.rpm",
arch: "x86_64",
want: "fleet-osquery-1.57.0.20260708.x86_64.rpm",
},
{
name: "single-component name still strips release",
in: "orbit-1.0.0-1.x86_64.rpm",
arch: "x86_64",
want: "orbit-1.0.0.x86_64.rpm",
},
// Edge cases: inputs that don't carry the expected "-1.<arch>.rpm"
// suffix are returned unchanged rather than mangled. In particular, a
// version whose last component happens to look like a release
// ("orbit-1.0.0") must not be truncated.
{
name: "no release segment with version is unchanged",
in: "orbit-1.0.0.x86_64.rpm",
arch: "x86_64",
want: "orbit-1.0.0.x86_64.rpm",
},
{
name: "no release segment (no dash before arch) is unchanged",
in: "foobar.x86_64.rpm",
arch: "x86_64",
want: "foobar.x86_64.rpm",
},
{
name: "no arch segment (no dot before ext) is unchanged",
in: "foobar.rpm",
arch: "x86_64",
want: "foobar.rpm",
},
{
name: "arch mismatch is unchanged",
in: "fleet-osquery-1.57.0-1.aarch64.rpm",
arch: "x86_64",
want: "fleet-osquery-1.57.0-1.aarch64.rpm",
},
{
name: "empty arch is a no-op",
in: "fleet-osquery-1.57.0-1.x86_64.rpm",
arch: "",
want: "fleet-osquery-1.57.0-1.x86_64.rpm",
},
{
name: "empty filename is unchanged",
in: "",
arch: "x86_64",
want: "",
},
} {
t.Run(tc.name, func(t *testing.T) {
require.Equal(t, tc.want, stripRPMRelease(tc.in, tc.arch))
})
}
}