fleet/server/vulnerabilities/macoffice/integration_sync_test.go
Victor Lyuboslavsky 8ab072f600
Fix CI: extend grace periods for MSRC feeds and expand test coverage for file validation. (#37991)
1. Root cause: cmd/msrc/generate.go

Problem: The MSRC feed generator panicked when the January 2026 feed
wasn't available. The grace period was only 5 days, but MSRC feed
publication dates vary (not available right now).

  Fix: Extended grace period from 5 to 15 days.

2. Defensive fix:
server/vulnerabilities/macoffice/integration_sync_test.go

Problem: Test only checked for files from the last 2 days, which failed
when the NVD repo hadn't published for a few days.

  Fix: Extended tolerance to 7 days.
2026-01-07 10:28:20 -06:00

47 lines
1.1 KiB
Go

package macoffice
import (
"context"
"os"
"slices"
"testing"
"time"
"github.com/fleetdm/fleet/v4/pkg/nettest"
"github.com/fleetdm/fleet/v4/server/vulnerabilities/io"
"github.com/stretchr/testify/require"
)
func TestIntegrationsSync(t *testing.T) {
nettest.Run(t)
vulnPath := t.TempDir()
ctx := context.Background()
err := SyncFromGithub(ctx, vulnPath)
require.NoError(t, err)
entries, err := os.ReadDir(vulnPath)
var filesInVulnPath []string
for _, e := range entries {
filesInVulnPath = append(filesInVulnPath, e.Name())
}
require.NoError(t, err)
// Checking for the presence of the file from the last 7 days
// in case the NVD repo is having delays publishing the data (weekends, holidays, infra issues, etc.)
var expectedFilenames []string
for i := range 7 {
expectedFilenames = append(expectedFilenames, io.MacOfficeRelNotesFileName(time.Now().AddDate(0, 0, -i)))
}
require.Condition(t, func() bool {
for _, expectedFilename := range expectedFilenames {
if slices.Contains(filesInVulnPath, expectedFilename) {
return true
}
}
return false
}, "Expected to find one of %v in %s", expectedFilenames, vulnPath)
}