Skip to content
Merged
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ require (
github.com/spiffe/go-spiffe/v2 v2.6.0
github.com/spiffe/spire-api-sdk v1.2.5-0.20250109200630-101d5e7de758
github.com/spiffe/spire-plugin-sdk v1.4.4-0.20250606112051-68609d83ce7c
github.com/stretchr/testify v1.10.0
github.com/stretchr/testify v1.11.1
github.com/uber-go/tally/v4 v4.1.17
github.com/valyala/fastjson v1.6.4
golang.org/x/crypto v0.41.0
Expand Down
6 changes: 4 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1694,8 +1694,10 @@ github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
github.com/stretchr/testify v1.8.3/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/stretchr/testify v1.11.0 h1:ib4sjIrwZKxE5u/Japgo/7SJV3PvgjGiRNAvTVGqQl8=
github.com/stretchr/testify v1.11.0/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U=
github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
github.com/subosito/gotenv v1.6.0 h1:9NlTDc1FTs4qu0DDq7AEtTPNw6SVm7uBMsUCUjABIf8=
github.com/subosito/gotenv v1.6.0/go.mod h1:Dk4QP5c2W3ibzajGcXpNraDfq2IrhjMIvMSWPKKo0FU=
github.com/syndtr/goleveldb v1.0.1-0.20220721030215-126854af5e6d h1:vfofYNRScrDdvS342BElfbETmL1Aiz3i2t0zfRj16Hs=
Expand Down
21 changes: 16 additions & 5 deletions pkg/server/datastore/sqlstore/sqlstore_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1756,9 +1756,15 @@ func (s *PluginSuite) TestPruneAttestedNodeEvents() {
s.T().Run(tt.name, func(t *testing.T) {
s.Require().Eventuallyf(func() bool {
err = s.ds.PruneAttestedNodeEvents(ctx, tt.olderThan)
s.Require().NoError(err)
if err != nil {
return false
}

resp, err := s.ds.ListAttestedNodeEvents(ctx, &datastore.ListAttestedNodeEventsRequest{})
s.Require().NoError(err)
if err != nil {
return false
}

return reflect.DeepEqual(tt.expectedEvents, resp.Events)
}, 10*time.Second, 50*time.Millisecond, "Failed to prune entries correctly")
})
Expand Down Expand Up @@ -4396,10 +4402,15 @@ func (s *PluginSuite) TestPruneRegistrationEntryEvents() {
} {
s.T().Run(tt.name, func(t *testing.T) {
s.Require().Eventuallyf(func() bool {
err = s.ds.PruneRegistrationEntryEvents(ctx, tt.olderThan)
s.Require().NoError(err)
if err = s.ds.PruneRegistrationEntryEvents(ctx, tt.olderThan); err != nil {
return false
}

resp, err := s.ds.ListRegistrationEntryEvents(ctx, &datastore.ListRegistrationEntryEventsRequest{})
s.Require().NoError(err)
if err != nil {
return false
}

return reflect.DeepEqual(tt.expectedEvents, resp.Events)
}, 10*time.Second, 50*time.Millisecond, "Failed to prune entries correctly")
})
Expand Down
11 changes: 8 additions & 3 deletions pkg/server/plugin/notifier/k8sbundle/k8sbundle_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
"testing"
"time"

"github.com/google/go-cmp/cmp"
"github.com/hashicorp/hcl"
"github.com/spiffe/go-spiffe/v2/spiffeid"
identityproviderv1 "github.com/spiffe/spire-plugin-sdk/proto/spire/hostservice/server/identityprovider/v1"
Expand All @@ -26,7 +27,6 @@ import (
"github.com/spiffe/spire/test/fakes/fakeidentityprovider"
"github.com/spiffe/spire/test/plugintest"
"github.com/spiffe/spire/test/spiretest"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
Expand Down Expand Up @@ -258,7 +258,7 @@ kube_config_file_path = "/some/file/path"
require.Eventually(t, func() bool {
Copy link
Collaborator

@sorindumitru sorindumitru Aug 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's also the option of using EventuallyWithT. It has an assert.CollectT parameter that I think is usable with require.X.

actualWebhook, err := test.webhookClient.Get(context.Background(), webhook.Namespace, webhook.Name)
require.NoError(t, err)
return assert.Equal(t, &admissionv1.MutatingWebhookConfiguration{
diff := cmp.Diff(&admissionv1.MutatingWebhookConfiguration{
ObjectMeta: metav1.ObjectMeta{
Name: webhook.Name,
ResourceVersion: "1",
Expand All @@ -271,6 +271,8 @@ kube_config_file_path = "/some/file/path"
},
},
}, actualWebhook)

return diff != ""
}, testTimeout, testPollInterval)
}

Expand All @@ -290,7 +292,7 @@ kube_config_file_path = "/some/file/path"
require.Eventually(t, func() bool {
actualAPIService, err := test.apiServiceClient.Get(context.Background(), apiService.Namespace, apiService.Name)
require.NoError(t, err)
return assert.Equal(t, &apiregistrationv1.APIService{
diff := cmp.Diff(&apiregistrationv1.APIService{
ObjectMeta: metav1.ObjectMeta{
Name: apiService.Name,
ResourceVersion: "1",
Expand All @@ -299,6 +301,8 @@ kube_config_file_path = "/some/file/path"
CABundle: []byte(testBundleData),
},
}, actualAPIService)

return diff != ""
}, testTimeout, testPollInterval)
}

Expand Down Expand Up @@ -739,6 +743,7 @@ func (c *fakeKubeClient) Get(_ context.Context, namespace, configMap string) (ru
}
return entry, nil
}

func (c *fakeKubeClient) GetList(context.Context) (runtime.Object, error) {
list := c.getConfigMapList()
if list.Items == nil {
Expand Down
Loading