Skip to content

Commit 088c242

Browse files
committed
Add unit tests for default client&server TLS config generator modifiers
Signed-off-by: Nassim 'Nass' Eddequiouaq <[email protected]>
1 parent 5bd7d32 commit 088c242

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

tlsconfig/config_test.go

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,44 @@ func TestConfigServerExclusiveRootPools(t *testing.T) {
287287
}
288288
}
289289

290+
// If we provide a modifier to the server's default TLS configuration generator, it
291+
// should be applied accordingly
292+
func TestConfigServerDefaultWithTLSMinimumModifier(t *testing.T) {
293+
tlsVersions := []uint16{
294+
tls.VersionTLS11,
295+
tls.VersionTLS12,
296+
}
297+
298+
for _, tlsVersion := range tlsVersions {
299+
servDefault := ServerDefault(func(c *tls.Config) {
300+
c.MinVersion = tlsVersion
301+
})
302+
303+
if servDefault.MinVersion != tlsVersion {
304+
t.Fatalf("Unexpected min TLS version for default server TLS config: ", servDefault.MinVersion)
305+
}
306+
}
307+
}
308+
309+
// If we provide a modifier to the client's default TLS configuration generator, it
310+
// should be applied accordingly
311+
func TestConfigClientDefaultWithTLSMinimumModifier(t *testing.T) {
312+
tlsVersions := []uint16{
313+
tls.VersionTLS11,
314+
tls.VersionTLS12,
315+
}
316+
317+
for _, tlsVersion := range tlsVersions {
318+
clientDefault := ClientDefault(func(c *tls.Config) {
319+
c.MinVersion = tlsVersion
320+
})
321+
322+
if clientDefault.MinVersion != tlsVersion {
323+
t.Fatalf("Unexpected min TLS version for default client TLS config: ", clientDefault.MinVersion)
324+
}
325+
}
326+
}
327+
290328
// If a valid minimum version is specified in the options, the server's
291329
// minimum version should be set accordingly
292330
func TestConfigServerTLSMinVersionIsSetBasedOnOptions(t *testing.T) {

0 commit comments

Comments
 (0)