Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions lib/auth/tls_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -697,6 +697,7 @@ func TestRollback(t *testing.T) {
// create proxy client just for test purposes
proxy, err := testSrv.NewClient(TestBuiltin(types.RoleProxy))
require.NoError(t, err)
defer proxy.Close()

// client works before rotation is initiated
_, err = proxy.GetNodes(ctx, apidefaults.Namespace)
Expand Down Expand Up @@ -726,9 +727,12 @@ func TestRollback(t *testing.T) {
// new clients work
newProxy, err := testSrv.NewClient(TestBuiltin(types.RoleProxy))
require.NoError(t, err)
defer newProxy.Close()

_, err = newProxy.GetNodes(ctx, apidefaults.Namespace)
require.NoError(t, err)
require.EventuallyWithT(t, func(ct *assert.CollectT) {
_, err = testSrv.CloneClient(t, newProxy).GetNodes(ctx, apidefaults.Namespace)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Should we be passing ct to CloneClient?

Suggested change
_, err = testSrv.CloneClient(t, newProxy).GetNodes(ctx, apidefaults.Namespace)
_, err = testSrv.CloneClient(ct, newProxy).GetNodes(ctx, apidefaults.Namespace)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

No, failing to create the cloned client should stop the test (it has no reason to fail), and, as part of its creation, a cleanup is added to the test, which is not something that CollectT supports.

assert.NoError(ct, err)
}, 15*time.Second, 100*time.Millisecond)

// advance rotation:
err = testSrv.Auth().RotateCertAuthority(ctx, types.RotateRequest{
Expand Down Expand Up @@ -772,17 +776,13 @@ func TestRollback(t *testing.T) {
require.NoError(t, err)

// clients with new creds will no longer work as soon as backend modification event propagates.
require.Eventually(t, func() bool {
require.EventuallyWithT(t, func(ct *assert.CollectT) {
_, err := testSrv.CloneClient(t, newProxy).GetNodes(ctx, apidefaults.Namespace)
Comment thread
espadolini marked this conversation as resolved.
return err != nil
}, time.Second*15, time.Millisecond*200)
assert.Error(ct, err)
}, time.Second*15, time.Millisecond*100)

grpcClientOld := testSrv.CloneClient(t, proxy)
t.Cleanup(func() {
require.NoError(t, grpcClientOld.Close())
})
// clients with old creds will still work
_, err = grpcClientOld.GetNodes(ctx, apidefaults.Namespace)
_, err = testSrv.CloneClient(t, proxy).GetNodes(ctx, apidefaults.Namespace)
require.NoError(t, err)
}

Expand Down
Loading