feat: add SSO workspace, named shares and Debian release tooling
This commit is contained in:
1 parent
833d908884
commit
87bc33e675
106 files changed
+4160
-5637
No files matched your search
@@ -0,0 +1,43 @@
|
||||
package fbhttp
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/filebrowser/filebrowser/v2/settings"
|
||||
"github.com/filebrowser/filebrowser/v2/users"
|
||||
)
|
||||
|
||||
func TestCustomShareKey(t *testing.T) {
|
||||
root := t.TempDir()
|
||||
if err := os.WriteFile(filepath.Join(root, "report.txt"), []byte("report"), 0600); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
perm := users.Permissions{Share: true, Download: true}
|
||||
st := scopedUserStorage(t, root, perm, []byte("test-key"))
|
||||
create := func(key string) *httptest.ResponseRecorder {
|
||||
r := httptest.NewRequest("POST", "/report.txt", strings.NewReader(`{"key":"`+key+`"}`))
|
||||
r = authorizeTestRequest(r, signToken(t, perm, nil))
|
||||
w := httptest.NewRecorder()
|
||||
handle(sharePostHandler, "", st, &settings.Server{}).ServeHTTP(w, r)
|
||||
return w
|
||||
}
|
||||
if w := create("quarterly-report"); w.Code != 200 || !strings.Contains(w.Body.String(), `"hash":"quarterly-report"`) {
|
||||
t.Fatalf("create: %d %s", w.Code, w.Body.String())
|
||||
}
|
||||
if w := create("quarterly-report"); w.Code != http.StatusConflict {
|
||||
t.Fatalf("duplicate accepted: %d", w.Code)
|
||||
}
|
||||
for _, key := range []string{"..", "a/b", "x", "has space", "-start"} {
|
||||
if w := create(key); w.Code != 400 {
|
||||
t.Fatalf("invalid key %q accepted: %d", key, w.Code)
|
||||
}
|
||||
}
|
||||
if w := create(""); w.Code != 200 {
|
||||
t.Fatalf("random key: %d", w.Code)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user