Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update types for TestAuthServerConfig #49194

Merged
merged 1 commit into from
Nov 22, 2024
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion lib/auth/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ type TestAuthServerConfig struct {
// CipherSuites is the list of ciphers that the server supports.
CipherSuites []uint16
// Clock is used to control time in tests.
Clock clockwork.FakeClock
Clock clockwork.Clock
// ClusterNetworkingConfig allows a test to change the default
// networking configuration.
ClusterNetworkingConfig types.ClusterNetworkingConfig
Expand Down
21 changes: 16 additions & 5 deletions lib/auth/tls_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -413,8 +413,9 @@ func TestAutoRotation(t *testing.T) {
t.Parallel()

ctx := context.Background()
testSrv := newTestTLSServer(t)
clock := testSrv.AuthServer.TestAuthServerConfig.Clock
clock := clockwork.NewFakeClock()
testSrv := newTestTLSServer(t, withClock(clock))

var ok bool

// create proxy client
Expand Down Expand Up @@ -514,8 +515,8 @@ func TestAutoFallback(t *testing.T) {
t.Parallel()

ctx := context.Background()
testSrv := newTestTLSServer(t)
clock := testSrv.AuthServer.TestAuthServerConfig.Clock
clock := clockwork.NewFakeClock()
testSrv := newTestTLSServer(t, withClock(clock))

var ok bool

Expand Down Expand Up @@ -4977,6 +4978,7 @@ func verifyJWTAWSOIDC(clock clockwork.Clock, clusterName string, pairs []*types.
type testTLSServerOptions struct {
cacheEnabled bool
accessGraph *AccessGraphConfig
clock clockwork.Clock
}

type testTLSServerOption func(*testTLSServerOptions)
Expand All @@ -4993,6 +4995,12 @@ func withAccessGraphConfig(cfg AccessGraphConfig) testTLSServerOption {
}
}

func withClock(clock clockwork.Clock) testTLSServerOption {
return func(options *testTLSServerOptions) {
options.clock = clock
}
}

// newTestTLSServer is a helper that returns a *TestTLSServer with sensible
// defaults for most tests that are exercising Auth Service RPCs.
//
Expand All @@ -5003,9 +5011,12 @@ func newTestTLSServer(t testing.TB, opts ...testTLSServerOption) *TestTLSServer
for _, opt := range opts {
opt(&options)
}
if options.clock == nil {
options.clock = clockwork.NewFakeClockAt(time.Now().Round(time.Second).UTC())
}
as, err := NewTestAuthServer(TestAuthServerConfig{
Dir: t.TempDir(),
Clock: clockwork.NewFakeClockAt(time.Now().Round(time.Second).UTC()),
Clock: options.clock,
CacheEnabled: options.cacheEnabled,
})
require.NoError(t, err)
Expand Down
Loading