Fixing whatsapp FMA app version (#31119)

Fixes #31185

whatsapp prefixes their version with '2.'. Either this ia a platform
code or some less relevant bit we can drop. It is fairly consistent when
looking through version history.

# Checklist for submitter

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

<!-- Note that API documentation changes are now addressed by the
product design team. -->

- [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.
- [x] Added/updated automated tests
- [x] Manual QA for all new/changed functionality
This commit is contained in:
Konstantin Sykulev 2025-07-31 12:16:44 -05:00 committed by GitHub
parent eb7b07bc46
commit ba18664446
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 52 additions and 1 deletions

View file

@ -9,6 +9,7 @@ import (
var Funcs = map[string][]func(*maintained_apps.FMAManifestApp) (*maintained_apps.FMAManifestApp, error){
"microsoft-word/darwin": {MicrosoftVersionFromReleaseNotes},
"microsoft-excel/darwin": {MicrosoftVersionFromReleaseNotes},
"whatsapp/darwin": {WhatsAppVersionShortener},
"google-chrome/darwin": {ChromePKGInstaller},
}

View file

@ -0,0 +1,20 @@
package externalrefs
import (
"fmt"
"strings"
maintained_apps "github.com/fleetdm/fleet/v4/ee/maintained-apps"
)
func WhatsAppVersionShortener(app *maintained_apps.FMAManifestApp) (*maintained_apps.FMAManifestApp, error) {
homebrewVersion := app.Version
if strings.HasPrefix(homebrewVersion, "2.") {
app.Version = strings.TrimPrefix(homebrewVersion, "2.")
} else {
return app, fmt.Errorf("Expected WhatsApp version to start with '2.' but found '%s'", homebrewVersion)
}
return app, nil
}

View file

@ -0,0 +1,30 @@
package externalrefs
import (
"testing"
maintained_apps "github.com/fleetdm/fleet/v4/ee/maintained-apps"
"github.com/stretchr/testify/assert"
)
func TestWhatsAppVersionShortener(t *testing.T) {
t.Run("successful version found", func(t *testing.T) {
app := &maintained_apps.FMAManifestApp{
UniqueIdentifier: "whatsapp/darwin",
Version: "2.25.16.81",
}
result, err := WhatsAppVersionShortener(app)
assert.NoError(t, err)
assert.Equal(t, "25.16.81", result.Version)
})
t.Run("unexpected version format", func(t *testing.T) {
app := &maintained_apps.FMAManifestApp{
UniqueIdentifier: "whatsapp/darwin",
Version: "3.25.16.81",
}
result, err := WhatsAppVersionShortener(app)
assert.Error(t, err)
assert.Equal(t, "3.25.16.81", result.Version)
})
}

View file

@ -1,7 +1,7 @@
{
"versions": [
{
"version": "2.25.17.82",
"version": "25.17.82",
"queries": {
"exists": "SELECT 1 FROM apps WHERE bundle_identifier = 'net.whatsapp.WhatsApp';"
},