mirror of
https://github.com/tailscale/tailscale.git
synced 2026-02-12 17:02:05 -05:00
This file was never truly necessary and has never actually been used in the history of Tailscale's open source releases. A Brief History of AUTHORS files --- The AUTHORS file was a pattern developed at Google, originally for Chromium, then adopted by Go and a bunch of other projects. The problem was that Chromium originally had a copyright line only recognizing Google as the copyright holder. Because Google (and most open source projects) do not require copyright assignemnt for contributions, each contributor maintains their copyright. Some large corporate contributors then tried to add their own name to the copyright line in the LICENSE file or in file headers. This quickly becomes unwieldy, and puts a tremendous burden on anyone building on top of Chromium, since the license requires that they keep all copyright lines intact. The compromise was to create an AUTHORS file that would list all of the copyright holders. The LICENSE file and source file headers would then include that list by reference, listing the copyright holder as "The Chromium Authors". This also become cumbersome to simply keep the file up to date with a high rate of new contributors. Plus it's not always obvious who the copyright holder is. Sometimes it is the individual making the contribution, but many times it may be their employer. There is no way for the proejct maintainer to know. Eventually, Google changed their policy to no longer recommend trying to keep the AUTHORS file up to date proactively, and instead to only add to it when requested: https://opensource.google/docs/releasing/authors. They are also clear that: > Adding contributors to the AUTHORS file is entirely within the > project's discretion and has no implications for copyright ownership. It was primarily added to appease a small number of large contributors that insisted that they be recognized as copyright holders (which was entirely their right to do). But it's not truly necessary, and not even the most accurate way of identifying contributors and/or copyright holders. In practice, we've never added anyone to our AUTHORS file. It only lists Tailscale, so it's not really serving any purpose. It also causes confusion because Tailscalars put the "Tailscale Inc & AUTHORS" header in other open source repos which don't actually have an AUTHORS file, so it's ambiguous what that means. Instead, we just acknowledge that the contributors to Tailscale (whoever they are) are copyright holders for their individual contributions. We also have the benefit of using the DCO (developercertificate.org) which provides some additional certification of their right to make the contribution. The source file changes were purely mechanical with: git ls-files | xargs sed -i -e 's/\(Tailscale Inc &\) AUTHORS/\1 contributors/g' Updates #cleanup Change-Id: Ia101a4a3005adb9118051b3416f5a64a4a45987d Signed-off-by: Will Norris <will@tailscale.com>
214 lines
5.0 KiB
Go
214 lines
5.0 KiB
Go
// Copyright (c) Tailscale Inc & contributors
|
|
// SPDX-License-Identifier: BSD-3-Clause
|
|
|
|
package compositedav
|
|
|
|
import (
|
|
"fmt"
|
|
"log"
|
|
"net/http"
|
|
"path"
|
|
"strings"
|
|
"testing"
|
|
"time"
|
|
|
|
"github.com/google/go-cmp/cmp"
|
|
"tailscale.com/tstest"
|
|
)
|
|
|
|
var parentPath = "/parent with spaces"
|
|
|
|
var childPath = "/parent with spaces/child.txt"
|
|
|
|
var parentResponse = `<D:response>
|
|
<D:href>/parent%20with%20spaces/</D:href>
|
|
<D:propstat>
|
|
<D:prop>
|
|
<D:getlastmodified>Mon, 29 Apr 2024 19:52:23 GMT</D:getlastmodified>
|
|
<D:creationdate>Fri, 19 Apr 2024 04:13:34 GMT</D:creationdate>
|
|
<D:resourcetype>
|
|
<D:collection xmlns:D="DAV:" />
|
|
</D:resourcetype>
|
|
</D:prop>
|
|
<D:status>HTTP/1.1 200 OK</D:status>
|
|
</D:propstat>
|
|
</D:response>`
|
|
|
|
var childResponse = `
|
|
<D:response>
|
|
<D:href>/parent%20with%20spaces/child.txt</D:href>
|
|
<D:propstat>
|
|
<D:prop>
|
|
<D:getlastmodified>Mon, 29 Apr 2024 19:52:23 GMT</D:getlastmodified>
|
|
<D:creationdate>Fri, 19 Apr 2024 04:13:34 GMT</D:creationdate>
|
|
<D:resourcetype>
|
|
<D:collection xmlns:D="DAV:" />
|
|
</D:resourcetype>
|
|
</D:prop>
|
|
<D:status>HTTP/1.1 200 OK</D:status>
|
|
</D:propstat>
|
|
</D:response>`
|
|
|
|
var fullParent = []byte(
|
|
strings.ReplaceAll(
|
|
fmt.Sprintf(`<?xml version="1.0" encoding="UTF-8"?><D:multistatus xmlns:D="DAV:">%s%s</D:multistatus>`, parentResponse, childResponse),
|
|
"\n", ""))
|
|
|
|
var partialParent = []byte(
|
|
strings.ReplaceAll(
|
|
fmt.Sprintf(`<?xml version="1.0" encoding="UTF-8"?><D:multistatus xmlns:D="DAV:">%s</D:multistatus>`, parentResponse),
|
|
"\n", ""))
|
|
|
|
var fullChild = []byte(
|
|
strings.ReplaceAll(
|
|
fmt.Sprintf(`<?xml version="1.0" encoding="UTF-8"?><D:multistatus xmlns:D="DAV:">%s</D:multistatus>`, childResponse),
|
|
"\n", ""))
|
|
|
|
func TestStatCacheNoTimeout(t *testing.T) {
|
|
// Make sure we don't leak goroutines
|
|
tstest.ResourceCheck(t)
|
|
|
|
c := &StatCache{TTL: 5 * time.Second}
|
|
defer c.stop()
|
|
|
|
// check get before set
|
|
fetched := c.get(childPath, 0)
|
|
if fetched != nil {
|
|
t.Errorf("got %v, want nil", fetched)
|
|
}
|
|
|
|
// set new stat
|
|
ce := newCacheEntry(http.StatusMultiStatus, fullChild)
|
|
c.set(childPath, 0, ce)
|
|
fetched = c.get(childPath, 0)
|
|
if diff := cmp.Diff(fetched, ce); diff != "" {
|
|
t.Errorf("should have gotten cached value; (-got+want):%v", diff)
|
|
}
|
|
|
|
// fetch stat again, should still be cached
|
|
fetched = c.get(childPath, 0)
|
|
if diff := cmp.Diff(fetched, ce); diff != "" {
|
|
t.Errorf("should still have gotten cached value; (-got+want):%v", diff)
|
|
}
|
|
}
|
|
|
|
func TestStatCacheTimeout(t *testing.T) {
|
|
// Make sure we don't leak goroutines
|
|
tstest.ResourceCheck(t)
|
|
|
|
c := &StatCache{TTL: 250 * time.Millisecond}
|
|
defer c.stop()
|
|
|
|
// set new stat
|
|
ce := newCacheEntry(http.StatusMultiStatus, fullChild)
|
|
c.set(childPath, 0, ce)
|
|
fetched := c.get(childPath, 0)
|
|
if diff := cmp.Diff(fetched, ce); diff != "" {
|
|
t.Errorf("should have gotten cached value; (-got+want):%v", diff)
|
|
}
|
|
|
|
// wait for cache to expire and refetch stat, should be empty now
|
|
time.Sleep(c.TTL * 2)
|
|
|
|
fetched = c.get(childPath, 0)
|
|
if fetched != nil {
|
|
t.Errorf("cached value should have expired")
|
|
}
|
|
|
|
c.set(childPath, 0, ce)
|
|
// invalidate the cache and make sure nothing is returned
|
|
c.invalidate()
|
|
fetched = c.get(childPath, 0)
|
|
if fetched != nil {
|
|
t.Errorf("invalidate should have cleared cached value")
|
|
}
|
|
}
|
|
|
|
func TestParentChildRelationship(t *testing.T) {
|
|
// Make sure we don't leak goroutines
|
|
tstest.ResourceCheck(t)
|
|
|
|
c := &StatCache{TTL: 24 * time.Hour} // don't expire
|
|
defer c.stop()
|
|
|
|
missingParentPath := "/missingparent"
|
|
unparseableParentPath := "/unparseable"
|
|
|
|
c.set(parentPath, 1, newCacheEntry(http.StatusMultiStatus, fullParent))
|
|
c.set(missingParentPath, 1, newCacheEntry(http.StatusNotFound, nil))
|
|
c.set(unparseableParentPath, 1, newCacheEntry(http.StatusMultiStatus, []byte("<this will not parse")))
|
|
|
|
tests := []struct {
|
|
path string
|
|
depth int
|
|
want *cacheEntry
|
|
}{
|
|
{
|
|
path: parentPath,
|
|
depth: 1,
|
|
want: newCacheEntry(http.StatusMultiStatus, fullParent),
|
|
},
|
|
{
|
|
path: parentPath,
|
|
depth: 0,
|
|
want: newCacheEntry(http.StatusMultiStatus, partialParent),
|
|
},
|
|
{
|
|
path: childPath,
|
|
depth: 0,
|
|
want: newCacheEntry(http.StatusMultiStatus, fullChild),
|
|
},
|
|
{
|
|
path: path.Join(parentPath, "nonexistent.txt"),
|
|
depth: 0,
|
|
want: notFound,
|
|
},
|
|
{
|
|
path: missingParentPath,
|
|
depth: 1,
|
|
want: notFound,
|
|
},
|
|
{
|
|
path: missingParentPath,
|
|
depth: 0,
|
|
want: notFound,
|
|
},
|
|
{
|
|
path: path.Join(missingParentPath, "filename.txt"),
|
|
depth: 0,
|
|
want: notFound,
|
|
},
|
|
{
|
|
path: unparseableParentPath,
|
|
depth: 1,
|
|
want: nil,
|
|
},
|
|
{
|
|
path: unparseableParentPath,
|
|
depth: 0,
|
|
want: nil,
|
|
},
|
|
{
|
|
path: path.Join(unparseableParentPath, "filename.txt"),
|
|
depth: 0,
|
|
want: nil,
|
|
},
|
|
{
|
|
path: "/unknown",
|
|
depth: 1,
|
|
want: nil,
|
|
},
|
|
}
|
|
|
|
for _, test := range tests {
|
|
t.Run(fmt.Sprintf("%d%s", test.depth, test.path), func(t *testing.T) {
|
|
got := c.get(test.path, test.depth)
|
|
if diff := cmp.Diff(got, test.want); diff != "" {
|
|
t.Errorf("unexpected cached value; (-got+want):%v", diff)
|
|
log.Printf("want\n%s", test.want.Raw)
|
|
log.Printf("got\n%s", got.Raw)
|
|
}
|
|
})
|
|
}
|
|
}
|