tailfs: fix race condition in tailfs_test

Ues a noop authenticator to avoid potential races in gowebdav's
built-in authenticator.

Fixes #11259

Signed-off-by: Percy Wegmann <percy@tailscale.com>
pull/11247/head
Percy Wegmann 3 months ago committed by Percy Wegmann
parent 086ef19439
commit 05acf76392

@ -5,6 +5,7 @@ package tailfsimpl
import (
"fmt"
"io"
"io/fs"
"log"
"net"
@ -142,7 +143,7 @@ func newSystem(t *testing.T) *system {
}
}()
client := gowebdav.NewClient(fmt.Sprintf("http://%s", l.Addr()), "", "")
client := gowebdav.NewAuthClient(fmt.Sprintf("http://%s", l.Addr()), &noopAuthorizer{})
client.SetTransport(&http.Transport{DisableKeepAlives: true})
s := &system{
t: t,
@ -375,3 +376,33 @@ func fileInfoToStatic(fi fs.FileInfo, fixupMode bool) fs.FileInfo {
func pathTo(remote, share, name string) string {
return path.Join(domain, remote, share, name)
}
// noopAuthorizer implements gowebdav.Authorizer. It does no actual
// authorizing. We use it in place of gowebdav's built-in authorizer in order
// to avoid a race condition in that authorizer.
type noopAuthorizer struct{}
func (a *noopAuthorizer) NewAuthenticator(body io.Reader) (gowebdav.Authenticator, io.Reader) {
return &noopAuthenticator{}, nil
}
func (a *noopAuthorizer) AddAuthenticator(key string, fn gowebdav.AuthFactory) {
}
type noopAuthenticator struct{}
func (a *noopAuthenticator) Authorize(c *http.Client, rq *http.Request, path string) error {
return nil
}
func (a *noopAuthenticator) Verify(c *http.Client, rs *http.Response, path string) (redo bool, err error) {
return false, nil
}
func (a *noopAuthenticator) Clone() gowebdav.Authenticator {
return &noopAuthenticator{}
}
func (a *noopAuthenticator) Close() error {
return nil
}

Loading…
Cancel
Save