mirror of
https://github.com/tailscale/tailscale.git
synced 2025-04-25 10:14:36 +00:00
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>
This commit is contained in:
parent
086ef19439
commit
05acf76392
@ -5,6 +5,7 @@ package tailfsimpl
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"io"
|
||||||
"io/fs"
|
"io/fs"
|
||||||
"log"
|
"log"
|
||||||
"net"
|
"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})
|
client.SetTransport(&http.Transport{DisableKeepAlives: true})
|
||||||
s := &system{
|
s := &system{
|
||||||
t: t,
|
t: t,
|
||||||
@ -375,3 +376,33 @@ func fileInfoToStatic(fi fs.FileInfo, fixupMode bool) fs.FileInfo {
|
|||||||
func pathTo(remote, share, name string) string {
|
func pathTo(remote, share, name string) string {
|
||||||
return path.Join(domain, remote, share, name)
|
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…
x
Reference in New Issue
Block a user