Skip to content

Commit

Permalink
fixup! test: fixup some racing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jimlambrt committed Sep 29, 2023
1 parent e9a6b6a commit 0090f76
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package gldap_test

import (
"crypto/tls"
"crypto/x509"
"fmt"
"sync"
"testing"
Expand Down Expand Up @@ -167,10 +168,18 @@ func TestServer_shutdownCtx(t *testing.T) {
td := testdirectory.Start(fakeT, testdirectory.WithDefaults(t, &testdirectory.Defaults{AllowAnonymousBind: true}))
time.Sleep(1 * time.Second) // allow time so the test directory will start up.
go func() {
client := td.Conn()
defer client.Close()
certpool := x509.NewCertPool()
certpool.AppendCertsFromPEM([]byte(td.Cert()))
tlsConfig := &tls.Config{
RootCAs: certpool,
}
conn, err := ldap.DialURL(fmt.Sprintf("ldaps://localhost:%d", td.Port()), ldap.DialWithTLSConfig(tlsConfig))
if err != nil {
return
}
defer conn.Close()
for {
err := client.UnauthenticatedBind("alice")
err := conn.UnauthenticatedBind("alice")
if err != nil {
return
}
Expand Down

0 comments on commit 0090f76

Please sign in to comment.